05-07-2009 04:01 PM
I'm getting odd results from the output of a very simple subVI - the final state of a boolean output is different depending on if it is hooked up to the "connector" of the VI or not. Not sure if it's an idiosyncracy of Labview, something I did wrong, or what.
The background - I have a DAQ rig I'm building that has a footpedal to turn an inflation valve on or off. Basically when the user pushes the pedal, it will toggle the valve to the opposite state. (My real program is more robust than these VI's, the pedal changes the state-machine state, and that state is what controls the valve.) I have the DAQ running at high speed, and only need to poll the footpedal (a digital input) occasionally. I put the logic in a subVI, which handles the logic of toggling by remembering if the pedal has been released since the last call.
Should all be very simple. However I ported the program over to a new laptop and some new NI hardware - and now my subVI doesn't work. It toggles once, just briefly, but then on the very next call to the subVI, the boolean output resets to false. So the value that gets passed back to the main VI is wrong. After much wrangling I wrote two simple VI's just to see what was wrong with my logic (files attached) Now, even If I single-step through the subVI, it works great up until it leaves the subVI - then it sets the output back to false.
In my subVI, I created two toggled outputs - LED's - which indicate the state. One works correctly, one does not. The ONLY difference between to two is that one is hooked to the connector pane, and one is not. There is also a third LED with my workaround - setting the indicator to a value as the very last step of the VI.
I think I've ruled out race conditions and logic errors. Dunno if I did something dumb, or not best-practices, or what - If anyone can figure out *why* they behave differently, that would be great!
05-07-2009 04:18 PM