LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed loop iterations end early

I have a timed loop set for a period of 12ms (using the 1kHz system clock).

Looking at the actual start and ends of each iteration, it seems that the loop moves to the next iteration after around 4ms, rather than 12ms.

How can I force the loop iteration to idle until the full period has elapsed?

0 Kudos
Message 1 of 16
(3,968 Views)

Can you show us some simplified code? How do you measure the timing?

0 Kudos
Message 2 of 16
(3,963 Views)

Thanks for your quick response, it's very much appreciated.

Attached is an image of my simplified VI with one of my timed loops. I am coordinating two timed loops hence the synchronised start.

I am using a quad core processor and forcing the other loops and structures onto seperate cores so these shouldn't be an issue.

0 Kudos
Message 3 of 16
(3,949 Views)

In terms of measuring the timing, I take the difference between the actual start and end times, obviously ignoring the first actual end time (and writing this all to a spreadsheet file).

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

can you attach the actrual VI instead?

 


@iskrazaf wrote:

I take the difference between the actual start and end times


Shouldn't you take the difference between successive start times?

0 Kudos
Message 5 of 16
(3,925 Views)

The difference between start times is the same as what I am doing, as there is no delay between any of the iterations. I have attached an image of the first few data points from a test run so that you can see for yourself.

Also attached is my VI, but it's quite messy and complex because I'm still in the process of developing the system.

It's for my final year undergraduate thesis project in engineering.

Download All
0 Kudos
Message 6 of 16
(3,913 Views)

You are looking at the difference between when the previous iteration ended and when the current iteration began.  You are actually measuring the wait that the Timed Loop put in in order to maintain the loop rate.  If you want to get an actual loop rate, you should look at the Start Times.

 

In your code, I'm seeing a dt of 1.  Why didn't you set that to your 12ms?


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 7 of 16
(3,840 Views)

One other thing, why are you setting the dt and mode in every iteration of the while loop, even that it can not change?

 

You have also a lot of sequence structures that are not needed, as the data flow force the correct execution.

0 Kudos
Message 8 of 16
(3,830 Views)

Thanks for your responses guys, really appreciate the help.

 

crossrulz: if you look at my timing data you can see that even if I take the difference in the start times, the loop is still ending early. The column on the left is an array of all the start times for every iteration. This is confirmed by the physical response of the system (a camera and LED setup). Also, the dt in my code is set to a control so that I can play with it when I am testing the system (see LineCapture_v6). I made a very quick simplified VI of my code for altenbach and attached it as a jpeg, so I must've accidentally put a 1 in the dt for that one. But I have definitely had dt set to 12 for my timing data collection.

 

dkfire: I was setting the dt and mode in every iteration as a frustrated attempt to fix it, it was a bit of a last ditch effort that I knew was probably unnecessary. To be honest I'm tearing my hair out here over this, I just can't see why it's not timing properly. The sequence structures are there so that I can force execution onto different CPU cores, I got a new computer so I just was playing around to test the performance.

 

Again I am still very much in the development stage, I haven't cleaned up my code, it's messy, I'm very sorry about that. I swear I'm usually a lot neater 🙂

 

0 Kudos
Message 9 of 16
(3,818 Views)

Sorry, I cannt really investigate your code, because my laptop screen is not big enough. It actually crashes my labVIEW 2014 reproducibly when I press "cleanup diagram". 😞

 

In general, you should take all these timed loops and sequences out of the event structure. What kind of hardware is this running on?


crossrulz wrote:

In your code, I'm seeing a dt of 1.  Why didn't you set that to your 12ms?


You need to look into the other event cases. There are dozens of timed loops and some have a dt determined from a control that is set to 12ms.

0 Kudos
Message 10 of 16
(3,803 Views)