LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event structure, while loop resources

Hello, I am new to event structures and so far have been using them in conjunction with a while loop. Currently I have written simple programs that wait for a front panel control to change value before execution code inside the event structure. My question is, should I place a timer outside the event structure and inside the while loop to periodically check for the front panel control change? I want to save resources as much as possible, and am not exactly sure how draining it is to have the while loop outside constantly executing (if it is executing?) while the program waits for the event structure to execute. Perhaps there is a better appraoch to take? Thanks!

0 Kudos
Message 1 of 4
(3,066 Views)

Hello,

 

It sounds like you are doing things correctly.  You will see on the upper left of the event structure that there is a timeout variable that you can wire up.  If you wire -1 (the default) the while loop will only execute when an event is triggered (you can verify this by throwing an indicator on the interation count of the while loop).  In effect, the event structure acts like the wait function that you will asking about.  Ask more questions if they come up!

0 Kudos
Message 2 of 4
(3,064 Views)
Create a VI that has nothing but a control and an event structure with an event on the control.  If you run the VI and open task manager you will see that LabVIEW is not using any resources until you trigger an event.
Jim

LV 2020
0 Kudos
Message 3 of 4
(3,061 Views)

Hi Newbie217,

 

If you want to know how long an event runs you can use the Tick Count function and place two--one before and one after the event. Please refer to the example VI, Event Tracking.vi to get a better idea of how this works. The Tick Count function does not have an absolute zero reference and so you need to find the difference between ticks to get the time elapsed.

 

Ipshita C.

National Instruments
Applications Engineer
0 Kudos
Message 4 of 4
(3,035 Views)