From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

Help with FFT data processing

Solved!
Go to solution

Hello LV experts,

 

I am trying to build a Vibration monitoring system using MPU 6050 Arduino module. I am able to read the data sucessfully from arduno and plot on my labview program.

 

However there are a couple of problems. 

1. When i run the problem the labview reads a certain spike  which i don't see in arduino serial monitor due to which i believe my fft plots shows a peak at he very beginning on low frequency as seen in the graph.

 

layman93_0-1593617788224.png

 

 

2. I have also tried using ptbypt filters and ptbypt spectrum measurements but nothing gives satisfactory value.

 

3. Because of staying at home i don't have any system for which i know the exact values such as max. rpm or anything so that i can verify if the program is giving correct values.

 

4. For now I am just able to visualize the data using different graphs, but I would request if anyone has any better ways or ideas I can implement to make the project more good.

 

I appreciate any help and feedback at this point iof time as I am just stuck at this since a week.

 

-layman93

 

 

 

0 Kudos
Message 1 of 29
(3,831 Views)

That FFT anomaly at 0 Hz is typical of data that contains a significant DC offset.  I'll assume you aren't interested in this DC offset and would like to remove it from your analysis.

 

A super simple way to surpress a fairly constant DC offset is to subtract the average of the dataset from each individual data point before doing your FFT.  I don't think this method would be considered mathematically "pure", but it often helps quite a lot for how simple it is.

 

High pass filtering would be another option and is probably preferable for more of a purist approach.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 29
(3,815 Views)

Hi Kevin,

 

Thanks for replying, you solution explains a lot.

 

Although shouldn't I be using a band pass filter then since the input is from a Arduino which will have electronic noise as well?

 

Also to the Labview Experts is there any better way to visualize it?

 

-layman93

0 Kudos
Message 3 of 29
(3,801 Views)

I know you are addressing LabVIEW Experts, which I assume means those who have sufficient psychic powers that they can visualize the LabVIEW Code (the actual .VI file) that you failed to attach for us non-Experts.  We'll just "guess" at what you are doing and suggest ways to improve it (sight-unseen, but "you get what you pay for").

 

I gather that you do not know much about FFTs, how it works, what "leakage" means, etc.  A typical "power-of-2" FFT has 2^n terms -- two are "special", the "DC" term (which is exactly the arithmetical mean of the data) and the "noise" term (which is "what is left over when you have fit the remaining 2^n-1 terms).  The other terms are pair-wise representations of harmonics of a sine wave whose period is the sampling period, so if you sample for 1 second, the harmonics will be 1 Hz, 2 Hz, 3 Hz, ... 2^(n-1) - 1 Hz.

 

If you are writing LabVIEW code to collect data and do an FFT on it, and you don't understand what you are seeing (and don't understand what you are doing), especially if you don't have "real data" to test, write a (very small) LabVIEW program that generates some data (there are Waveform Generators on the Waveform Palette, or you can simply try making a sine wave, or a square wave, or a triangle wave) and feeding your "signal" into an FFT.  You can "experiment" by doing such things as:

  • See how varying the sampling frequency changes the units of the FFT.
  • See how varying the total sampling time changes the units of the FFT.
  • See how varying the total number of samples (these three tests are different, but related!) changes the units of the FFT.
  • What happens if you add a DC Offset to your signal?  How does that change the FFT?
  • What happens if you add "noise" (like "Sine + random number")?
  • What happens if you apply a digital filter before you run the FFT?

You can learn a lot by doing this, and because you are doing it, it will "stick" with you better than if some "expert" tries to explain it to you (particularly if you can't ask questions and get answers quickly).

 

Bob Schor

Message 4 of 29
(3,787 Views)

Hello Bob,

 

Thank you for your response.

 

Out of all the things you suggested I have tried a few and I did understand how the data changes. Maybe I am not able to communicate properly, my properly. 

 

I have vibrating elements which vibrates at 6 speeds from 2100RPM to 3600RPM.

 

From the simulated signal in Labview I did understand that how my program is supposed to behave. But when i used the sensor to acquire real time in real time, the program gives results in different way. For this i tried using ptbypt Vi's also since it is said that it helps with real time processing.

 

But the result is still the same. I am attaching the VI again to show what I have tried.

 


  • What happens if you add a DC Offset to your signal?  How does that change the FFT?
  • What happens if you apply a digital filter before you run the FFT?

I will try to do these two thanks for the insight.

 

@Bob and other can you help me do it in a better way and also please point out any mistakes or nonsense code if present in it.

 

-Thanks

layman93

0 Kudos
Message 5 of 29
(3,780 Views)

Hello All,

 

I am trying to create a simple LV interface where in I can plot data of vibration acquired using MPU 6050 Sensor using Arduino UNO board in realtime.

 

I am trying to visualize the fft plot but haven't been able to do so as seen in the picture attached. 

 

layman93_0-1594063564524.png

 

The system has a motor running at  2100 rpm for which I expected a peak at 35Hz , but the graph being plotted is no where near that and i don't even understand what scale is it using.

 

Plotting FFT or Power spectrum is important for me to further process the data but I am not able to do it.  Can anyone please explain why is the plot not correct also is there any problem in my LV program. I have attached my Lab view program.

 

Please help.

 

-Thanks

0 Kudos
Message 6 of 29
(3,680 Views)

Can't really tell what's going on in your VI.

 

I think you should try Bob's suggestion and make a simulation.

 

However here are some points to consider:

  1. To detect a 35 Hz frequency, that means you have to sample at 70 Hz minimum. (I would recommend a minimum of 140 Hz sampling rate.) It looks like you are acquiring a point-by-point. 70 Hz sampling implies a 14 ms period, no idea whether an Arduino over a serial port can go at that rate for single point acquisition.
  2. Your frequency resolution will depend on how long you acquire data; for example 1 second of data gives you 1 Hz resolution. I would recommend acquiring data such that your frequency resolution is a multiple of the frequency you want to detect. For example, with 5 Hz resolution, (200 ms acquisition), a 35 Hz signal shouldn't leak too much into other frequency bins.

mcduff

Message 7 of 29
(3,664 Views)

Hello all and McDuff

 

Thank you for your help with which I was able to figure out the technical aspects of my system.

 

I also followed you explanation in this thread

 

Please see attached VI

 

My sampling rate is 338 hz and the frequency of m,y interest range from 35 hz to 60 hz, thus satisfying the Nyquist law.

 

I am trying to sample 10000 data points at a time. with my df being 0.0338 Hz for my acquisition time of 29 secs.

 

But when i try to plot my data the frequency axis is not proper as shown-in capture png.

 

I believe the peak is correct but I am not able to set the frequency resolution properly.

 

I have also attached my Matlab plot which gives out correct peak.

 
 

Can you please help.

 

layman93

 

 

 

 

 
 

 

 

 

 

 

 

 

Download All
0 Kudos
Message 8 of 29
(3,635 Views)

Hi layman93,

Can you please attach the matlab code also so that i can understand what are you trying to achieve?

 

 

Regards,
Srikrishna


0 Kudos
Message 9 of 29
(3,626 Views)

Hello Srikrishna,

 

Here is the code attached and data set.

 

 

Download All
0 Kudos
Message 10 of 29
(3,616 Views)