From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to run two event cases consecutively with one click

Hi Friends,

 

I am trying to run two event cases consecutively with only one click. I am not sure if it is possible. 

 

There are three cases, add, substract, add & substract, the third one is what I am talking about. I would like to click just ADD, then it can also run substract. A true value is assigned to substract in the Add & substract case.  attached is the VI.

 

Add&Sub.png

 

Thanks,

Gu

0 Kudos
Message 1 of 5
(3,640 Views)

Writing to a local variable doesn't trigger a Value Change event.

To do that, write to the Value (Signaling) property.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 2 of 5
(3,571 Views)

Hi Paul, Thanks.

 

Did you mean the way as shown below? It can pass new value, true,  to Substract, but does not trigger the event. 

 

The Vi in my original post is an example for troubleshooting, my real VI is for a linear stage control, add represents forward move, substract represents backward move, and the add & subtract represent a combination in one click for a forward followed by a backward move. 

 

Off cause, the forward and backward move can be done using a case with two instructions, ADD followed by SUBSTRACT, however, the bottom loop, which is for monitoring the stage position, does not run until doing the SUBSTRACT, meaning the bottom monitoring loop ignores the ADD.

This is the reason why I am looking for an answer to my post.

 

Regards, 

Add&Sub2.png

0 Kudos
Message 3 of 5
(3,555 Views)

It seems you posted the same code once more.

 

My guess is that you are a beginner because your Code is extremely flawed and will not work as expected. For example, immediately after entering the while loop, the x and y controls will be read and the value pushed into the tunnel going to the event structure. Changing any of the controls before triggering an event will not operate on the new values, they'll get read only at the next iteration again.

 

None of the code "smells right". It would help if you could add a better simulation of your stage so we get a better ideas what you actually want. There is most likely a much cleaner solution for all that. (Think "state machine", for example).

 

Basically, tell us what you need to do, now how you want to do it. 😉

0 Kudos
Message 4 of 5
(3,515 Views)

Good Morning, Altenbach,

 

Thanks for your suggestion, I am going to try state machine. Actually, I already downloaded a few state machine sample codes from NI web yesterday evening. 

 

Regards,

Gu

0 Kudos
Message 5 of 5
(3,417 Views)