11-21-2023 11:14 AM
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)?
11-21-2023 11:45 AM - edited 11-21-2023 12:02 PM
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.
11-21-2023 07:35 PM
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.
11-22-2023 10:00 AM - edited 11-22-2023 10:08 AM
@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