LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Starting events at specific times of the day?

Solved!
Go to solution

Hi All, 

 

 

I would like to trigger events at specific times of the day, and would like suggestions on how the attached vi can be improved.   

 

The events will drive a state machine, as per this example by FuManWho: 

https://forums.ni.com/t5/Example-Programs/UI-Producer-Loop-with-State-Machine-Consumer-Loop-Using-La...

 

The vi works (as long as the consumer is slower than the producer), but I'm sure there is a better way of doing this! Custom events? QMH? 

 

Many thanks

Graham 

0 Kudos
Message 1 of 21
(4,753 Views)
Solution
Accepted by topic author grahamwebb

Hi graham,

 

just a suggestion:

check.png

You could put those FOR loops into the timeout event of your event structure…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 21
(4,751 Views)

Oh I like that. Thanks. 

 

I did have them in the timeout at one stage but moved them around to get over a different problem - my event queue was filling up (to 99 events) in the time the 60 seconds the test condition was true. Limiting the queue size and adding delays worked but I didn't like stalling the consumer to get around that. 

0 Kudos
Message 3 of 21
(4,744 Views)

Hi Graham,

 

my event queue was filling up (to 99 events) in the time the 60 seconds the test condition was true.

You surely want to generate just one event when the conditions switches to TRUE!

So you need to include a comparison to check for changed conditions…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 21
(4,735 Views)

Yes (at least I think so!). The event would be something like play mp3 file, switch light on, boil kettle etc. Single discrete events that begin at that time. 

0 Kudos
Message 5 of 21
(4,723 Views)

@grahamwebb wrote:

I did have them in the timeout at one stage but moved them around to get over a different problem - my event queue was filling up (to 99 events) in the time the 60 seconds the test condition was true. Limiting the queue size and adding delays worked but I didn't like stalling the consumer to get around that. 


What you should do is add a shift register to hold the current comparisons.  Then you can do a if(current Value == TRUE AND previous value == FALSE) {do action}.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 21
(4,708 Views)

Do you really need to check for a timeout every 10 ms? That seems extremely fast for the types of events you are triggering.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 21
(4,686 Views)

Since I can't open the VI (Installing 2017 now) and it is in 2017

 

Why not use "Value Changed.vim" on the Time Date record.(Day, Hour, Month, Minute) element as appropriate?

 

Hint: for bonus points you can even add a "Quotient & Remainder" to a counter that increments every (Whatever)

 

Anyone up to Whip in a simple example firing a "User Event" every n Seconds? (Wire control "n" to the divisor of Q&R test R=0, if so generate "User Event"

🙂 Bonus points if the user event data type contains a date-time record


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 21
(4,679 Views)

@GerdW wrote:

Hi graham,

 

just a suggestion:

check.png

You could put those FOR loops into the timeout event of your event structure…


Also be aware of that issue with DST and the witching hour of 2:00 AM. One day of the year there are two hours that are "2:00 AM" and another day where there is NO "2:00 AM". As long as the trigger times are not in that window, just ignore me.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 21
(4,674 Views)

@Ben wrote:

@GerdW wrote:

Hi graham,

 

just a suggestion:

check.png

You could put those FOR loops into the timeout event of your event structure…


Also be aware of that issue with DST and the witching hour of 2:00 AM. One day of the year there are two hours that are "2:00 AM" and another day where there is NO "2:00 AM". As long as the trigger times are not in that window, just ignore me.

 

Ben


Cast "To UTC" and ingore Ben this time.   😮


"Should be" isn't "Is" -Jay
Message 10 of 21
(4,664 Views)