Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Measure time between rising edges of two analog signals

I am trying to measure the elapsed time between rising edges of 2 analog signals, in real-time using DAQmx and a PCIe DAQ card.

 

The two-edge separation function of a counter can do this very easily but this built-in function is only for pulse (digital) signals.


My signals are analog. How can I do this with DAQmx? I have tried doing this:
1. Set up two counters to produce single digital pulse each
2. Each pulse is triggered by each analog signal, on the rising slope and at certain voltage level
3. Thus I will have two pulses whose rising edges are apart from each other by the same amount of time as the original analog signals
4. I will then use a 3rd counter and use the two-edge separation function to measure the time difference between the two pulses.

 

The above cannot work since the pulse generation cannot be triggered by an analog signal...it can only be done with a digital trigger, and according to the DAQ card's manual, the trigger can only come from PFI0.

 

If I use the simple two-edge separation function, can I instead just connect analog signals to PFI lines and use the function directly? Will it work? Is it possible to connect analog signals to PFI lines directly and use the counter's two-edse separation measurement which is supposed to be only for digital signals?

0 Kudos
Message 1 of 4
(3,336 Views)

What you're hoping to do shouldn't work, or at the very least shouldn't be expected to work.

 

You should plan on incorporating some simple interface circuitry (have you looked into Schmitt Triggers?) to create digital logic edges when your analog signals cross the appropriate threshold levels.  Then you can use your digital PFI pins and counter tasks to do the real-time edge separation measurements.  Compared to post-processing chunks of analog data, you'll get better timing resolution, lower latency, and less CPU usage.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 2 of 4
(3,316 Views)

You can try to acquire the signal inside a loop point-by-point, for example using daqMX Analog DBL 1Chan 1Samp. You pass this read signal through the loop with a shift register also, so that you have available the previous value. Inside the loop you can subtract the actual signal value minus the previous signal value and in this way gain a rate of change. That could be used to detect rising edges. Keep in mind however, that the loop time has to be pretty high and also, that by creating this "Delta" probably nose will also be registered as a "rising edge". So you have to include some logic, that activates only when the difference between actual & previous is high enough and at the same time the actual value is over a specific threshold

In case you have access to FPGA hardware, this application can be solved perhaps even more simple.

Good luck



0 Kudos
Message 3 of 4
(3,301 Views)

If your DAQ device (you didn't tell us which one you have) supports analog reference triggering, you could conceivably create one digital pulse internally in the card every time the signal crossed a threshold.  That said, you'd need two such circuits and the ability to route those digital signals to the counter circuitry.  If your card supports analog reference triggering, it will only have one analog trigger circuit because NI doesn't make cards with two such trigger circuits on one board, so the point is moot.

 

You have two realistic options:

 

  1. Do the time delta measurement in software after acquiring the two channels of analog data.  (You could use the Transition Measurements VI or some other similar function to get the location of edge events and then put in the logic to correlate the events across channels and subtract the times.)
  2. Put a level shifter circuit in front of your analog measurements.  These circuits will essentially output a digital high or low if your analog signal is above or below, respectively, a threshold that you can usually supply with a voltage reference.  As long as that buffer circuit met TTL thresholds, you could then wire those TTL outputs (and NOT the analog signals themselves) into your digital inputs and use your counters for a two edge separation task.
Message 4 of 4
(3,170 Views)