LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop loop during process

Solved!
Go to solution

Hello,

 

One again, i'm back for another question, eager to learn more about labview and these countless obscure secrets.

Well my problem seem's to be a commun problem but i didn't find the answer in other topics.
Here are the levels of my VI (more simple if you directly look at VI)

1st level, I have a case event to launch the measure or to go back to the main Vi
2nd level (during the measure process), I have a while loop with a case event inside to stop the loop if the process is blocked. but it doesn't work.

 

And to make matters worse I can not press the buttons when the measurement started

 

I'm on this problem since 10 hours this is not a question asked without thinking but i'm realy blocked.

 

Thanks

 


0 Kudos
Message 1 of 9
(3,356 Views)

You have set the outer event structures Start Case to "Lock front panel until this event case completes. This is why pressing the button is simply ignored.

 

Christian

0 Kudos
Message 2 of 9
(3,353 Views)

Ok i just look at that and it solve the button problem, thanks.
The main problem, about stopping while loop during the process is still present.
Someone have any idea about that ?

0 Kudos
Message 3 of 9
(3,350 Views)

When I press the button "stop measure" the while loop and so the exectuion of the VI stops. Is this not what you are asking for?

 

Christian

Message 4 of 9
(3,347 Views)
Solution
Accepted by topic author demum

First of all, stacking event structures is going to be tricky very fast, so i want to disencourage to do this until you are an experienced LV developer. You are currently just dipping on the "first issues", which is commonly understood as caveats of the event structure.

 

The second thing is, i understand that you want to terminate the wait function itself (which represents your external code). This cannot be done. The reason is simple: LV is simply waiting for the code to complete. So telling LV to stop execution will come true as soon as LV "gets back the baton". This is going to happen once the external code has finished executing.

 

You CAN terminate the external thread using the Windows API, but you should/must restart the whole LV application to prevent memory corruption created by the killed threads (not suggested).

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 5 of 9
(3,341 Views)

Ok, firstly, i updated my VI , this on is made with your advice.
Yes the VI stops but before it waiting for the end of the loop ( 10s in this case).
I want it to stop immediatly after pushing STOP button.

0 Kudos
Message 6 of 9
(3,339 Views)

Norbert,

I understand, it seem's that LV is working only with flow. I can't stop the flow ..
An another solution would be to get my DAQ process (daq assistant + trigger) out of the sub VI and to put a manual button on trigger and DAQ assistant.
The manual button works, but it don't stop the loop. (look at en & condition on picture).

I send you a picture of the real VI because he is quite complex to send Smiley Surprised

0 Kudos
Message 7 of 9
(3,327 Views)

I repeat:

If something is blocking the execution of LV code, LV will not terminate. So if you wait for e.g. 1M DAQ samples acquired with 1Hz, you will have to wait 1,000,000 seconds without being able to terminate this.

 

OK, this example is exaggerated, but i hope you get the point. For DAQmx, you can configure a timeout in order to not have such long times until *something* happens.

You should get in touch with concepts like

- streaming

- producer/consumer

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 8 of 9
(3,320 Views)

Yes i understand. My solution works because the DAQ loop is looping every 0.17s.

So LV check STOP button every 0.17 s (much enough for me).

 

Tanks for your help.

The answer to this post is this is not possible to break flow. find an another solution 🙂

0 Kudos
Message 9 of 9
(3,317 Views)