LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Relay sequencer

Solved!
Go to solution
Highlighted
I have this sequencer that will allow the user to cut on and off a relay(s) after so many seconds of delay. The trouble is that my pause button isn't being read often enough. How would be the best way to read the pause button during seq 1 or seq 2? Also, it would be nice if I could get it to start back up in the same seq that it was in when the pause was pushed and even have the remaining time of the cycle,  not the whole cycle to complete.
0 Kudos
Message 1 of 5
(1,124 Views)
Highlighted

How fast is not fast enough?

 

Overall, it looks like you've built the statemachine so it executes in the timeout case about every 50 msec.  However, if you are in Sequence 1 or Sequence 2, you have an internal while loop in those cases where each iteration will take X seconds depending the values in time 1 or time 2.

 

Your i=0 condition is kind of odd also.  The first iteration of the loop will always be i=0 and thus the loop will stop after that iteration and it will continue to the next the next sequence once the X seconds have passed.

 

I'm not sure exactly how you want to sequence things, but I would recommend you use some elapsed time functions that determine when the X seconds have passed and execute the relay change accordingly.  Get rid of the inner while loops (which only run once) and the wait timers.  Now the outer while loop will continue to be your master state machine and the pacing of the loop will be controlled by the timeout timer on the event structure.

0 Kudos
Message 2 of 5
(1,109 Views)
Highlighted
Ok, I took out the i=0. It wasn't doing anything. I am trying to add the elapsed time function but not having the best of luck. I can pause now because I took out the while loops. What am I doing wrong on the elapsed time?
0 Kudos
Message 3 of 5
(1,090 Views)
Highlighted

Your current time is being fed into the shift register on every iteration and becoming the new start time for the next iteration.  If you change states, then feed your current time into the shift register for the new start time.  Otherwise feed the existing start time into the shift register.

Another tip, in sequence 2, don't write any data to the property node for Exit.  It makes the button look pressed in.  If anything, you would want the value signalling property so that it signals the Exit Value change event to run.  And then only write to the property node if it is True.
 One other option is to make the Exit a state of the state machine.  And if the Exit Value change event occurs, it does nothing but set the next state to be Exit.  Then when the timeout occurs, the Exit state of the state machine will run.
Message Edited by Ravens Fan on 05-12-2009 04:01 PM
0 Kudos
Message 4 of 5
(1,085 Views)
Highlighted
Solution
Accepted by topic author bassinbc

I am adding the finished vi here in case anyone would benifit from it.

Thanks Ravens Fan, I took your tips and incorporated them into the program and added a feature that allows the user to enter zero in the number of cycles and it will cycle continuously.

0 Kudos
Message 5 of 5
(1,055 Views)