12-26-2019 07:45 PM
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.
Thanks,
Gu
12-26-2019 09:46 PM
Writing to a local variable doesn't trigger a Value Change event.
To do that, write to the Value (Signaling) property.
12-26-2019 10:52 PM
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,
12-27-2019 01:41 AM - edited 12-27-2019 01:55 AM
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. 😉
12-27-2019 10:30 AM
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