From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring Time between two Digital Signals

I'm new to labview, and I have two signals both 5 volts. One occurs first and then the other one. I was trying to use true/false condition and converting data output of DAQ assistant into boolean and running a timer and then substracting two times. But I get really small time difference of 10ms, however its true values lies around 400 - 500ms. If you will give any suggestions please explain what the block codes do. Thanks.

0 Kudos
Message 1 of 10
(7,335 Views)

Btw I am using NI usb 6501

0 Kudos
Message 2 of 10
(7,334 Views)

It might be a simple fix, but I am not sure how you have set up the code.  Posting the code or a screenshot of the block diagram would be helpful.

0 Kudos
Message 3 of 10
(7,324 Views)

SMC Program.jpg

0 Kudos
Message 4 of 10
(7,320 Views)

The only thing I am not sure is how much delay is introduced by the labview code to actual time difference between two signals.

0 Kudos
Message 5 of 10
(7,317 Views)

Unfortunately the 6501 doesn't have a lot of timing/triggering capabilities like the more expensive DIO/mixed-signal DAQs do.  The 621x series might be a better option, or one of the X-series modules.  Downside is $$$...

 

Rather than using the DAQ Assistant, use the DAQmx Create Channel VI (Digital Input polymorphic) and wire in DevX/Port0/Line0:1 (if you're using P0.0 and P0.1 as the two DI lines) to "lines", and "one channel for each line" in line grouping. 

 

Use the ... blah, take a look at the attached example.  Add some logic where the data indicator is.  This example stops when both lines go high (both lines connected to gnd). 

 

I'd recommend using the "get date/time in seconds" VI when the first line goes high, take that value and subtract it from anohter "get date/time in seconds" reading when the second line goes high. 

 

If your application requires a little more precision (like, sub-millisecond resolution) I'd suggest a better DIO... but if a few msec error is acceptable, polling the DI lines and software-timing is probably the cheapest route.

Download All
0 Kudos
Message 6 of 10
(7,235 Views)

I am trying to do something similar but I'm using a single channel.

 

Using Labview with the MyDAQ and/or the 6024. I am trying to simply monitor a digital or analog channel and calculate the time between two events (two consecutive falling edges on a single channel). This is for an apparatus measuring an object falling through a tube triggering two spaced optical sensors that output falling edges of a 5v nominal signal when the projectile passes.

 

I am new to Labview and trying to figure out this basic experiment. I have found the Basic Level Trigger Detection VI . Is that a good tool for this or is there something more straightforward?

 

Thanks.

0 Kudos
Message 7 of 10
(7,178 Views)

Hello Zimbop,

 

For digital signals, I would recommend using a digital counter task to accomplish the time measurement between 2 raising edges. Examples describing this can be found in the Labview example finder as shown below.

 

Examples.png

 

For analog signals, I prefer to acquire the data than post process to find the time difference between the two edges. The Basic Level Trigger Detection VI can be a helpful tool for accomplishing this.

 

Eric

Eric Liauw
Senior AE Specialist - Automated Test | CLD | CTA
National Instruments
0 Kudos
Message 8 of 10
(7,160 Views)

Hello everyone!

 

I am trying to find the best way to measure the time between edges (to perform a simple estimation of RPM's). I am using Arduino (can't use DAQmx VI's), and I already could make something work using the concept of the VI that "panoramarts" shared. I have just one signal in (on , off) so when I measure the time, using the VI I mentioned (panoramarts), the program will calculate the time difference every TWO edges (1st with 2nd, 3rd with 4th, and so on), and not one after the other.

How can I solve this so it continuously gives the time difference of consecutive edges?

 

Thanks in advanced to anyone that can give a pice of advice on this.

DMDsync
0 Kudos
Message 9 of 10
(6,862 Views)

Hi DMDsync,

 

You can use the following example to measure the pulse width of a digital signal:

 

 pw.png

 

Also, you can use Meas Semi-Period to measure the high and the low pulses of a given signal. For every measured period two data points will be returned.

Mikhail
RF Toolkits, Product Support Engineer
National Instruments
0 Kudos
Message 10 of 10
(6,833 Views)