LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Inconsistent Time Interval

Hi

I have a vi which has four parallel running while loops. One is used
to acquire data from the data acquisition board, one is used to plot
the data, one is used to calculate a setpoint which is then used in
the fourth loop which contains the PID.vi from the PID Toolkit.

I want my loops (particularly the PID loop) to always run at a rate of
one iteration per 0.3 seconds, so I have placed a "wait until next ms
multiple" function in each of the loops and wired a value of 300 to
them. I am using the "Time since last call".vi to determine the speed
of each loop.

The problem I am having is that sometimes the loops run with a time of
precisely 0.3secs (which is good), yet other times the loops (from the
very moment of pressing "run") oscillate around 0
.3 seconds (sometimes
upto +/- 10%). There seems to be no rhyme or reason (that I can
detect) that makes it sometimes work and sometimes not. If it happens
to be an occasion where the time oscillates, then it will continue to
oscillate for the duration of the run. vice versa, if it happens to be
an occasion when it works fine, then it will work fine until I press
end.

I can literally run my program, have it work OK, press stop, press
start again, and it not work OK.

Can you think of any reason as to why this maybe?

I have local variables in some loops, which are calculated in others.
Could this be a problem?

Thanks for your time,


Dr Jonathan Atkinson
0 Kudos
Message 1 of 3
(2,751 Views)
If the operating system you are using is Windows, please find this article in NI Knowledge Base 'Why is the Delay Function Inaccurate Under Windows?' (http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/862567530005f09c8525643d004e509e?OpenDocument)
and 'PID Control Toolkit and Internal Timer Issues' (http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/dbd4729c3b55326b8625619700782cab?OpenDocument)
good luck
0 Kudos
Message 2 of 3
(2,751 Views)
If you have 4 independent parallel while loops, a wait until next ms
multiple function is not ideal.

Each loop will wake up at the same time, more or less! Because each loop
in turn will notice that the timer has reached a multiple of 100 ms, and
will wake up.

Make some of these non-independent, using normal dataflow?

Or replace wait until next ms multiple by the Wait function, now each
loop will wait for 300 ms independently of the others.

For subtle timing, stagger the order in which they start. Initialize
each loop at the beginning using the wait until next ms multiple. After
the first loop starts, wait 75 ms then fire off the next loop, another
75 ms for the 3rd loop, & another 75 ms then the last loop.

Mark
Message 3 of 3
(2,751 Views)