LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Filter analog signal using arduino

Hello. I've the following problem, in which I need to filter an analog signal coming from a signal generator through an arduino uno. My question is, how can I get the same frequency as I'm inputting in Labview? Because, so far, all my measurements seem to be kinda off. I tried the following code and while it did give me the correct frequency when I measure it with the FFT, when I pass this signal through a Filter VI Express, this error arises:
"The following conditions must be met: 0 < f_low <= f_high <= fs/2."

 

So, how can I fix it so the frequency will be the same as the one coming from the signal generator so I can apply diferent filters to it (lowpass, highpass, bandpass, bandstop)?

Download All
0 Kudos
Message 1 of 4
(674 Views)

I suggest you do a little reading on Nyquist–Shannon sampling theorem

 

Then you will understand why an Arduino is too slow to accomplish this.

 

BTW: The "Loop Rate" indicator is also your actual sampling frequency.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 4
(666 Views)

So you think I'll have a better result using an ESP32 instead of an Arduino or it's still too slow to accomplish such task? And thanks. I didn't completely understand what the loop rate specified, now I do. 

0 Kudos
Message 3 of 4
(631 Views)

@ACMontez wrote:

So you think I'll have a better result using an ESP32 instead of an Arduino or it's still too slow to accomplish such task? And thanks. I didn't completely understand what the loop rate specified, now I do. 


I guess it depends on what you are looking for as far as accuracy and frequency range. Considering Nyquest Therium basic premise is "the sample rate must be at least twice the bandwidth of the signal avoid aliasing distortion". To get reasonably accurate measurements in say the audio frequency range (20Hz-20KHz) your sampling should be at least 44Khz like a standard audio CD. But then again if you want to do spectral analysis on a signal you need to sample it at a much higher rate. To accurately capture the 10th harmonic of a signal with a 20Khz fundamental frequency, you need to sample at 440Khz minimum.

 

The loop rate is your sample rate because the Arduino is taking one analog sample per loop iteration. This being roughly 100Hz means the highest frequency you can accurately measure is less than 50Hz, even less for spectral analysis. I believe an Arduino programmed in its native language might get up to 200 loops per second, better but still not that good. Programming the Arduinos' Atmel in C might gain you a few more loops per second but not a lot.

 

So to do this "right" you really need a dedicated high-speed DAQ device. I get it, a high speed DAQ is also a high dollar item.

 

I will toss out a couple ideas for you to think about.

 

LabVIEW can use the sound card in your computer as a waveform capture device.

Most modern oscilloscopes have communication options and LabVIEW support.

There are reasonably priced USB oscilloscopes with LabVIEW support   

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 4
(609 Views)