LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Measure time between triggers on analog input

Solved!
Go to solution

Hi,

 

I'm using an NI USB-6009 to measure an analog input. I want to measure the time between triggers on this input. I'm using the 'trigger and gate' express VI, it does a great job of triggering, but I can't figure out how to measure the time between the triggers. Any suggestions are appreciated!

Little_Owl_0-1690397350016.png

 



note: this will be done in real time with a DAQ card. The attached VI has a representative data set that I split into chunks to 'simulate' the DAQ readings

0 Kudos
Message 1 of 8
(1,114 Views)

Little_Owl_0-1690397667195.png


FYI there is a double pulse for each trigger. I'm counting this 'double pulse' as 1 trigger on purpose.

0 Kudos
Message 2 of 8
(1,110 Views)

with this slow samplerate  simply do a peak detection (actually valley) 3-4 point width

see attachment

 

You really should try to use a higher samplerate 😉

 

 

EDIT: Oh one pulse ... which one to take first , second , mean of two ?

 

You need to use the hardware timing information (t0 and dt) .. the location information from the peak detection is sample based, with t0 and dt you can calculate the timestamp of your pulses and calculate the differenence.

I would use continious aquisition without the express vis to get snippets of the the waveform incl. t0 and dt

see shipped exsamples for continious aquisition as a starting point.

 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 3 of 8
(1,067 Views)
Solution
Accepted by topic author Little_Owl

build a better one

 

sometimes get the double pulse but that is easy filter 🙂

try samplesize 4 to get each trigger 😉 (and minimize or remove your delay :D)

 

you need to handle the timing information with your sampled data!

(at least the samplerate)

 

do you need subsample resolution ?  peak detection will fitt a square on the pulse and migth allow that, but is a function of the shape of your trigger pulse

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 4 of 8
(1,057 Views)

Hi Henrik,

 

Thanks for the reply! I neglected to mention I'm still on LV2012, are you able to post for that version?

0 Kudos
Message 5 of 8
(1,030 Views)

Re: sample rate

 

Agreed, I should definitely increase the sample rate. Historically the pulse amplitude and width was much greater. It's a pretty weak signal on the current hardware setup.

 

I've tried doing peak detection before but I get different results if I run it on the entire set vs. discrete samples. I get less peaks detected when it runs on the discrete samples. My guess was that it had trouble with pulses that land on the edge of the sampling window. Thats why I liked the 'threshold and gate' VI, it seems to buffer the data in a way that it doesn't run into that issue - unfortunately it's also a black box and I couldn't figure out how to get the timing information (sample #) out of it.

 

I don't need subsample resolution. But a quick response time is useful - eventually I'll trigger some other hardware when a peak is detected.

 

I'll take a look at your VI when it's converted to LV2012 🙂

 

0 Kudos
Message 6 of 8
(1,023 Views)

here we go

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 7 of 8
(996 Views)

Ah, the 'dt' parameter was the trick. Thanks! I don't have any experience with the waveform data type.

 

Also, I never noticed you could make a concatenating tunnel conditional - wow!! That's very convenient

0 Kudos
Message 8 of 8
(933 Views)