LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exiting a while loop if a variable value does not change for some time

I am trying to find a way to exit a while loop when the value in a variable does not change for a certain time. Basically, I am looking at the current volume and target volume in a syringe. If the current volume is greater than the target volume in the syringe by a certain value x, the loop will continue. Unfortunately, the sensor on the syringe does not work consistently and sometimes stops at a reading greater than 'x' and stays there. I tried using a shift register to compare the current volume values and ending the while loop if the current volume has not changed and the target volume criterion has been met. But, sometimes, the loop ends after the first iteration since the current volume value does not update after the first iteration. I am trying to figure out a way where the loop will stop if the current volume value does not change for a set period of time.

 

Any help is greatly appreciated!

0 Kudos
Message 1 of 9
(1,284 Views)

What about adding some logic to ignore the comparison on the first iteration, on top of what you have done?

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 9
(1,268 Views)

It might not be for one iteration that the value remains the same. Ideally, I want to do the check after the current and target volume criteria are met. I tried using a feed back node with the delay set to 10 iterations, but it did not seem to work.

0 Kudos
Message 3 of 9
(1,261 Views)

Using the shift register to compare values is the way to go.

You need to figure out when to start comparing the values.

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 4 of 9
(1,247 Views)

Oh I see. I am trying to figure out how to start that particular condition check after the loop has run for some time.

0 Kudos
Message 5 of 9
(1,219 Views)

Add a counter. If it's the same as before, add 1. If counter is > limit, stop.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 9
(1,185 Views)

If you don't mind PtByPt and\or express VIs (I do, both):

Change With Timeout.png

0 Kudos
Message 7 of 9
(1,177 Views)

Typically we can provide much more specific advice once you attach your VI.

 

LabVIEW does not really have "variables", so I think you are talking about the value in a wire. What is the datatype? (i.e. what are the possible digital quantization steps). The term "does not change" is a very dangerous requirement for floating point values, a better definition would be that it "stays within a certain narrow range". How often is the value read? How much noise does it have?

 

If the signal is well behaved, you could feed your value into a ptbypt linear fit with the history length adjusted according to the sample rate and desired stability time, then do a simple ["value > target" AND "slope approximately zero"] to decide what's next. 😄

0 Kudos
Message 8 of 9
(1,148 Views)

I tried this set up and it seems to work as of now. Thank you all for your inputs!

Message 9 of 9
(1,129 Views)