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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

timing in queued SM

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!!!

0 Kudos
Message 1 of 6
(2,265 Views)

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.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 6
(2,263 Views)

So what you are saying is that if there is not data to be dequeued theloop will do noting?

0 Kudos
Message 3 of 6
(2,252 Views)

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


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 6
(2,242 Views)

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


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 5 of 6
(2,218 Views)

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

 

Best Regards

Alex E. Munkhaus
Certified LabVIEW Developer (CLD)
System Engineer
Message 6 of 6
(2,191 Views)