06-11-2018 08:09 PM
Hi,
I'm making a VI used for data acquisition and it needs to be able to send out digital output signals to certain valves in a timed sequence, as well as send signals from manually pressing switches. I set up a state machine to accomplish this and it works for the most part, but it also needs to have an abort state that the state machine immediately goes to upon pressing the abort button. The problem is, I'm not sure how to interrupt the sequence (especially during any of the wait x milliseconds frames) and immediately proceed to the abort state without having to wait for either the current state to end or for the sequence to end. Any help on how to do so is appreciated.
I have attached a model VI of the situation as well the relevant portion of the full VI I'm making.
Solved! Go to Solution.
06-12-2018 01:33 AM
Hi joey,
I set up a state machine to accomplish this and it works for the most part,
Please make that enum a type definition! (For clusters and enums you should immediatly start with typedefinitions!)
Right now you already use different kinds of enums as can be seen by those coercion dots!
And you surely don't need all those local variables…
but it also needs to have an abort state
You already created such a state, that's fine.
that the state machine immediately goes to upon pressing the abort button. The problem is, I'm not sure how to interrupt the sequence (especially during any of the wait x milliseconds frames) and immediately proceed to the abort state without having to wait for either the current state to end or for the sequence to end.
There is NO way to "break" a wait function. NO WAY!
Possible solutions:
- Don't use wait functions with high wait times. You may use a dedicated "wait state" with a small delay of 10ms to be able to react "immediately" on your "Abort" button…
- Use a different approach than a (simple) state machine. A QMH (queued message handler) might be suited better here…
06-12-2018 01:35 AM
Hi Joey
A simple way to achieve this is to have a for loop inside each case that currently has a delay. Replace the delay with the loop monitoring your abort button on a much smaller timeout. Not sure how quickly you need to abort but I've chosen 10ms.
See attached VI.
06-12-2018 02:03 AM
I'm relatively inexperienced with LabVIEW, could you explain the reason for making the enum(s) a type definition?
Yes there were a lot of local variables but I just quickly threw that model VI together to get the job done I guess.
I'll look into possibly making a QMH
06-12-2018 02:04 AM
Thank you! I'll try that out when I get the chance.
06-12-2018
02:19 AM
- last edited on
06-09-2025
04:16 PM
by
Content Cleaner
I'm relatively inexperienced with LabVIEW, could you explain the reason for making the enum(s) a type definition?
Basically all changes to all instances of the type-def are synced. ![]()
06-12-2018 02:23 AM
Hi Joey,
could you explain the reason for making the enum(s) a type definition?
With a typedefinition you only need to change the definition (like adding a new state/item to your enum) and all instances of this typedefinition automatically adapt to the changes!
Just count how many enum constants you use in your simple VI: when adding new items you would need to change them all - or just one typedefinition…
06-12-2018 09:34 AM - edited 06-12-2018 09:40 AM
If you have a need for a long "wait state with abort" do something like this:
My "Stop" button will abort the timer. (after 10mS)
Also notice the time I leave the loop becomes my acquisition time stamp. Using a shift register is fed to my acquisition state then fed back to the timer state to make up for acquisition time, keeping the acquisition intervales exact.