LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

case structure not working

Hi

 

I am trying to build a VI in which the position of a sliding bar can be moven along Y axis in two way. Once using a dial control and another using up down keys. I am using a toggle switch to control the case structure. But it works for once. After that even though i change the switch position it does not change the value. 

 

Can somoen please check and let me know why the case structure is not working propoerly?

 

Regards

Farooqui

0 Kudos
Message 1 of 3
(2,405 Views)

Hello alfarooqui,

 

The Event structure you are using will block execution until at least one of its cases has been satisfied.  It looks like you've also removed the Timeout case and not wired a timeout value, so the structure will wait indefinitely for a Key Down event.

 

In general, it's not a good idea to place even structures within other structures where they'll block execution- by nature they're asynchronous.  I'd suggest taking a look at the Producer-Consumer With Events architecture.


You should also consider using a wait function for Execution Timing Control in your primary loop, as it is it is "greedy" and will execute as many times as it can as fast as possible, regardless of what the user is doing.

 

Regards,

Tom L.
Message 2 of 3
(2,399 Views)

alfarooqui wrote:

I am trying to build a VI in which the position of a sliding bar can be moven along Y axis in two way. Once using a dial control and another using up down keys. I am using a toggle switch to control the case structure. But it works for once. After that even though i change the switch position it does not change the value. 


your VI name "Final.vi" is definitely not final. 😄

 

You should make yourself familiar with dataflow and also with simple debugging techniques such as execution highlighting.

 

Besides the inside-out arrangement of the event structure, there are many more things wrong. For example if the boolean is false, the VI will run as fast as the CPU allows and any key operation will queue up events without ever being able to execute them. Also your math code is way too complicated. Use a FOR loop for the successive subtractions. Use the correct datatypes for controls, etc.

Message 3 of 3
(2,377 Views)