LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best programming technique

Hello,

 

I have made a very large labview suite. The description of the suite can be simplified so that their are three main loops. These are:

 

1. The principal while loop.

 

2. A while loop which updates indicators on the front panel.

 

3. A while loop which checks for the stop button being pressed.

 

 

The .vi isn't perfect since there is no way of the while loops 2 and 3 ending. What is the best way for me to end loops 2 and 3 when the end of the program is reached. ie report variable (data acquisition is complete) is reached.

 

.vi

0 Kudos
Message 1 of 30
(3,339 Views)

Some good practise certainly, but I find this part below really weird unusual.

 

Clipboard01.png


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 30
(3,314 Views)

I believe it is Ed Dickens who sports the signature;

 

"Using the stop button to stop your VI is like using a tree to stop your car. It may be effective but you may not like the consequences."

 

I believe you can answer your own question if you turn on execution highlighting (the light bulb) (after getting rid of that stop thingy) and watch the code while asking the question "What knows about the stop and what SHOULD know about the stop?".

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 30
(3,305 Views)

Yeah, that is a very brute force way to stop your code.  Just put the STOP terminal in your main while loop and OR it with the existing boolean there.

http://www.medicollector.com
0 Kudos
Message 4 of 30
(3,304 Views)

And I also see one while loop is running without a time delay. This would eat all your CPU usage and aslo the loop is stopped by a value from the shared variable (Am not sure where it is written) suppose if the loop stops but the rest of the loops will be keep on running so the FP will seem to be hanged you need to avoid this and sychronize the loops.

-----

The best solution is the one you find it by yourself
Message 5 of 30
(3,295 Views)

@Ben wrote:

"Using the stop button to stop your VI is like using a tree to stop your car. It may be effective but you may not like the consequences."

 


I like the image! Smiley Very Happy


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 6 of 30
(3,292 Views)

The lower left loop is unnecessary, you destroy the event after the main loop which is sufficent. Move the stop button inside the main loop, use a local of it to stop your global update loop, and for the love of Nurgle, place a wait in the global update loop (100ms?)

 

/Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 30
(3,288 Views)

Hello Yamaeda,

 

I need the .vi to stop at the very end. (ie after the Report Variable and error out at the very right of the .vi.)

 

How can I do this by creating a local stop variable from the main while loop?

 

Nevica

 

 

0 Kudos
Message 8 of 30
(3,277 Views)

The VI will stop once data has passed through all wires, so the VI will wait until the report is written.

/Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 30
(3,271 Views)

Hello Yamaeda,

 

You are wrong in saying that the left lower while loop is destroyed after the main while loop finishes. It does in fact continue along with the right lower while loop. That is the problem.

0 Kudos
Message 10 of 30
(3,268 Views)