LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event driven front panels ?

Hi,

This is a problem that I seem to be running into a lot
lately.

Suppose that you have a front panel with a bunch of
buttons (or other controls) and you want each button
to perform some action (ie excecute a sub-vi) when it
is pressed.

Is there a way to do this WITHOUT using a polling loop?

What I mean is: can I tie a particular action to each
button without having to make a loop that checks each
button to see if it has been depressed?

The reason I ask is that if there are lot of controls
on the front panel, the loop that checks which have
been changed can end up taking a long time and/or a
demand a heavy CPU load.

Does anyone know any tricks for dealing with this?

Something that can mimic the behavior of windows or
J
ava interfaces would be perfect, butI am willing
to investigate clever polling tactics as well.

Thanks for any assistance,
H.


Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 1 of 8
(2,963 Views)
helix_r@my-deja.com wrote:What I mean is: can I tie a particular action to
each

> button without having to make a loop that checks each
> button to see if it has been depressed?
>

You can make one loop that checks all buttons.
There is not way ( that I am aware of ) to do this
without at least one loop.

>
> The reason I ask is that if there are lot of controls
> on the front panel, the loop that checks which have
> been changed can end up taking a long time and/or a
> demand a heavy CPU load.
>
> Does anyone know any tricks for dealing with this?
>

I have a VI with several Booleans on the FP.
I then used the build array function to make
a Boolean array. From this I used the "Boolean Array to Number"
function to determine which button was pushed. This is fed into
a c
ase structure that determines what SubVI to call.

This is all enclosed in a while loop, with a "Wait ms" timer to allow for
time sharing. I never looked at the CPU usage since it does not matter in
this application.
One drawback is that once a button is pushed and the SubVI runs the main
loop is suspended until the SubVI exits. For my application this is exaclty
what I want though so it is not a problem for me.

I would like to hear other suggestions
Kevin Kent
0 Kudos
Message 2 of 8
(2,963 Views)
Kevin B. Kent wrote in message
news:384433DD.99A75455@usa.alcatel.com...
> helix_r@my-deja.com wrote:What I mean is: can I tie a particular action to
> each
>
> > button without having to make a loop that checks each
> > button to see if it has been depressed?
> >
>
> You can make one loop that checks all buttons.
> There is not way ( that I am aware of ) to do this
> without at least one loop.
>
> >
> > The reason I ask is that if there are lot of controls
> > on the front panel, the loop that checks which have
> > been changed can end up taking a long time and/or a
> > demand a heavy CPU load.
> >
> > Does anyone know any tricks for dealing with this?
> >
>
> I have a VI with several Booleans on the FP.
> I then used the build a
rray function to make
> a Boolean array. From this I used the "Boolean Array to Number"
> function to determine which button was pushed. This is fed into
> a case structure that determines what SubVI to call.
>
> This is all enclosed in a while loop, with a "Wait ms" timer to allow for
> time sharing. I never looked at the CPU usage since it does not matter in
> this application.
> One drawback is that once a button is pushed and the SubVI runs the main
> loop is suspended until the SubVI exits. For my application this is
exaclty
> what I want though so it is not a problem for me.
>

My application is functioning in a similar fashion. However, I have multiple
while loops so that some necessary operations can happen in a parallel.
In essence there are several main loops. Adding the proper wait statements
is essential when doing this polling. Another problem encountered when
you have a main control panel/main loop calling subvi's is that the main
display can't get data updates until the
subvi has completed execution. I
could only get around that by using a subvi as my display page.

I would also like to know how others have solved this common problem.

Joe Orndorff
0 Kudos
Message 4 of 8
(2,963 Views)
> My application is functioning in a similar fashion. However, I have multiple
> while loops so that some necessary operations can happen in a parallel.
> In essence there are several main loops. Adding the proper wait statements
> is essential when doing this polling. Another problem encountered when
> you have a main control panel/main loop calling subvi's is that the main
> display can't get data updates until the subvi has completed execution. I
> could only get around that by using a subvi as my display page.
>
> I would also like to know how others have solved this common problem.

After I had written some applications, I had following idea:

Use two main while loops, each loop is doing its special job
independently:
The first loop checks, whehter a
control has been changed and executes
the demanded modification.
The second loop gets the data of your measurement in a stable interval
and displays the data.

If you have some machines that give you an update of your data slower
than other machines or measuring instrument, make a third loop, which
writes the data of your machines in local variables or in arrays.
The second loop then takes those variables and arrays and displays the
data in a stable interval irrespective of the data has been changed or
not.

So you have no event driven front panels.
I realized this idea in several applications and it works well.


--
Ciao
Max


* Max Weiss*Adlerstr.22*76133 Karlsruhe*0721/3842835*Germany *
* max@mvmpc9.ciw.uni-karlsruhe.de*DB8MWE *
0 Kudos
Message 6 of 8
(2,963 Views)
helix_r@my-deja.com wrote:
>
> Hi,
>
> This is a problem that I seem to be running into a lot
> lately.
>
> Suppose that you have a front panel with a bunch of
> buttons (or other controls) and you want each button
> to perform some action (ie excecute a sub-vi) when it
> is pressed.
>
> Is there a way to do this WITHOUT using a polling loop?
>
> What I mean is: can I tie a particular action to each
> button without having to make a loop that checks each
> button to see if it has been depressed?
>
> The reason I ask is that if there are lot of controls
> on the front panel, the loop that checks which have
> been changed can end up taking a long time and/or a
> demand a heavy CPU load.
>
> Does anyone know any tricks for dealing with this?
>
> Something that
can mimic the behavior of windows or
> Java interfaces would be perfect, butI am willing
> to investigate clever polling tactics as well.
>
> Thanks for any assistance,
> H.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.


You could try a polling while loop, running in parallel
with your vi. Put a 'wait ms' vi in it, so that it doesn't
hog cpu time (maybe 100 or 200 ms).

'OR' all the button outputs into a digital indicator,
then make a local variable for the indicator. You can check
the local variable, at non critical times, in your main vi.

I haven't tried the parallel while loop + local variable.
My last vi was or-ing local variables of the buttons in
different places in my vi. It turned out a bit of a mess,
but it works.

Walter
0 Kudos
Message 3 of 8
(2,963 Views)
helix_r@my-deja.com wrote:

> Hi,
>
> This is a problem that I seem to be running into a lot
> lately.
>
> Suppose that you have a front panel with a bunch of
> buttons (or other controls) and you want each button
> to perform some action (ie excecute a sub-vi) when it
> is pressed.
>
> Is there a way to do this WITHOUT using a polling loop?
>
> What I mean is: can I tie a particular action to each
> button without having to make a loop that checks each
> button to see if it has been depressed?
>
> The reason I ask is that if there are lot of controls
> on the front panel, the loop that checks which have
> been changed can end up taking a long time and/or a
> demand a heavy CPU load.
>
> Does anyone know any tricks for dealing with this?
>
> Something that can mimic th
e behavior of windows or
> Java interfaces would be perfect, butI am willing
> to investigate clever polling tactics as well.
>
> Thanks for any assistance,
> H.

I created a set of VIs just for this purpose.
Buttons will be created at run time. Each takes an
occurance. Whenever the button is pressed, the
corresponding occurance will be set. No polling,
no CPU time wasted! Support raise when cursor hover,
flatten when cursor leave.

Download "button.zip" at:

http://gtoolbox.topcool.net/gtool51.htm


George Zou
http://gtoolbox.topcool.net
http://rtprint.yeah.net
0 Kudos
Message 5 of 8
(2,963 Views)
Thanks George and everyone who responded,

I have been using some of the techniques you guys
have mentioned. I like the idea of multiple parallel
loops to speed things up.

One thing that I have done in the past is to put
my controls in a cluster, and then flatten the
cluster to a string and poll to see if the
string has changed. This is good if you have a mess
of controls that are not necessarily booleans, although
I don't think you want to be doing "flatten to string"

I was hoping that there was a cool elegant solution
to the problem... but I guess that the lack of
event-driving controls is a fundamental limitation
of LabVIEW as a programming language.

I do like George's solution, even though it uses a CIN
and proprietary code.

regards,
H


In arti
cle <384609F4.6A57@nosuch.com>,
zz wrote:
> helix_r@my-deja.com wrote:
> >
> I created a set of VIs just for this purpose.
> Buttons will be created at run time. Each takes an
> occurance. Whenever the button is pressed, the
> corresponding occurance will be set. No polling,
> no CPU time wasted! Support raise when cursor hover,
> flatten when cursor leave.
>
> Download "button.zip" at:
> http://gtoolbox.topcool.net/gtool51.htm
>
> George Zou
> http://gtoolbox.topcool.net
> http://rtprint.yeah.net
>


Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 7 of 8
(2,962 Views)
Event driven programming is now supported in labview 6.1. You can read about using event structures in the Labview 6.1 manual.
0 Kudos
Message 8 of 8
(2,962 Views)