Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

timed-loop period is different with the measured loop time

Hi,

 

I have some problem when measuring the timed loop. I tried to measure my timed loop by adding some feedback block. Unfortunately, the result is twice of my timed loop setting. My setting for timed loop is 1 ms between the loop time, but it appeared 2 ms when I measured it manually using the additional block.

 

So, what causes my loop time to become doubled?

 

* I attached the project file, the VI is under Main.vi

0 Kudos
Message 1 of 4
(2,204 Views)

You can get the loop time from one of the nodes on the top left inside the loop (expand the current "error". output). No need to measure it seperately. What is the "finished late" output?

 

. Do you have the same problem with your loop example that only contains the time taker?

0 Kudos
Message 2 of 4
(2,195 Views)

Hi Altenbach,

 

So basically, I want to generate a signal from the analog output with fixed time sampling. Then, I set my loop time at 1 uS by set the dt=1000 in my timed-loop. With this setting, I got both 1000 uS or 1 mS by measuring the period in output node and loop time manually using the tick count. But in the second picture, I got a different result between the period in the output node and tick count.

 

 

 

Blank VI with just timed-loop and tick count.

rwastuw_0-1603363263587.png

 

My existing VI with timed-loop

rwastuw_1-1603363599460.png

 

 

0 Kudos
Message 3 of 4
(2,163 Views)

You did not answer my other questions, but a loop cannot spin faster than the slowest item in it. It cannot go to the next iteration until all code has completed and your loop contains a lot of expensive garbage code (express VIs, dynamic data, conversions, etc.) that are probably not the most efficient way to do things.

 

You are making many poor choices, e.g. constantly growing and shrinking the array in the shift register, especially bad since you are pre-pending instead of appending. This is a huge burden on the memory manager unless the compiler can work around it. See if you can come up with a solution that operates in-place on a fixed size array. There is probably no need for dynamic data. Then you are autoindexing on two output tunnels where arrays grow forever and memory needs to be reallocated whenever it runs out of the previous estimate.. You are polling buttons and updating indicators.

 

So what's the experiment? Why can't you do hardware timed IO? Does it really need to be one point at a time? How long is the loop supposed to run?

0 Kudos
Message 4 of 4
(2,146 Views)