LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Send messages at different programmed rates

Solved!
Go to solution

Hi, I have to send three different messages from LabVIEW to a microcontroller. Each message has to be sent at a different programmed rate, for example:

- send message 1 every 5 seconds

- send message 2 every 3 seconds

- send message 3 every 60 seconds

Which is the best way to organize that? Should I use three different While Loops or maybe a single While Loop with a state machine, or other...?

Thanks in advance for any suggestion!

0 Kudos
Message 1 of 5
(3,217 Views)

Hi biomed,

 

I would use a state machine…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,202 Views)

Thank you GerdW! Can you please show me a simple example of how to do that? Should I insert a time counter inside each case structure or use one single timer to abilitate different case structures? I'm a newbie with these things... Thanks!

0 Kudos
Message 3 of 5
(3,176 Views)
Solution
Accepted by topic author biomed87

Hi biomed,

 

I would use an array of cluster [ timestamp, message-type].

When you send a message, for example message#1, you put a [timestamp and message#1] in the array, where timestamp is the time, when to send the next message#1. The same applies for each other messages too.

 

Your state machine would just have a "check" state where it checks the current time vs. the timestamps in your array. When a stored timestamp is "over" you remove that cluster from your array and send the next message…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(3,171 Views)

Thank you very much GerdW, your help has been precious!!

I attach a VI where I implemented your suggestions, maybe it can be useful for other people...

Thank you!!

0 Kudos
Message 5 of 5
(3,139 Views)