Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Measure time difference between two signals using PXIe6366 DAQ module with signal routing and filtering

Hi all, 

I am trying to measure the time difference between two signals. One of the signal is a 32kHz clock which stops some time after the 1st signal goes low. The 32kHz clk signal is connected to port0.0 and I am routing this signal internally to the counter0 gate terminal. Since I need the time difference between the falling edge of the 1st signal and the last falling edge of the 32kHz clock signal, I enable the digital filter on the counter gate terminal.

The problem is sometimes I get correct result and sometimes it doest measure at all. 

 

Could someone suggest a solution for this?Attached is the waveform.

 

Thanks

0 Kudos
Message 1 of 9
(5,287 Views)

Roshan,

 

You should be able to do this with your current hardware. I would have a DI task that has the two channels you want. With the PXIe-6366 module you will want to use the hardware timed example, such as Digital - Continuous Input or Digital - Finite Input (Available from the Example Finder, Hardware Input and Output >> DAQmx >> Digital Input). Make sure you use the Onboard Clock as the Sample Clock Source.

 

Triggering - You could trigger the acquisition off of your signal if you wanted. I would probably trigger off of the rising edge or falling edge of your first signal. For instance if you trigger off of the falling edge of your first signal you would begin your acquisiton at the sample where your waveform goes low. From here you would aquire your second signal for a duration of time until you see enough 0 samples in a row for you to determine that your 32kHz clock signal has stopped.

 

If you know the number of samples from your trigger to your "stop" of your 32kHz clock, you will also know your dt or acquisition rate. You would be able to calculate the delay.

 

You could post your code and that will help people see what you are currently doing.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 2 of 9
(5,275 Views)

I am sorry the 32kHz clock is on PFI lines a well. Below attached is a small portion of my code

 

thanks 

Roshan

0 Kudos
Message 3 of 9
(5,268 Views)

Roshan,

 

As you mentioned in your other post, all other Ports than Port 0 are software timed. I believe your signal is too fast to be measuring it SW timed. You have a DI sample clock and a DO sample clock. It's possible to use pins on Port 0 for both DI and DO and both of them be hardware timed.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 4 of 9
(5,262 Views)

For Port 0 i shold be able to do that but for the other ports the only option i find is to enable the digital filter on the counter gate terminal and then route the digital signal from the corresponding PFI line internally to the counter gate terminal.

 

Is there some other solution for this problem?

 

Regards

Roshan

0 Kudos
Message 5 of 9
(5,250 Views)

OK, I understand what you are trying to do now with the two edge separation. You can use the PFI lines on Port 1 to access the counter. According to the X-Series User Manual (Digital Filtering) there are three filter settings:

 

filters.png

 

I'm guessing your value is getting coerced to one of the values above. After you set the value of the min_pulsewidth you could try and read back the value using the Get function instead of the Set just to see what the value is. I'd assume since you are setting 27u, it's probably getting rounded down to 10.25us value. This means you're probably catching some of the transitions of your 32kHz clock.

 

You could try using the High Filter setting, but there are consequences to doing that (Reference X-Series User Manual) mostly you give up some accuracy of the timing of the edge.

 

 

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 6 of 9
(5,243 Views)

Table 6-1 is for filtering digital inputs on port 0.  This is a separate feature from the PFI filters, which are quite a bit more configurable:

 

www.ni.compdfmanuals370784d.png

 

 

While the filters are only present on the PFI lines, in software you access them through the DAQmx terminal properties (if you are using a terminal that is not a PFI line, you'll get an error when trying to configure filtering).  Assuming your signals are input to the DAQ card via PFI line, you don't need to do any additional routing to use the filters, just configure the filter for the appropriate DAQmx terminal.

 

You should be configuring both the first and the second input of your two edge separation to use digital filtering with the same minimum pulse width.  The reason that you filter the slower channel as well is that it will now introduce the same delay (within 1 timebase tick anyway) so your measurement will be consistent.  In the C API for example, there is a DAQmxSetCITwoEdgeSepFirstDigFltrEnable as well as a DAQmxSetCITwoEdgeSepSecondDigFltrEnable.

 

 

Best Regards,

John Passiak
Message 7 of 9
(5,219 Views)

Hi all,

 

thanks for the reply.

Is there some possibility to view this filtered output waveform on the PFI lines?

 

regards

Roshan

0 Kudos
Message 8 of 9
(5,191 Views)

I don't believe you can, but I'm actually not positive (maybe if you are clever with DAQmx Connect Terminals there's a way to get it to work).  I'm working from home today so I can't test it out.  

 

If your goal is to verify the filter is working you could do this with a counter (say, an implicit pulse measurement task) and not have to worry about routing the filtered signal back out.

 

 

Best Regards,

John Passiak
0 Kudos
Message 9 of 9
(5,185 Views)