LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

triggering event by time of day

Solved!
Go to solution

I am trying to set up a system which needs to take several samples per day at set times (irregular intervals), and then repeat this each day for a week or so. So far I have been trying to use an array of TimeStamp controls, but am not getting far. Does anyone have any ideas on how to do this, or can point me to an example I have missed in my searching.

 

Thanks

 

0 Kudos
Message 1 of 25
(4,341 Views)

Does this application need to be doing other stuff while waiting for the next timing interval to come up, or can it simply go to sleep until the appointed time?

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 25
(4,326 Views)

Hello Mike,

Most of the time the application will be waiting around for the next timed event to happen. The PC will be used exclusively to run this experimental equipment, so there won't be other applications running in the background either. I hope to run 5 sets of the experimental apparatus, each with its own set of timed events to occur. An 'event' is turning on a motor for a few seconds to deliver a measured amount of feed to animals at set times through the day. The shortest time interval between feeds is 1 hour, so even with 5 sets, it won't be working too hard.

 

0 Kudos
Message 3 of 25
(4,320 Views)
Solution
Accepted by topic author Novelec

Then what I would do is create an event loop with only one event - a timeout. Driving this event, would be an array of times when an action needs to be performed. When the loop starts, remove the first element and subtract the current time from the time target. This will give you the time in seconds until the event. Multiply it by 1000 to get the number of milliseconds until the target time. Feed that value to the timeout. Then each time the timeout event fires, index out the next element and calculate a new delay.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 4 of 25
(4,288 Views)
Actually a 2nd event case that handles the Value change of the Stop button is also desirable.  That way if you want to stop the program before the timeout is up, it will handle it right away.
0 Kudos
Message 5 of 25
(4,282 Views)

Good point, thanks...

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 25
(4,281 Views)

Thanks Mike - I tried using an event structure and it works well. Getting this going has now brought to light another problem. I am feeding the event with an array of 24 timestamps. The problem is that if the user only wants say 6 time events, the rest of the array is filled with either default values or values from a previous run. Is there any way to programmatically let the user shrink the array size, or to fill it with null values or something?

 

 

 

 

 

0 Kudos
Message 7 of 25
(4,199 Views)

Why are you stuck with 24 timestamps? Write the logic building the timeout array to only create as many elements as there are timeouts required.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 25
(4,191 Views)

The maximum number of timeout events required is 24, so I have created an array of 24 Timestamp controls on the front panel. I have been looking at using other methods of getting users to enter times (such as tables), and then creating an array from this, but so far without success.

 

0 Kudos
Message 9 of 25
(4,184 Views)

Ok, starting with an array of 24 empty timeout events, let the user edit the list to insert the appropriate timing data. When they click a button to start the tesst, trim off the end of the array any elements into which they haven't entered any data.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 10 of 25
(4,181 Views)