06-06-2024 03:48 AM
Hi Gerd,
If I dont have the Elapsed Time VI in a case structure, it will just be counting up to infinity, and the 'TimeElapsed?' will be true at all times
06-06-2024 03:51 AM
Hi lorc,
@lorc34 wrote:
If I dont have the Elapsed Time VI in a case structure, it will just be counting up to infinity, and the 'TimeElapsed?' will be true at all times
Did you read the help for ElapsedTime?
It offers a Reset input…
06-06-2024 03:58 AM
Hi Gerd,
Yes I know about the reset function. But lets say when the level is exceeded, I reset the elapsed timer, it will start counting from zero. Once it hits 4 seconds it will equal true. However, prior to resetting it, it was already equal to true, because its just going off to infinity.
06-06-2024 04:13 AM
Hi lorc,
@lorc34 wrote:
But lets say when the level is exceeded, I reset the elapsed timer, it will start counting from zero. Once it hits 4 seconds it will equal true. However, prior to resetting it, it was already equal to true, because its just going off to infinity.
I don't understand your problem.
What's wrong with this behaviour?
06-06-2024 06:38 AM - edited 06-06-2024 06:40 AM
Hi Gerd,
I just cant figure out how to implement the VI the way I want using no case structure even with your latest message/advice
This should probably not be very hard. If it was a textual programming language it would only be a fine lines of code:
timer_started = False
start_time = None
turnGreenLightOn()
while True:
if level_exceeded() and not timer_started:
turnRedLightOn()
turnGreenLightOff()
start_time = time.time()
timer_started = True
if not level_exceeded() and (time.time() - start_time >= 30
turnRedLightOff()
turnGreenLightOn()
timer_started = False
If the level does not exceed, the green light will be on.
If the levels DOES exceed, the red light will stay on even if the level becomes low again. It will ONLY turn back to green, once the 30 seconds has passed. (or if we push a button, but lets ignore that for now..)
If the level stays at an exceeding level, the red light will always stay on no matter what the timer does.
06-06-2024 06:56 AM
I have the behaviour I exactly need working in this VI, with the only problem being, the ElapsedTime VI runs even when its case structure is not active. Its in the True case, and even when that case structure is wired False, it still runs in the background. If it did not run in the background, it would work exactly as I need
06-06-2024 08:36 AM - edited 06-06-2024 08:40 AM
Okay I have it working now based on what you said Gerd using the Elapsed time VI without a case structure. It uses a NAND gate with a true constant so that when the level exceeded is true, the reset is set to false and it records, and then the elapsed time goes to a shift register which resets the NAND input to false.
Thank you for your help
EDIT: actually a NAND gate with a true constant on one input is just a NOT function 🙄