LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

COUNTER

i want to do a VI that does the function of 3 astable timers but i want that the program doesn't close when the timers end

0 Kudos
Message 1 of 6
(3,290 Views)

Great. What have you tried so far? Have you looked at shipping examples? Have you done the LabVIEW tutorials?

 

You could, for example, make a producer-consumer VI. Your producer would have an event structure that adds a state to a queue and your consumer is a state machine. Simple, effective.

0 Kudos
Message 2 of 6
(3,246 Views)

Wow, there are so many ways to achieve that.  There is the producer consumer scheme as one solution.  Another solution would be to create a sub-vi out of the timer portion and then put that in a switch in a loop... see example.

 

Good Luck!

Download All
0 Kudos
Message 3 of 6
(3,226 Views)

Comments regarding the code provided by Drewski:

 

  • Change the mechanical action of "Go" to Latch When Release. Now eliminate the property nodes. VI still works as intended.
  • It is a BAD idea to use the Stop function unless you have a REALLY good reason for it. In this case there is no good reason, and it's actually completely pointless, since the VI will stop once the loop ends. Even if you have code that gets run after the loop ends, the VI will still stop on its own.
0 Kudos
Message 4 of 6
(3,223 Views)

Wow, you looked at my code, cool.  Thank you for the feedback.

 

You're right, latch on release would eliminate the property nodes.  My covert reason for using them was to introduce the programmer to alternatives to local variables.

 

You're also right about the "stop" being superfulous, as the loop would stop.  I'm not clear on how it is BAD.  Can you please educate me on that?  My covert reason for explicitly using the stop was so that a "Quit" could be installed in it's place later for application type behavior.

 

Thanks and Good Luck.

0 Kudos
Message 5 of 6
(3,216 Views)

 


@Drewski wrote:

Wow, you looked at my code, cool.  Thank you for the feedback.

 

You're right, latch on release would eliminate the property nodes.  My covert reason for using them was to introduce the programmer to alternatives to local variables.


 

That's perfectly fine, as long as you also provide the caveats for local variables: http://forums.ni.com/t5/BreakPoint/Why-some-people-say-Local-Variables-are-bad/td-p/711239.

 

 


You're also right about the "stop" being superfulous, as the loop would stop.  I'm not clear on how it is BAD.  Can you please educate me on that?  My covert reason for explicitly using the stop was so that a "Quit" could be installed in it's place later for application type behavior.

The Stop function performs the same exact action as clicking on the Abort button in the toolbar. It will certainly stop your program, but there are consequences, such as (potentially) references not being closed, files left open, etc. As the signature of a regular says, a tree will also stop your car, but there are consequences.

 

0 Kudos
Message 6 of 6
(3,206 Views)