LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Closing the relay when STOP is pressed

I have a program that opens a relay to heat an element, read the temperature with thermocouple, starts to pulse then closes the relay to cut the power from the heating element. My problem is when the program is stopped by the STOP button the program stops but the relay stays on. How can I wire the stop butto that is in the while loop to the last state that closes the relay?
0 Kudos
Message 1 of 10
(3,835 Views)
It depends on your architecture. If you have a state machine, add the code to the stop state. Same is true if you're using an event structure. If you've got neither, just put the code inside a case statement and wire the stop button to the case selector, though the case, and to the while loop terminator.
0 Kudos
Message 2 of 10
(3,835 Views)
Will you take a look at my code? Also, I seem to have a 5 second delay from the time the relay turns on and the thermocouple takes a reading. Will you look at that and see if anything stands out that would cause that?

Thanks! 😉
0 Kudos
Message 3 of 10
(3,835 Views)
Can you save it as 7.0? I don't have 7.1 yet.
0 Kudos
Message 4 of 10
(3,835 Views)
You need to change your code so that case number 5 will run when you hit the stop button. Right now, when you hit the Stop button, no more cases are executed. The loop just stops.

The easiest way to Close the relay would be to duplicate the code in case 5 out to the right of the loop and connect the error wire to it so it only executes after the loop stops.

As it sits right now, the stop button will most likely be read before each case statment is executed, but there is no way of being sure on this point since there is no data dependency between when the stop button is read and the case structure being executed.

As for the delay you are seeing, it could be the DAQmx Create Channel. Try building the channel in MAX and just using a DA
Q Name constant to the DAQmx Read.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 5 of 10
(3,835 Views)
I found the problem with the time delay. I removed the Wait Until Done vi and it seems to be running fine. I just need help with wiring my stop button to the state #5.

Thanks
0 Kudos
Message 6 of 10
(3,835 Views)
Try this.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 7 of 10
(3,835 Views)
Thanks for your help. I loaded your modified version of the software and When I press the stop button on the front panel nothing happens (mechanical action: latch when pressed) when I press the stop on the menu bar the program stops but the relay light it still on (open). Same as before.

Sherry
0 Kudos
Message 8 of 10
(3,835 Views)
The button on the tool bar is not a Stop button, it's an Abort button. What it does is stops the program right where it is without letting any additional code execute. It is not tied to the Stop button youplace on the front panel. This is really just a troubleshooting/development tool and should not be used during normal operation of your applicaiton.

The problem looks to be in frame 1 in the While loop. While this loop is running, your stop button cannot be read because it's outside of this loop. You need to figure out a way to stop this loop when you hit the stop button.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 9 of 10
(3,835 Views)
Thanks for your help.

😉
0 Kudos
Message 10 of 10
(3,835 Views)