ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed VI

Hi,

I am working on an application that requires me to execute a certain task (turn a motor) every 1 hour for 1 minutes.

Though I am getting my code to run correctly, I can only get it to run once for some reasons.

Can someone help me make it a continuous VI until the user decides to stop it, please?

 

I am using dummy variables to check if it works (1hr -> 30 s, 1 min -> 10 s and the motors are replaced by LED)

Thanks

0 Kudos
Message 1 of 5
(2,920 Views)

Hi Joel,

 

build a statemachine with some states:

1. wait for x seconds

2. switch on motor

3. switch off motor

Then it will become easy to fulfill your requirements…

 

I can only get it to run once for some reasons.

- Well, you compare the elapsed time with some set value: the elapsed time is counting up all the time while your value is fixed. There is only one opportunity to have both equal…

- Comparing floating point numbers for equality often gives unexpected results. There are a lot of threads here on this very topic - read them! (Search for "floating point accuracy".)

- Your outer loop is running as fast as it can: that's the reason why that floating point comparison is working so far. But do you really want to burn a CPU core just to wait for some amount of time?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(2,897 Views)

I came across a solution later today.

It does what I want it to do, but I want to make sure that it is a viable and robust enough solution for the application.

Could you look at it? Meanwhile, I will look into statemachines, get familiar with it and come up with something for it.

Thank you for the suggestion.

0 Kudos
Message 3 of 5
(2,868 Views)

It's not a great solution.

 

Suppose you set up for a 1 hour loop iteration.  Then you decide to stop the VI.  It might take up to 2 hours after you hit the stop button, for the VI to actually come to a stop.  Not a robust solution.

 

A state machine can execute much more quickly and can respond to a stop command quickly.

0 Kudos
Message 4 of 5
(2,863 Views)

I see. I will work on coming up with a state machine and post any concern along the process.

Thank you

0 Kudos
Message 5 of 5
(2,847 Views)