LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed loop not executing on time

Hi everybody,

I am trying to make a timed loop where I first aquire data (analog voltage) from my PCI-6024E card and then write this data to a measurement file (with the write to measurement file function). This in itself is no problem, but I have set the loop's iteration time to 2000 ms seconds, and the iteration time varies each time I run the loop (total variation is about 15 ms) even if I am doing the exactly same thing.  I suppose it is the DAQ assistant I use that creates this problem, but I am not sure.

The timing is very important, because I also generate a pulse in a parallell timed loop which is red by the this timed loop. And I need to know at which instant the pulse was generated. The important thing would be for the pulse generation and the pulse reading from the card to start at the same instant.
I am using LabView 8.5.
Can anybody help me with this?

-Jenny
0 Kudos
Message 1 of 8
(3,681 Views)
If two things should happen a the same time, the two operations probably belong in the same loop. Ideally, you should do hardware timing and run both off the same clock. How do you measure the iteration time?
0 Kudos
Message 2 of 8
(3,680 Views)
Hi Jenny,

how do you measure time?
When using (wrong) inappropriate functions you will always have variations of upto 15ms because Windows will not provide more accurate timings!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 8
(3,670 Views)
Well, I now did put everything in the same loop. The data aqusition does start at an arbritary time about 50-65 ms later than the function which generates a pulse. (Should start simultaneously) Should I do the data aquisition differently (now done with DAQ assistand) or can I time it somehow differently.
No the only timing I have is the timed loops timing (1kHz clock) is this the problem?

jmvester
0 Kudos
Message 4 of 8
(3,634 Views)

Hi Jenny,

Since you are using an E series card, I am not sure if you would be able to do the two operations (acquiring data and output the pulse) simultaneously!  Can you not start the acquisition BEFORE you send the pulse output and programatically determine the delay and ignore the samples acquired before the pulse output?

Vikas

0 Kudos
Message 5 of 8
(3,615 Views)

An E series card lets you define clock sources so you can run both off the same clock and they will occure exactly simultaneously. For example you could probably tie the AI conversion to the pulse clock or vice versa. I've done that over 10 years ago where I needed to synchronize AI and AO to occur at the same time.

Are you using express VIs for the hardware interaction or lowlevel VIs? Can you show us some code on how you actually do things ( DAQ, measure timings, etc.).

0 Kudos
Message 6 of 8
(3,599 Views)

Hi altenbach,

I have my lates version here, now I started using the small DAQ-blocks instead of the DAQ assistant. My timing right now is way off.

But I will attach the "main" progam and the two under programs Ttl_cntr0.vi, which just generates a digital  1 sec. TTL pulse and StepFlash, which generates another analog pulse, which length and amplitdue one can defline.

Do I need to make the card timing in the StepFlash vi too? And I do not understand how this hardware timing works, which clock should I use? Sample clock or some of the other ones, is this the same thing as the onboard clock, that is then found in e.g. the DAQ triggering block??? Or should I choose another one from the Clock choises? 

-Jenny

Download All
0 Kudos
Message 7 of 8
(3,573 Views)
Sorry, I don't have any DAQ installed on my laptop, so I canot see most of the items, still....
  • How are you running this??? It seems that all the loops stop immediately after one iteration.
  • Are you using the "continuous run" button?
  • you code with [i] wired to a case and outputting TRUE in both cases makes very little sense (all loops have that!). can you explain the reasoning?
  • You have no data dependency between any of the loops or the counter stuff on top. You have no way to tell in which order they execute.
  • All your expensive channel and timing configurations belong outside the loops, only the read and write operations belong inside the loop once your loops are set to actually spin.

Also check the time loop palette, there are tools to e.g. syncronize the start of time loops.

0 Kudos
Message 8 of 8
(3,553 Views)