From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

schedule a vi to run on a particular day of the week

How exactly would you go about scheduling a vi to run on a particular day of the week?  Say for instance I want a vi to run every Sunday morning at 11:00am, when the system is not being used.  I know how to extract the day of the week from the Get Date/Time in Seconds.  I just can't figure out how to use the day (Sunday) to trigger the vi, so that the vi will again start at his same time next Sunday.  What I really can't figure out I suppose is how to advance the target date by one week after each iteration.  In other words, I can get the vi to start at 11:00 am this Sunday (October 22, 2006), but after it's done, I want it to start again on the following Sunday at 11:00am.
0 Kudos
Message 1 of 12
(3,982 Views)
I would just use the windows scheduler and not worry about modifying the LabVIEW program. That way, the VI doesn't have to be constantly running and checking the date and time.
0 Kudos
Message 2 of 12
(3,980 Views)

Duh...ok, how do I get Windows Scheduler to run a particlar LabVIEW vi?  I'm sure I'm overlooking the obvious, but have pity on my poor tired brain.

 

0 Kudos
Message 3 of 12
(3,977 Views)
In XP, it's Start>Programs>Accessories>System Tools>Scehduled Tasks. click on it to start the wizard. At one point, you are given a list of programs. I generally build an executable and it's show here but you should be able to use the browse button to select a VI. The VI you want to run should be set to run when opened so that it will automatically start. If there is data that needs to be provided or controls to be set, you might want to use the command line functions and put this in a .bat file.
0 Kudos
Message 4 of 12
(3,969 Views)
start, settings, control panel - Scheduled Tasks.
0 Kudos
Message 5 of 12
(3,965 Views)

OK, I have the vi running just the way I want.  Not only do I want it to execute once a week, but I want it to constantly display how many hours remain until the next execution (so I want it to run 24/7).  Part of the functionality requires that I have a target date/time, so that I know how much time is remaining until it executes.  What I need to do is figure out how, after it executes this Sunday, to rest the target date/time, advancing it by 1 week (7 days or 168 hours or 1080 minutes or 604,800 seconds).  I need to find out how to advance the Target Date/Time block.

0 Kudos
Message 6 of 12
(3,952 Views)

You can place an elapse time express VI in the while loop and specify the duration (eg 604800 sec) and also set it to auto reset. Wire the "Time has Elasped" output of this express VI  to a case stucture. Implement  your code in the true case and calculate the remaining time in the false case.

Tunde.  

0 Kudos
Message 7 of 12
(3,909 Views)

You probably solved this issue already, but here is a solution for anyone interested. The VI runs once every day at the same time. You would need to modify it to increase a week instead of a day to the target time. 

 

Cheers,

 

David

0 Kudos
Message 8 of 12
(2,546 Views)

Have you tried running your VI?  I doubt it works very well.

 

First, you have no wait statement in there so that thing is going to burn up your CPU doing nothing but checking the time.  A small wait in there would reduce your CPU % tremendously.  Your VI doesn't run "every day at the same time".  It runs every day all day long.

 

But the big problem is you are subtracting two floating point values (the timestamps) and comparing them to zero.  Actually you are rounding to nearest, so you may get lucky, but in general comparing floating point numbers for equality may never match even though you think they do.  Or if you do wind up with a small delay in your VI because Windows decided to get busy doing something else, you might accidentally skip over the point in time where the difference is zero.

 

Why not see if the time is greater than or equal to zero?  (Or maybe less than equal to, depending on the signs of the logic.)

0 Kudos
Message 9 of 12
(2,535 Views)

The VI it's been running for 5 days now with no problems. I agree, a small delay would reduce the CPU % and I should probably add it, but if you want to check the time using labview then there's no other way around it. The VI has to run continuously checking the current time so you can compare it. Only other way to do it is using the Task Scheduler but I want to only have labview running and not rely on another app. 

 

At the moment, the VI has a window of 0.5secs to react to the triggering signal. If you increase this range too much and you only want to run your program once, it might run a few times within this window depending on how much you need to process. I am comparing a rounded decimal = integer to zero. No problems with that. 

0 Kudos
Message 10 of 12
(2,512 Views)