LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event structure and radio buttons

I put a button on the front panel, all by its lonesome.  I create an event (value change) for the button.  Every time I press the button, the event fires.  Good.

 

Then I put a radio button on the front panel.  The radio button works fine.  Good.

 

Now I press the button.  The event fires.  The radio button continues to work.  Still good.

 

Now I press the button again.  The event (apparently) does not fire and the radio botton is locked.  Not good.

 

If you wish I can post the program but it is so simple that anybody can create it in a minute or two.

 

What could possibly be happening?

0 Kudos
Message 1 of 27
(4,350 Views)

Please include a Snippet of your code, or attach your VIs, so that we can better assist you. We are here to help, but won't spend all day recreating your code from scratch just to help.

You probably spent more time typing that out than it woould have taken to save a snippet.

 

What you've described, the step-by-step code build, shouldn't result in any problems, which means you probably did something weird.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 27
(4,341 Views)

Have you used radio buttons before?  I mean usually they are for selecting one of many.  If you only have one then things get confusing.  If you have two then selecting the unselected one should generate some value changed event.  If you keep selecting the only radio button that is already selected then the value doesn't change so the value changed event doesn't kick.  

 

Maybe I'm way off.  I haven't used radio buttons in LabView yet.  

Grant M. Johnson
Project Engineer
LECO Corporation
0 Kudos
Message 3 of 27
(4,335 Views)

What Grant said is correct... if you aren't changing the value of the radio buttons enum (that's all it is really, an enum in the form of buttons), then you won't generate a value change event.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 27
(4,327 Views)

OK.  Here is the program.

0 Kudos
Message 5 of 27
(4,317 Views)

You have a While loop inside of a While loop. This means the inner while loop holds up the rest of the VI. Literally everything outside that inner loop will run a single time and then wait. So what's happening is the event structure is then locking up the application because it can't handle the second press of the button.

 

You should never do what you are doing in a real application user interface. Everything has to follow data flow. You can easily fix this by getting rid of the inner While loop.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 6 of 27
(4,305 Views)

You have an infinite inner while loop.  It is doing nothing but burning away CPU cycles writing the radio button value to an indicator.  The event structure waits on the button.

 

The outer while loop won't iterate until ALL the code inside of it is done.  This is a basic DATAFLOW principle.  The event structure is done because it waited untilt he event was fired.  But the inner while loop is not done.  And it will never be because you have a False wired to the stop button.

 

Turn on highlight execution and learn how LabVIEW works.

Message 7 of 27
(4,302 Views)

I took a stab at implementing the suggested changes.  Am I on the right track?

Grant M. Johnson
Project Engineer
LECO Corporation
0 Kudos
Message 8 of 27
(4,243 Views)

On the right track.

 

  • You could just not wire the timeout input because you don't have a timeout case. This means that you don't need to time out. Add the QUIT button tot he event structure and trigger the loop to stop from that.
  • If you move the Button terminal to inside the event for the button, you can make the button act as a Latch when pressed and you wont need to write False to it every loop.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 9 of 27
(4,236 Views)

Thanks,

 

I tried it and the button change fires every time but the radio buttons do not work.  I put a probe on the line from the radio button to the indicator and it never executes.

 

So I put a timeout value of 10 milliseconds on the event structure and then it works.  

 

What I find puzzling is why this is required and why the inner loop was the cause of the problem.  I always thought of an event handler as a software equivalent of a hardware interrupt and the idea that a software loop could prevent interrupts from firing as bizzare. Also why is a timeout value on the event stucture required for the contents of the loop to execute at all since my "code" for the timeout case does nothing.

 

I have some more comments which I will right in a follow-up response when I have a moment.

 

But, again, thanks for your assistance.

 

 

0 Kudos
Message 10 of 27
(4,189 Views)