11-21-2011 02:05 PM
Hello,
I am just starting labview 2010 so this question might be very simple. However I couldn't find any answer by searching an introduction book, this or other forums.
The task is very simple: I want a bool which I can initiate before I start the program AND which I can change when it is running. The latter itself appears to be not straight foward itself, as it is not the "classical stop-the-loop scenario".
I came up with two versions (see attachment):
1) With the bool outside (lower part in vi), I can press the button before the program is executed, and the program does what I want, except I cant set it during excecution (as expected). And for some reason the button does not appear pressed down, although both LED and progamm indicates it's doing the right thing.
2) With the bool inside, it is reset to FALSE every loop for some reason.
Any suggestions or links to existing answers would be highly appreciated!
Thanks,
Armin
11-21-2011 02:17 PM
You can use a local variable to set the boolean control value inside your code.
11-21-2011 02:19 PM
Note that some of those booleans are latch action, which is why they pop back up after they are read. With latch action booleans, local variables aren't going to work.
11-21-2011 06:29 PM
Thanks. I wasn't aware of the different boolean options. A combination of changing the type, adding a local variable (Thanks to Mark) and using an 'if' function, finally works. I am just curious why it appears so complicated for such an easy task...
11-21-2011 07:16 PM
@Al2 wrote:
The task is very simple: I want a bool which I can initiate before I start the program AND which I can change when it is running. The latter itself appears to be not straight foward itself, as it is not the "classical stop-the-loop scenario".
Any suggestions or links to existing answers would be highly appreciated!
You are approaching this the wrong way. There should never be anything that needs to be set before the program runs. Edit mode should not be part of operating the VI!. If you need to change it before the loop runs, use a state machine architecture where, after pressing a run button on your front panel , the program first starts out in an idle state, after which you can proceed to the loop state.
Press the run arrow before any user interaction. Only stop the program once you are completely done. Once your program is finalized and built into a standalone application, it will reun when opened and edit mode is not useful anyway.
11-21-2011 08:15 PM
im thinking of making two VI's. One where you set the values and the other one that loads those values and runs for iteslf
11-21-2011 08:25 PM
@Motanum wrote:
im thinking of making two VI's. One where you set the values and the other one that loads those values and runs for iteslf
Why would you want to double the complexity for such a simple problem???
11-21-2011 08:27 PM
Because I am not very proficient with LabView and I just shouted a solution which I thought of. Plus, I dont think doing two VIs is that complex. Just take all data in an array and then extract it on the other VI
11-22-2011 10:38 AM
-------------------------------------------------------
You are approaching this the wrong way. There should never be anything that needs to be set before the program runs. Edit mode should not be part of operating the VI!. If you need to change it before the loop runs, use a state machine architecture where, after pressing a run button on your front panel , the program first starts out in an idle state, after which you can proceed to the loop state.
Press the run arrow before any user interaction. Only stop the program once you are completely done. Once your program is finalized and built into a standalone application, it will reun when opened and edit mode is not useful anyway.
-------------------------------------------------------
That seems to be a good point. I'm working with a lot of vi's that are quite complex and made by other people. This whole presetting thing in a non-started vi was always suspicious to me, i.e. nobody used a state machine. I will try it. Thanks