LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use of local variables

Hello,

I'm new into Labview and would like to ask for feedback on the programm I made. I have two controls, each activating a boolean pulse when triggered. Starting the VI is setting the controls as well pulse-booleans to default (zero). The way I programmed is with multiple local variables, however this the use of them should be limited within labview to keep an overview on the dataflow.Is there a way to make this vi more effecient (read: programming like an expert would do Smiley Happy)?

Looking forward to your feedback!

 

Pieter

 

Download All
0 Kudos
Message 1 of 5
(2,704 Views)

Post your actual VI rather than a picture.

 

1.  Your leftmost while loop does nothing.

2.  Your Select statements are a Rube Goldberg.  Using a boolean to decide whether to pass on a True or a False is redundant.  Just use the boolean wire itself.

3.  There is an =0 function on the palette.  No need to use the equals and the zero constant.

0 Kudos
Message 2 of 5
(2,702 Views)

Hi RavensFan, thanks for your feedback. I made the adjustments you suggested. So the VI is an acceptable solution for initiating a puls (with an adjustable puls length)?

However, I face the problem that the pulses are not always directly started when pushing, or when changing quickly on/off the button 1, the pulse is even not started. How can I improve timings in this situation (trigger the pulse immediately (and reproducible)).

 

Thank you very much, all feedback is appreciated.

Pieter

0 Kudos
Message 3 of 5
(2,688 Views)

Both your loop spin millions of times per second, as fast as the CPU allows. The two loop need a small wait so they alternate.

 

I would use an event structures, this way the loop does not spin until needed. Here's a quick example. As has been mentioned, your "select" construct makes no sense. Why do you invert the value from the local variable in the inner loop? You can change the termination mode directly instead.

 

 

0 Kudos
Message 4 of 5
(2,666 Views)

I used the event structure also. I used queues to transfer the data from the button loop to the display loops.  The timeout on the Dequeue is used to set the blink rate when the user does not make any changes. As in altenbach's example you could use local variables to force the buttons to a known state in the beginning.

 

One problem with my version: Although the event structure responds immediately to the stop button, the Dequeue timeouts must run in the display loops before they will stop. A more complicated queue process could send both the boolean and the stop commands through the same queues and the notifier would not be needed.

 

Lynn

 

0 Kudos
Message 5 of 5
(2,663 Views)