Jump to content

Use of Timer Loops


Recommended Posts

hi to all i need to learn about all the timer loops and especially the tick count... I would like to learn..that if say i want to know the execution time of a while loop..and need to get the difference of my previous sample and next sample...how to implement it?.. can anybody help me or explain it to me with one short and sweet example... I much thankful to him/her if i wil get the answers from u people... Sahara

Link to comment

If you want to know the execution time your while loop takes you can use a shift register to calculate the difference in time. Here is an example using "Get Date/Time in Seconds.vi" and "Tick Count (ms).vi". The method that uses the get date/time will use more processor time than the tick count method. However, if you use the tick count method the counter will wrap back around to zero at some point so you will get an error eventually if you run it for a long time (will wrap around once every 50 days).

post-8228-1193724717.jpg?width=400

Download File:post-8228-1193724740.vi

I don't know if this is what you are after or if you wanted help using the timed-loop structure.

Link to comment

QUOTE(Karissap @ Oct 30 2007, 07:15 AM)

...However, if you use the tick count method the counter will wrap back around to zero at some point so you will get an error eventually if you run it for a long time (will wrap around once every 50 days)...

The wrapping of the U32 tick count value is not an issue, unless one iteration is taking more than 2^32 ms to complete.

In other words: A-B, where A and B are U32 values, will still be correct even if A wrapped (unless the real difference is greater than 2^32).

/J

Link to comment
  • 3 weeks later...

QUOTE(Karissap @ Oct 30 2007, 06:15 AM)

Why use of shift registers for initial time "stamp" (are there any performance benefits, or...?). If you just connect initial seconds count to the while loop boundary every time loop iterates it will get same value; that would eliminate need to carry "non-changing" variable through the loop and shift registers. or am I missing something?

Link to comment

QUOTE(carlover @ Nov 15 2007, 11:11 AM)

Why use of shift registers for initial time "stamp" (are there any performance benefits, or...?). If you just connect initial seconds count to the while loop boundary every time loop iterates it will get same value; that would eliminate need to carry "non-changing" variable through the loop and shift registers. or am I missing something?

What you suggest would give you the total time elapsed in the loop. The way it's written now gives you the elapsed time of each iteration of the loop.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.