LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event driven programming

I am a c++ programmer trying to use labview and I am not getting it?!? I want to have the Vi to run continuously and respond to any front panel changes that the user makes (ie change the frequency). We have bought the base package and it does not have the event structure. Are there any other ways?
0 Kudos
Message 1 of 4
(2,722 Views)
Before the event handler (introduced in 6.1), the programmer has to compare the values. A way to do this is using a shift register to compare the current value of a given with the value at the last iteration of the main loop. See the attached example.

I'd say that, unless you're writing a pretty simple program, the event structure is not the only thing you'll wish you had. It might be worthwhile upgrading to the full version.

Tim
0 Kudos
Message 2 of 4
(2,722 Views)
> I am a c++ programmer trying to use labview and I am not getting it?!?
> I want to have the Vi to run continuously and respond to any front
> panel changes that the user makes (ie change the frequency). We have
> bought the base package and it does not have the event structure. Are
> there any other ways?

Without events, you periodically compare the value from the frequency
with the previous value which you stored in a shift register. If the
value changes do whatever is appropriate. If you have multiple
controls, these are usually bundled, then compared. In the case they
are the same, you can sleep something like 50ms, which updates often
enough for UIs, but uses very little CPU.

Greg McKaskle
0 Kudos
Message 3 of 4
(2,722 Views)
Yes, some of us did programs before the Event Structure came along.

I have attached an example of how I have done it for years.

Basically, you employ a "change-detector", comparing the current value of a control to the previous value. If different, you do something in response; if not, you don't.

I use a sequence here to save diagram space, not because they need to be executed in a particular order.

Be sure to use a WAIT function somewhere in the loop, or you'll hog the CPU. There's no point in checking the STOP button 1,000,000+ times per second.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 4 of 4
(2,722 Views)