03-12-2019 10:43 AM
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?
03-12-2019 11:38 AM
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
03-14-2019 02:50 AM
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
04-11-2019 02:00 PM
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: