LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to capture/record the time at which each sample is aquired

My application uses the Rettriggering Method to aquire one AI channel's data based on happenings of external events (the frequency of these external events is varying and not fixed). Data aquisition is made when those external events occur. The attached VI achieves this function. However, I still need to capture and record the time at which each sample is aquired. In other words, I need to know the timing of each external event when they occurs.
 
I tried simply change "DAQmx read" block to Waveform from DBL. But this does not solve the problem. The first column in the obtained .lvm file becomes time points. These time values looking as below are related to the pre-set sampling rate (here is 10000Hz), which is not the actual sampling rate. The actual sampling rate is not fixed due to happenings of external events.
 
0.0000
0.0001
0.0002
0.0003
...
 
 
Please could any expert help out? I only need to capture the time of each sample, or catch the timing of external events?
 
Many thanks.
0 Kudos
Message 1 of 12
(3,611 Views)

Hi wjshm,

change the read.vi to waveform output, there you have a start time and a dt at which each point was measured. With this information you can calculate the exact time for every value.

Mike 

0 Kudos
Message 2 of 12
(3,608 Views)

Hi Mike,

Could you be more specific how to do it? The problem is that dt is not fixed but unknown, then how this data pruning can be made?

Thanks for further help please.

wjshm

0 Kudos
Message 3 of 12
(3,606 Views)

Hi wjshm,

if you use the read.vi with the waveform type the dt value is fixed. See the attached example please.

Mike

0 Kudos
Message 4 of 12
(3,601 Views)
Hi Mike,
 
Maybe I did not express clearly. In my application, dt is not fixed but unknown. So Waveform, in this sense, is not workable.
 
Wait here on line for a solution.
 
wjs
0 Kudos
Message 5 of 12
(3,597 Views)
Anybody can offer some advice please?
0 Kudos
Message 6 of 12
(3,567 Views)
I don't think the standard DAQ functions can give you what you want.

Record the triggers on a separate channel with sufficiently high sampling rate to capture the trigger times to the resolution and accuracy you require. The minimum time between triggers and the widths of the triggers will determine what you need to do to capture the data. You may also need to do some processing to get the times of each trigger.

Lynn
0 Kudos
Message 7 of 12
(3,562 Views)

Hi Lynn,

Thanks for your input. The external events (which are TTL pulses) occur and change in the frenquency range 10kHz - 100kHz. I read some other threads saying it is not accurate to use LabVIEW "get timestamps" block to aquire the time information. If that is true, maybe I have to buy a counter/timer like PXI 6602 to do this work. But still wondering if this is necessary.

Thanks.

wjshm

0 Kudos
Message 8 of 12
(3,557 Views)
wjshm,

With a maximum frequency of 100 kHz you will need timing resolution better than 10 microseconds, probably 1 microsecond or less. All of the LabVIEW timing functions (Tick Count and Get Date/Time) involve calls to the operating system. The resolution will not be better than milliseconds.

I am not sure that a 6602 can give you the time of arrival of pulses at 100 kHz. It can certainly count them. The buffered period counting might work. I never tried to use it that fast.

What I was thinking about was doing a hardware timed digital input, perhaps with a 1 MHz clock. You would get a t0 output when the acquisition started and have a dt of 1 us. Then the index of each rising (or falling) edge in the data would give the time of a trigger:

t(tr) = t0 + i(tr) * dt

Lynn
0 Kudos
Message 9 of 12
(3,553 Views)
Lynn,
 
I will ask NI application engineers whether PXI 6602 can give me the time of arrival of external pulses at 100 kHz.
 
About the method you think, theoretically it stands, but how this can be implemented? I believe this is also the fundamental of NI to handle data aquisition triggered by external clock.
 
Thanks.
 
wjshm
0 Kudos
Message 10 of 12
(3,549 Views)