From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-17-2014 03:31 PM
Hello!
I made a big (wel for me it is big) State Machine (SM).
There are a few while loops (Q-sm's) they all have got a case inside, and before the case there is a element de-queued. The queued data is a case with a variant and a typedef. The typedef selects the case the variant is used in the case for what ever reason. It is a pretty standard Qued SM ques.
So there is:
(1)one Q-sm for the data-IO, now it is a simulation but later on it wil be real hardware.
(2)One main SM
(3)A error log SM
I have got some questions about how to get the timing right.
Now I have got the function Wait (ms) in the data-IO loop waiting for 10ms AND the same function Wait (ms) in the main SM.
Q1 Is this the right way? Do I need the function Wait (ms) in all Q sm's? Wouldnt it be better to have one SM telling the other SM's the speed of exeqution?
Q2 in the error log SM there is NO timer, is this okay to do? In other words will the Q-sm only exequte when there is data dequeued?
Q3 Is the function Wait (ms) the right function? It suggests that this function waits for x-ms (I use 10 ms) does this 10 ms add to the rest of the code? That way if the rest of the code would take 1ms and I have got a 10ms function Wait (ms), I get a total of 11 ms. Is this true?
Thank you all for the great help!!!
06-17-2014 03:41 PM
Generally speaking - And thats all I can do without detailed specs- the Wait ms calls inside a loop are there to prevent the loop from being "Greedy. Since you are dequeueing inside the loop the dequeue element will effectivly provide all the waiting you need to not hog the CPU.
06-17-2014 04:18 PM
So what you are saying is that if there is not data to be dequeued theloop will do noting?
06-17-2014 05:06 PM - edited 06-17-2014 05:07 PM
@code.gimmie.code wrote:
So what you are saying is that if there is not data to be dequeued theloop will do noting?
Yeah, that's sort of the point of dequeue element, to give you a "wait-until-there-is-something-to-do" function.
06-17-2014 08:06 PM
@code.gimmie.code wrote:
So what you are saying is that if there is not data to be dequeued theloop will do noting?
That is assuming that the timeout for the Dequeu Element is either unwired or set to -1. If you define a timeout, then that in effect acts as the Wait (ms). Either way, you don't need the Wait (ms) in your queued loops.
06-18-2014 04:42 AM
Hi code.gimmie
I agree with Jeff, that the queue will provide you with the delays you need.
I know a really good article that explains the Queued State Machine. I will definitely recommend you to read it:
Community: Queued State Machine