LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Entering a case structure only once

Hello All,
I would like to enter a case structure exactly once a day at midnight, do something and then not repeat it until the next day. My initial attempt was to wire a case structure that checks if the hour is 00. But the problem with this approach is that the case structure remains wired as true for the entire hour (till 0100 Hrs). How does one do something when the hour is 00 and then not do it until the next day? I do not want to use the seconds (compare if it is 00 Hrs, 00 min and 00 sec) because I am not sure about the timings in the while loop. So ideally I would like some marker that flags that the job to be done is finished and the next iteration at 00 Hrs would check the marker and if it is set will not repeat th
e job.
In the vi I have attached, the big marker light remains lit when the minute (I have made it a minute where as in the real programme it is hours) is equal to the control number ; you will notice that the Boolean LED remains lit for the entire duration of the control minute.
Any suggestions as to how this can be solved?
KB
0 Kudos
Message 1 of 5
(2,988 Views)
Hi,

It's exactly what you said. Use a marker (Job's done) and check that marker at midnight (don't forget to reset the marker).

Here's a litlle modification of your VI that explains better.

Hope this helps !
Julien
0 Kudos
Message 2 of 5
(2,988 Views)
It does not seem very efficient to constantly poll for the time. I suggest an event structure with a timeout.

Except for the first call, the timeout is the number of ms in a day. For the first iteration the timeout is the number of ms left until midnight.

Simply use a shift register for the timeout as in the attached example. It gets initialized with the time until midnight, then permanently gets the 1 day timeout.

(I haven't fully tested the demo, but you'll get the idea)
Message 3 of 5
(2,988 Views)
Sorry, I made some errors in the time calculation in the version I just posted above. Here is a corrected version that also can be switched to once/minute for debugging.
Message 4 of 5
(2,988 Views)
Works exactly as I wanted it to do. I had to use both the methods of using a marker and the event structure, since the event structure inside a while loop I already have for DAQ does not work (long timeout?) so I used the marker method inside the existing while loop and the event structure menthod outside my existing while loop.
Thanks to both of you for helping me out.
0 Kudos
Message 5 of 5
(2,988 Views)