LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timer fucntion

Hi all,
I am trying to port VB 6.o code to LabVIEW 7.0. Got stuck up with timers. Please help me to sort of this issue. In the current VB code, there is a fucntion called Scan, which receives the input from GUI. This function execution is based on timer value. Say if the timer is set for 5ms, then the scan will be called for every 5ms and also, if I click on any button in the GUI or change any value. The changed value will be passed to scan function.

I need to implement the same in LabVIEW program. So, I used millisecond timer in loop, to execute the code present in the loop for every 5ms. But now the other part of the code (like change in any control value etc) is not getting executed ,till this while loop terminates. I am totally confused in the design of the code. Help Me
Thanks,
Poornima
0 Kudos
Message 1 of 3
(2,679 Views)
A better way to do this is an event structure. It eliminates polling entirely and you can create events for any kind of FP changes you desire. Instead of polling every 5ms if anything changes, the code waits until an event occurs.

The basic design is an event structure inside a while loop. Any monitored event (e.g. value change of a control) will trigger execution of the assigned event case. Have a look at the shipping examples. Search for "events". Have a look at e.g. the example named "event tracking.vi" or "New event handler.vi".

Back to your original question:
Without event structures, you need to compare each value with the previous value from a shift register at each iteration to see if they have changed. use the boolean output of the comparison to switch to a designated execution case. If nothing changed, play an empty case. The case structure of course must be in the same loop where the polling takes place, NOT outside the loop as you seem to be trying to do.

There are many more complex ways to do this, e.g. with seperate loops for UI and computations, linked by e.g. queues. At this stage, I would keep it simple.
Message 2 of 3
(2,677 Views)
Hi,
It is working fine now.
Thanks a lot.
Poornima
0 Kudos
Message 3 of 3
(2,637 Views)