08-18-2015 06:17 AM
I'm probably overthinking this one...I have a State Machine that will be running on a CRIO9030. I have an Input that will read from an E-Stop Switch. I want to program it so that no-matter what case is active, if the E-Stop is hit, it goes to an E-Stop Case in my Case Structure. I can get it to stop at the end of each Case Loop...but need it to process as soon as it is processed, not at the end of the loop.
08-18-2015 09:06 AM
Well there's lots of ways but the my suggestion will rely on the current implementation of the software.
Having a second loop dedicated to reading that input is a good start. I think you can have it generate an event based on value change in some cases (registering for the event). Then what might be best is to have that loop do the shutdown operations, or commanding another loop that is idle to perform the shutdown operations. It would probably be best to broadcast the shutdown event. A functional global is the easiest, assuming you have it setup to check this global before performing any action, and to not do that action if shutdown is seen.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-18-2015 09:08 AM
1. You'll have to get each of your states in your state machine to process quickly.
2. Get a subVI that reads your e-stop button as soon as a state is finished. If it reads true, then no matter what state the state machine was going to execute next, you tell it to execute the E-stop state next.
How critical for safety is this e-stop? If it is critical, don't rely on software. If it isn't so critical, a case where I need it to stop as quickly as it can, but I can tolerate odd pauses because Windows decides to run a virus scan at that instant, and no one is going to get hurt if it takes a few secodns to happen, then a software solution might be okay.
08-18-2015 09:10 AM
It is critical...I have E-Stop Signals going directly to the main components...the E-Stop signal in the Labview is just to shut-down the case and de-energize the system...basically, anything I can't hardwire a stop too.
08-18-2015 09:11 AM
RavensFan wrote:
How critical for safety is this e-stop? If it is critical, don't rely on software. If it isn't so critical, a case where I need it to stop as quickly as it can, but I can tolerate odd pauses because Windows decides to run a virus scan at that instant, and no one is going to get hurt if it takes a few secodns to happen, then a software solution might be okay.
The OP did state this is running on a cRIO, so I don't think this is much of an issue.
But RavensFan's first point is the most important. You need your states to be somewhat quick. If you have loops inside of your states, you need to reevaluate your state machine.
08-18-2015 09:16 AM
crossrulz wrote:But RavensFan's first point is the most important. You need your states to be somewhat quick. If you have loops inside of your states, you need to reevaluate your state machine.
Or check stopping conditions within that loop of your software is already written, but writing code from the start to have states complete quickly is a better design.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-18-2015 09:20 AM
One of my states takes 5 seconds to run...that is the longest one, all the rest are blink-of-the-eye fast, so no concerns with those, just the 5 second one.
08-18-2015 09:23 AM - edited 08-18-2015 09:23 AM
@ajsdwilson wrote:
One of my states takes 5 seconds to run...that is the longest one, all the rest are blink-of-the-eye fast, so no concerns with those, just the 5 second one.
Well whatever it is doing have it return periodically to check the shutdown status, or have the shutdown status have a way to abort the thing it is doing. Close references, kill tasks (safely) or whatever it is doing that takes so long. If it is a DAQ task try to return subsets of your data instead of all the data at once. Like maybe return 0.1ms of data 500 times, instead of returning 5s of data once. I suspect you can also clear and stop the task reference being used and it would probably stop, but would need to test it to make sure.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-18-2015 09:26 AM
Sorry, should have explained this part...it is a machine that has a robot in it...so one cycle of all it's tasks takes 5 seconds...I'll look at putting E-Stop Checks between each function.
08-18-2015 09:30 AM
@ajsdwilson wrote:
...so one cycle of all it's tasks takes 5 seconds...
I would think about making each of those tasks a single state so that you can check the e-stop more often.