取消
显示结果 
搜索替代 
您的意思是: 

Starting events at specific times of the day?

已解决!
转到解答

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 项奖励
1 条消息(共 21 条)
6,792 次查看
解答
接受人 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
2 条消息(共 21 条)
6,790 次查看

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 项奖励
3 条消息(共 21 条)
6,783 次查看

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 项奖励
4 条消息(共 21 条)
6,774 次查看

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 项奖励
5 条消息(共 21 条)
6,762 次查看

@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}.



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 项奖励
6 条消息(共 21 条)
6,747 次查看

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 项奖励
7 条消息(共 21 条)
6,725 次查看

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 项奖励
8 条消息(共 21 条)
6,718 次查看

@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 项奖励
9 条消息(共 21 条)
6,713 次查看

@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
10 条消息(共 21 条)
6,703 次查看