07-11-2017 06:15 PM
I do not want to have to use the abort execution button, as I hear that is not the correct way of closing out your .vi
I would like to program a simple STOP button that when pressed, aborts the VI but also safely resets the hardware (for example, turns off a power supply, resets a drift oven, etc) when it is pressed. Otherwise, it just continues running the program until it is finished.
I know this is a relatively simple problem but I have not been able to figure out a simple way to do it.
I believe Event Structures are my friend here, but I am a bit unsure how to do this.
Could anyone walk me through?
Thank you !
Solved! Go to Solution.
07-11-2017 09:55 PM
Post your VI so we know what your architecture looks like. That will dictate how to handle a stop button.
Personally, I avoid using a stop button and instead use the Front Panel:Close? event (the filter event version since I discard the actual closing and later close the panel myself when I am done). But, again, how you handle this depends on your architecture.
07-13-2017 01:30 PM
Attached is my .vi. Warning, I was a bit hesitant to upload as it is a bit messy.
07-13-2017 02:20 PM
I cannot see the subVIs as they were not included.
As of now your program runs a specified number of loops and then stops.
If you want to keep this architecture, \emph{if}, then your options are
Hints: Look at state machines. If possible download the JKI State machine form VI package manager and learn to use it. Your program can probably be rewritten in one loop.
cheers,
mcduff
07-13-2017 02:26 PM
My apologies, attached is the .vi with sub-VI as well.
Also, do you have a link to this state machine you are referring to that I can use as a basis?
Thank you.
07-13-2017 02:31 PM
What version of LabVIEW do you have?
Recent versions have come with VI Package Manager, open that program and you can find links to the JKI State machine. It will install it correctly if you use VI Package Manger. Otherwise you will have to do a manual install from https://github.com/JKISoftware/JKI-State-Machine
mcduff
07-13-2017 02:32 PM
I am using LabVIEW 2009.
07-13-2017 02:37 PM
Bits and pieces of the new subVIs were missing. I suggest you look at the tutorials and examples for inspiration.
Another piece of advice, it looks like you are constantly initializing and closing VISA resources. Initialize them once before the loop, keep them open while in the loop, and close when the loop is finished.
VI Package Manger is here https://vipm.jki.net/
Not sure if it works with LabVIEW 2009.
Look at the state machine examples that ship with LabVIEW.
mcduff
07-13-2017 02:38 PM
I had a look at your VI. The main thing you need to fix if you want to be able to stop at any time is that you are using the Time Delay ExpressVI in between your temperature reads. Your code will be stuck there waiting and nothing else will execute until the 5 seconds (or however much) is up, and this means that you won't be able to stop at any time since the code will not read your stop button until it is done with the delay. What you need to do instead is use an architecture where you check what time it is or whether stop button is pressed - if the time is up, go to the next thing - if stop button is pressed, stop- otherwise, go back and check again.
Try implementing a state machine architecture. Here, I made an example for you of how you could start changing your VI into a state machine. It is just a basic outline. See if you can understand it, and let me know if you have questions, and then try putting your code in.
07-13-2017 02:42 PM
I see. I will give this a shot, and post questions if they come up
Thank you for your replies!