11-21-2019 12:02 PM
Hello,
I've been struggling with an application of a timeout within a case structure in my LabView application. The desired effect is as follows.
A case structure is within a while loop that is constantly checking if a pressure from an analog input has been met. If it has not yet been met it loops around and checks again. I'd like to have a timer start the first time this case structure occurs and start accumulating time. After a specific time I'd like the case structure to stop looping back on itself and move on to another case. I'm well aware that there are multiple timing functions within LabView but have not been able to get it to work using any of them. Keep in mind that there are many other sections of the case structure and it will need to go through these structures many times. So it will come back around to this checking for pressure case again and it needs to be reset once more and ready to start when that happens.
The main problems I run into are as follows.
1. If I put a timer within the case structure to time out, it will work but it will not ever respond to my pressure input and won't loop back around until the timer has completed. I understand why this is happening because the while loop wont loop back around until everything is executed. Still don't know how to fix that though.
2. I know I could probably put a 10ms wait in the case structure and count how many times it has looped through to allocate time, but I think this is sloppy as the timing is not very precise and I'm not quite sure how to reset this again.
I even tried writing a C# program and using that to implement a timeout, but no luck.
Any ideas?
Solved! Go to Solution.
11-21-2019 12:07 PM
Hi,
you already use a state machine: why not add one state "start timer" where you store the current time in a shift register. Other states can check the elapsed time by subtracting that stored timestamp from current time. The result of that subtraction can be used to decide which state to call next...
11-21-2019 03:06 PM
Thank you, GerdW!
Wow worked like an absolute charm. I spent so much time trying different things and just never had the thought to do it like that. Thank you so much for the help. VI included with changes for others to learn.
For others take note that the included .ctl file is needed to properly populate the case structure.