10-06-2015 04:28 AM
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!
Solved! Go to Solution.
10-06-2015 04:46 AM
10-06-2015 06:55 AM
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!
10-06-2015 07:05 AM - edited 10-06-2015 07:06 AM
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…
10-06-2015 08:59 AM
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!!