ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to avoid aliasing with DAQmx

I have a multifunction DAQ device. As an analog output I generate a 2kHz pulse train connected to an LED. The analog input is connected to a photodiode to measure the output of the LED. I'm not interested in the temporal reponse of the LED, I just want to measure the average photodiode voltage every 100 ms.

 

The code I have:

output.png

 

Though it's working, at certain frequencies, I get aliasing of the signal. Meaning that I measure, for example, 2 points in high, and 1 point in low, meaning that the average is too high. I just want to measure the average voltage over 100 ms. How can I make sure that I don't accidentely measure more high points than low points (or vice versa?). Is there an analog aperture time I can set? I found this https://www.ni.com/docs/en-US/bundle/ni-daqmx-properties/page/daqmxprop/attr2fee.html, but this property is not available to me in the DAQmx channel node.

 

Another options I guess, is to synchronize the input with the output, to ensure that I measure 1 point at every high and low output. But this only works because I happen to have all NI devices. What if an external device is generating the PWM signal? How can I avoid aliasing in that case?

0 Kudos
Message 1 of 5
(1,898 Views)

Nyquist theorem states that you need to sample at a rate of at least twice the signal frequency. Since your pulse train is 2kHz, your AI sample clock should be at least 4k, although you should use 5 to 10 times to capture the waveform correctly. Is there any reason why you cannot use a higher sample rate on AI?

 

 

ZYOng_0-1687526523047.jpg

 

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
-------------------------------------------------------
https://github.com/ZhiYang-Ong
0 Kudos
Message 2 of 5
(1,881 Views)

@ZYOng wrote:

Nyquist theorem states that you need to sample at a rate of at least twice the signal frequency. Since your pulse train is 2kHz, your AI sample clock should be at least 4k, although you should use 5 to 10 times to capture the waveform correctly. Is there any reason why you cannot use a higher sample rate on AI?


Yes, our system has a PCI-6225 which has a sampling rate of 250kS/s. We want to measure 32 LEDs simultaneously. Measuring boths voltage and current we need 64 channels, allowing a max sample rate of 250.000 / 32 / 2 = ~3900 S/s/ch. 

 

But like I said, I don't actually care about the shape or frequency of the LED output, I just want to measure the average intensity.

0 Kudos
Message 3 of 5
(1,877 Views)

I think I would use a hardware low pass filter like a simple RC circuit. A time constant of 10ms would flatten the pulses, but a stable reading would be avaliable after about 50ms. Check if your circuit is able to source/sink the filter correctly! 

Message 4 of 5
(1,817 Views)

Some point that came into my mind:

 

You need a scan over all LED within 100 ms, thats about 31 ms per LED ..

 

You need to sync your 2 kHz (is that fixed?) with your aquisition !

(see manual , since you only need a square , you can also consider to use a timer for that)

I would try to configure the analog capture in a way that you sample one channel every 0.5 ms , I don't know the detailed possebilities of that DAQ but with some properties (you should be able   to configure settle time and capture time ) it should be possible to always hit the LED in active mode (better close t the end)

 

Another point is the settle time error at higher impedances. See figure 1 in the spec! We don't know your photodiode detector output impedance, so if it is not buffered..

uups I had a peek ... that card is even worse than I thought...     depending on your needed accuracy , forget the sync idea, go with a RC lowpass and choose a bigger C .. and choose the lowest samplerate (10 Hz ) to scan your channels.

 

As test try 20 Hz SR and use a channel list with every channel twice in the list (CH0,CH0,CH1,CH1, ...) and compare the results.

 

 

 

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 5 of 5
(1,787 Views)