10-17-2016 09:46 PM
I have a SubVI with a Elapsed timer which checks input condition for 5 seconds and updates Indicator accordingly. It works fine as a standalone VI. But when I make it a Sub VI, the timer doesn't run and doesn't reset. Instead the timer keeps increasing .. I can't figure out what I am doing wrong. Need some help please
10-17-2016 11:11 PM
Your subVI has a while loop. That subVI will keep running until the while loop stops. It will either happen immediately if the pitch and rol values you send in when the VI starts are false, then the while loop won't run. Or if the pitch and roll values cause the while loop to run, then it won't stop until the elapsed time has passed. Only then will the subVI stop and it will go back to the main VI.
Next iteration of the main VI, the while loop (if it runs) will not reset the Elapsed time timer because you have a false value on the initializer of the shift register. It will keep couning from where it left off.
Do you really want a subVI in that while loop?
Have you used the debugging tools like highlight execution so that you understand how LabVIEW works and the data flows?
10-17-2016 11:25 PM
Hi Raven,
Hey I was just looking at it now with highlight execution and realized the false initialization everytime.
I actually want it in a While loop for monitoring it continuously. And the while loop inside for checking fall condition for 5 seconds. Is there a way to fix this?
10-17-2016 11:31 PM
What determines if it is a fall condition? The values changing in roll and pitch?
Those values don't change until the subVI ends because those values come from the main VI.
I suggest getting rid of the subVI and putting your code in the main VI.
10-17-2016 11:42 PM
Roll and Pitch values actually change and I checked it. Please have a look, since the while loop in subvi stops in both conditions
But the problem I have now is the elapsed time
10-17-2016 11:56 PM
Putting it in the main VI doesn't make a difference
10-18-2016 01:42 AM
Why don't you also attach the code with everything in the main VI so we can understand what you define as "working correctly".
10-18-2016 02:23 AM
Yeah sure..
10-19-2016 02:10 AM
I haven't checked about the sense of the whole code. However, the "not resetting" issue is expected behavior. In fact, LV only does what you tell it to do with your code.
Point is, that you initialize the reset shift register with FALSE each time you call the subvi.
When the time elapsed, the value in the shift register is true. However, as you use that value as loop termination as well, the subvi stops without calling elapsed time with the reset TRUE.
In the next call, reset is FALSE because of your initialization.
Norbert