LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scheduling daily and weekly events

Hi,

 

I'm fairly new to LabVIEW, but have successfully built/modified a .vi to communicate with an Arduino/motorshield to control a stepper motor.

 

The next step is to be able to have the user schedule daily events on a weekly basis.

 

For example: Move stepper to position x at date/time x.  Move stepper to position y at date/time y.  Repeat daily for z amount of days.

 

I’ve looked into using Windows Task Scheduler to call independent .vi’s for each maneuver but would rather have this functionality built into the .vi/front end.

 

What would be the best way to go about this? 

 

Thank you.

 

-Charlie

 

0 Kudos
Message 1 of 15
(5,344 Views)

Read the LabView help section on Format Codes for the Time Format String for the Format Date and Time vi.

 

You can specify a time format like %A (full day of the week) %W (Week Number 00-55)

 

Check this when you start save it in a variable or shift register and periodically check the time to see if it has changed.

 

The attached image is how I check to see if a week has gone by, if so it closes the current data files and starts new ones.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 15
(5,331 Views)

There is no need to format the timestamp into a string and then compare strings.

 

Use the Seconds to Date/Time function:

 

Seconds_to_Date-Tiime.png

 

This will give you a cluster representing the current time.  You can compare this to the time interval you want things to happen at and then execute code based one that (i.e. if you check to see when the minutes is equal to zero, you can execute code every hour (but make sure you check every 30 seconds or so if you use equals so you don't miss it!)).

Chris
Certified LabVIEW Architect
Certified TestStand Architect
Message 3 of 15
(5,310 Views)

Yeah that's the one I was looking for. I could not find it the last few times I needed it so I went back to my old ways of using Format Date/Time String. This really needs to be named something more descriptive...

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 15
(5,285 Views)

I totally agree!

 

I'd been using LabVIEW for almost 3 years before I realized what this function actually did and how useful it was.  Life without it is harsh....

Chris
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 5 of 15
(5,271 Views)

Subtract two timestamps- you get a double equal to the seconds difference, including subsecond resolution.  LabVIEW is really smart!

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 6 of 15
(5,252 Views)

Thanks for the help so far.

 

I've been successfully able to read in the current time, convert to a string (HH:MM AM/PM) and compare it to a similarly formatted user input string.  I did the string comparison (HH:MM AM/PM) because I need the code to execute daily until the user hits Stop.  Ultimately I'd like to put this into a timer controlled while loop, but first things first.

 

The user can "Set Time 1" and a "Resistance at Time 1" via Time Stamp and Numerical Controls.  When "Set Time 1" equals "Current Time Stamp", I want to execute a loop based on "Resistance at Time 1".  Right now I have an Event Case structure and want to send "Resistance at Time 1" as a Value Change. 

 

What's the best way to go about this?

 

VI is attached.  Please excuse the extra indicators and equations as they are used for troubleshooting/verification.

0 Kudos
Message 7 of 15
(5,210 Views)

Bump.....?

 

Or should I start another thread for this particular inquiry?

0 Kudos
Message 8 of 15
(5,188 Views)

The posts above already explain that you should not compare times as strings. It is easy to do this correctly with numeric comparisons - but do not use the "equals" comparison since the two times will not be equal if they vary even in milliseconds, unless you do some rounding first.

 

You can trigger a value-change event when you reach a certain time by using a Value (Signaling) property node. Usually this would not be my preferred way of doing it, but it is the easiest option in your case. You should add some logic so that you only trigger the value change event once when the current time reaches the target time. Right now your case selectors are true for a minute, and if you do the same with the value change event it will occur over and over again unnecessarily. I recommend a boolean stored in a shift register that indicates whether the time event has already occurred; you'll also need a way to reset it.

0 Kudos
Message 9 of 15
(5,175 Views)

>>You can trigger a value-change event when you reach a certain time by using a Value (Signaling) property node.   Right now your case selectors are true for a minute, and if you do the same with the value change event it will occur over and over again unnecessarily.

 

Thank you.  I tried this and found the VI will hang when the Value Signaling is triggered.  This is probably due to the multiple triggers during the one-minute period.

 

>>You should add some logic so that you only trigger the value change event once when the current time reaches the target time.  I recommend a boolean stored in a shift register that indicates whether the time event has already occurred; you'll also need a way to reset it.

 

I understand what you are saying, but I'm having a difficult time realizing the implementation (newbie).  Would you mind supplying example code to explain/clarify the logic?

 

Thank you again.

0 Kudos
Message 10 of 15
(5,135 Views)