From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FFT the signal which read from analog pin through Arduino

Solved!
Go to solution

I'm using Arduino to send my signal to Labview. The signal display on the chart pretty good but I could not realize it's spectrum (I'm testing with sine wave Vpp = 1 at 100Hz).

What will I have to do to see the spectrum? I think the signal output (after ADC_Read function) is quite different from others.
I hope someone can help me this problem. Please, I really need your help. It's my final project!!!

Attached is the block diagram and front panel include signal (dont care about the signal had just half above because of ADC_read, this is not my problem) and the spectrum. Problem is I can not understand why the spectrum was that and how to fix it???

 

 

front_panel.JPGblock_diagram.JPG

Message 1 of 36
(7,574 Views)

Hi holucbme,

 

you already got a spectrum - what else do you need?

 

Your signal is NOT a sine wave. It's a only the positive part of sine wave, the negative part being set to zero (aka rectified…): becuase of this you will not get a spectrum with a clear peak at 100Hz, but with several lines at multiples of 100Hz.

 

Additionally you ignored the coercion dot at the FFT function: it expects a waveform signal, but you only provide a 1D array of samples without any timing information. Thus the x axis shows wrong scalings!

 

And last but not least: with a sample rate of 1kHz you met the Nyquist criteria for a 100Hz signal, but you can't expect to get an "accurate" spectrum of your signal…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 36
(7,561 Views)

Thank you for your quick response. But How can I provide the timing information, Can you show me an example, It will be easy for me when I'm new in Labview. Moreover, You mean, To obtain the accuracy higher, I should increase the sampling frequency?

 

Again, thank you so much for analyzing detailly

0 Kudos
Message 3 of 36
(7,553 Views)

Hi holucbme,

 

Can you show me an example

check.png

 

It will be easy for me when I'm new in Labview.

LabVIEW comes with a lot of example VIs! You could study them.

And there are a lot of training resources on NIs website. Many of them are for free!

 

You mean, To obtain the accuracy higher, I should increase the sampling frequency?

In general for FFT these facts stay:

- the higher the sample rate, the higher the max frequency you can analyze

- the more samples (blocksize) you provide for FFT, the higher the frequency resolution

It's up to you to choose parameters to get a result you can live with…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 36
(7,532 Views)

Also notice your waveform chart only shows the positive half of your sinewave?

 

Tha Arduino is clipping off the negitive side.

 

That is because the analog input of an Arduino can only measure voltages from zero to +5 volts

 

You are going to have to use a DC offset to get your entire sinewave on the positive side.

 

Hint: Use the Arduino's 2.5 volt reference

 

One more thing, a sinewve should have very little harmonics (technically a pure sinewave has none) so your spectrum should not show much beyond the fundamental frequency. Try a triangle or square wave.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 36
(7,510 Views)

Thanks GerdW,

 

I used DC offset voltage = 1V, so my signal already is sin wave.

The X axis is done but not accurate (higher a bit 100Hz which I generated). I try to increase the samples to read but not as I expected. Can you show me where problem is?1.JPG2.JPG

Message 6 of 36
(7,492 Views)

Thanks RTSLVU,

 

I also would like to use the ADC 3.3V (Arduino Uno), It's best for increasing resolution of my signal.

I know the arduino had Analog Reference but dont know how to access the firmwave to fix it once arduino connect to labview.

Your response would be appreciated. Thank again

0 Kudos
Message 7 of 36
(7,489 Views)

@holucbme wrote:

Thanks RTSLVU,

 

I also would like to use the ADC 3.3V (Arduino Uno), It's best for increasing resolution of my signal.

I know the arduino had Analog Reference but dont know how to access the firmwave to fix it once arduino connect to labview.

Your response would be appreciated. Thank again


Are you using LabVIEW and Lynx to program your Arduino or the Arduino IDE?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 8 of 36
(7,446 Views)

Hi, RTSLVU

I use Labview interface for Arduino (LIFA). Can I fix the code in the firmware, bro?

Also, Can you show me the problem above? (the FFT was not right at 100Hz)

0 Kudos
Message 9 of 36
(7,440 Views)
Solution
Accepted by topic author lucbk

@holucbme wrote:

Hi, RTSLVU

I use Labview interface for Arduino (LIFA). Can I fix the code in the firmware, bro?

Also, Can you show me the problem above? (the FFT was not right at 100Hz)


I didn't know you guys were related.

 

Connect your waveform chart to the waveform wire after you build in the dT instead of the array of doubles.  It will show the timing info chart rather than just integers on the X axis.

 

Are you sure your input signal is 100 Hz?   Are you sure your Arduino is acquireing at 1 kHz?

Message 10 of 36
(7,435 Views)