08-17-2009 04:06 AM - edited 08-17-2009 04:10 AM
Hello,
I have a vi which uses three initial switches to select an input. The switches activate once pressed and then stay pressed even when the vi is stopped. Also, I have a stop button wired into local variables so I cannot set as a latch as I would want to. If I set the initial three switches as latches then it is difficult for the user to see that a button has been pressed.
So the problem I have is that when I stop the vi with the stop button, this button stays pressed. I cannot set the stop button as a latch because it is not allowed in Labview with local variables. The next person who comes along will not see that the stop button is pressed and start the program only to find that the stop button is pressed and some sort of loop will happen.
Is there a way of when starting the vi that teh select buttons and stop button will default to the initial positions.
Nevica
08-17-2009 05:19 AM
You need to create a value property node for each variable and set a value of false. You can, then, use the error out of the property nodes and wire them to the while loop. This will ensure that the property nodes execute before the while loop.
You should start having a look at the State Machine Design Pattern (File -> New.. and look in Design Patterns).
08-17-2009 05:48 AM
Hi Adnan,
Thanks for your reply. Could you please be more specific. Where can I find 'State Machine Design Patterns'. I presume they must be in Labview examples but I cannot find them?
Nevica
08-17-2009 05:54 AM - edited 08-17-2009 05:55 AM
Did you feel this is specific?
08-17-2009 06:07 AM - edited 08-17-2009 06:08 AM
08-17-2009 06:16 AM
08-17-2009 06:28 AM
Hello,
Thanks for your suggestions. I have decided to stop the vi with the vi stop button on the top bar instead of creating my own stop button.
I am still left with two problems.
1. How do I reset the initial selection buttons outside of the case structure every time the vi runs.
2. How can I output the data on just one graph no matter which gauge I select. Having three graphs is overkill. I cannot put the waveform chart and digital indicator outside of the case structure because the looping happens inside of the case structure. I have thought of using local variables as in the example of the second case structure in my attached vi but this does not work.
How can I get around these problems?
Nevica
08-17-2009 07:14 AM
Jorn, You shouldn't initialize the stop button AFTER the program ends since you have not accounted for the case when the VI stops abruptly. Always initialize your variables at the start of your application.
nevica wrote:
I have decided to stop the vi with the vi stop button on the top bar instead of creating my own stop button.
DON'T DO THIS. Using the Abort Execution button when stopping a VI is like using a tree to stop your car. You need to stop the VI gracefully in the application itself.
Have a look at the attached application for an example of how to initialize your boolean buttons at the start of the application. I have implemented it using a State Machine. Since I am in a hurry, I did not account for error checks.
08-17-2009 07:32 AM
Hello Adnan,
Unfortunately I am running Laview 7.0 so cannot open test.vi. Please could you do a screen shot or save in 7.0 please.
Thanks,
Nevica
08-17-2009 07:33 AM
Adnan Z wrote:Jorn, You shouldn't initialize the stop button AFTER the program ends since you have not accounted for the case when the VI stops abruptly. Always initialize your variables at the start of your application.
..
You are right. My intention was to provide a quick solution.