LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I program an e-stop into a state machine?

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.

0 Kudos
Message 1 of 14
(3,699 Views)

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.

0 Kudos
Message 2 of 14
(3,629 Views)

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.

0 Kudos
Message 3 of 14
(3,625 Views)

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.

0 Kudos
Message 4 of 14
(3,619 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 14
(3,613 Views)

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.

0 Kudos
Message 6 of 14
(3,602 Views)

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.

0 Kudos
Message 7 of 14
(3,593 Views)

@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.

0 Kudos
Message 8 of 14
(3,588 Views)

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.

0 Kudos
Message 9 of 14
(3,582 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 14
(3,553 Views)