Solution
This is possible, using a combination of LabVIEW's built-in time functions and a
Shift Register in a
While Loop.
- Calculate the time period you want the code to run for, in seconds.
- Add this time period to the initial time as grabbed from Get Date/Time in Seconds.
- Initialize a Shift Register [right click on the edge of your While Loop to Add Shift Register] with the time you want the section to run until (the Goal Time).
- Compare the time from the Shift Register to see if Get Date/Time in Seconds (the Current Time) is past the time the code should run for by using a Greater Than comparator.
- Create a Case Structure around the section of code you want to run for the interval.
- Route the boolean output from this comparator into the selector on your Case Structure
- In the False Case, place the code you want to run for 10 minutes. If the Current Time is not past the Goal Time, the code you want to run for 10 minutes will continue running.
- In the True Case, you can enter a message or leave the case blank. If the Current Time is past the Goal Time, a message will appear that 10 minutes has passed, and the program will stop.
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.