Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Usage of Timed Loop versus a timed/wait While Loop

I apologize if there are other forums for this but I could not find one.  I am creating an embedded system on a 9636 board and have more of a general question.  I want to know the advantages of using a Timed Loop versus using a While Loop with a wait constant included.  None of my functions are dependent upon processor clock time, but I do logically control things based on time.  For example, I may query transducer readings every 30 seconds or log data every 5 minutes and have just used increments based on the loop wait constant.  however, this is my first time programming an embedded system and was wondering if there is an advantage to changing my timed while loops to actual Timed Loops.

 

Thank you,

gerin99

0 Kudos
Message 1 of 4
(7,948 Views)

There are couples of timed loop advantage such as loop priority, you can abort loop from other part of VI, you can control loop period less than 1ms, you can select the processor, you can check whether previous loop miss the dead line, and so on. Howevr, your program is not that fast. I think you should use only a while loop with ler's say 100ms period, and use time elapsed function to check for 30 secs.

Message 2 of 4
(7,936 Views)

are you going to run this application on RT or Host ?????

if it on RT timed loop can give your task priority. By default on RT timed loop has highest priorty ( less than Time critical ).

Timed loop can tell you the task you specified has taken the amount of time you expected or greater and if greater then what is the reason.

If your application is not using the processor clock cycle then how you have applied it in software because only timed loop will give you the opportunity to specifiy other clock.  

0 Kudos
Message 3 of 4
(7,933 Views)

I agree with KateB - your use-case definitely doesn't seem to require the use of a timed loop; anything with timing of more than 1 second generally wouldn't require use of the timed loop unless the contents inside the loop actually took longer than 500ms to execute, in which case I would consider refactoring your code.  However, it can be challenging to write an application that correctly makes use of timing and cancellation.  Fortunately there is a GREAT problem within the Certified LabVIEW Developer practice exam that actually covers this exact case and it is explained exceptionally well.  I would download the Certified LabVIEW Developer practice exam and check it out.

 

https://lumen.ni.com/nicif/us/ekitcldexmprp/content.xhtml

 

-Danny

0 Kudos
Message 4 of 4
(7,853 Views)