How to add a time delay to a measurement without sleep()

Viewed 15

I have a program that constantly measures values of another device and gets them through a simple test. After the first measurement is taken, there needs to be a time delay, after which the second measurement is taken, to look if the two measurements are the same or if there is too big of a difference, rendering the tested device as faulty. In this case there is one self build device that pumps gas into test devices to measure the pressure in mbar, looking for leakages. After applying the pressure through a valve, the first measurement is taken, then there needs to be a delay of 15 seconds, where the pressure gets hold, whereafter the second measurement is taken. There are multiple valves, so the testing program is a statemachine, while the valves need to operate with a delay, so the tester can also observe what is going on, instead of all valves testing at the same time. There is as much a state to wait 15 seconds, which works perfectly fine, but waiting 15 seconds as a step inside another state doesnt work, which is what I need.

My problem is, that this time delay doesnt work as I intend it. I tried it with time.sleep(), but that also stops the measurement for the time it sleeps, which concludes in the second measurement being the same as the first, because between the two no other measurement was taken, because the program was too fast for the measuring device to produce a new measurement.

Is there a way to achieve a time delay without stopping the entire process?

0 Answers
Related