Need help with FFT of sensor data

Hello.
For my thesis, I am required to analyse one of the five links of 5 DOF robotic arm. The said link has also been designed in solidworks and was imported in Ansys software to find first 4 natural frequencies/mode shapes through Finite Element Analysis (FEA). The natural frequencies are as follows :
  • 0.05934
  • 188.22
  • 476.19
  • 558.74
Ansys also provides the Displacement Time data which can be exported for further analysis. I am currently trying to obtain a magnitude - frequency graph through FFT to find the natural frequencies of the link through exported data.
My understanding is, if I can recreate the natural frequencies given by Ansys through my MATLAB program, I will be able to find acceptable natural frequencies of any link by aquiring acceleration time data through sensors. But in order to do that, I need a program that finds close to accurate natural frequencies through FFT.
I have made/replicated a program, which is attached, by researching online. However, I am obtaining peaks at incorrect frequencies. Furthermore, my plot does not cover all the frequencies on the X-Axis as well.
Summary : I want to make a program that can give me a Magnitude Frequency graph through FFT for a link of a 5 DOF robotic arm. I want to recreate the results comparable or similar to precalculated and correct values of natural frequencies through my program. However, the results through my program are incorrect.
I am sure I must be doing something wrong but I cannot seem to figure it out.
Would appreciate any and all help.
Cheers.
X=readmatrix('accl.xlsx') %importing data
fs=20; % sampling frequency
L=138; % length of signal
nfft=2^nextpow2(L); % next power of 2 from length of freq signal
f=(fs/2)*linspace(0,1,nfft/2+1);
timefft = fft(X(:,2),nfft)/L;% frf of displacement
fre=2*abs(timefft(1:nfft/2+1));% frf of displacement
figure(1),plot(f,fre); grid on % fig A
% Natural frequencies without any scale adjustment
frf=fft(X(:,2));
figure(2),plot((abs(frf))); % fig B

12 Comments

Hi Huzaifah,
If the list of expected frequencies is in Hz, then you are attempting to resolve a waveform at several hundred Hz using a sampling rate of 20 Hz, which is not possible. Is the list not in Hz?
Thank you for your response. Yes, the frequencies are in Hz, indeed. I was under the impression that I need to plug 'fs' in my program with the frequency based on the data. The data that I extracted was from a resolved model in ansys for mode shapes. Based on the data, I believe the frequency is 20 Hz. Should it not be the case that 'fs' is the sampling rate of the data?
Pardon my lack of knowledge on the topic of signal/frequency analysis and feel free to enlighten me.
fs is he sampling rate of your data but the point is you cannot see a natural frequency of 188 Hz using a data sampled at 20 Hz. The information is lost. You can only see up-to 10 Hz frequencies (can be more with some interesting techniques) when you have a data sampled at 20 Hz. Check Nyquist-Shannon sampling theorem if you want to understand more.
Generally, you want to sample 10 times faster than the frequency components you want to see in a signal. For instance if you want to capture 100 Hz dynamics, you should use 1 kHz sampling rate etc.
Ah, understood. That makes so much sense.
I do wonder though, how Ansys calculated the natural frequencies till 560hz with a 20 sampling rate. Do let me know if you have any ideas regarding that.
And moving forward, due to the low sampling rate, is there no way I can achieve the expected frequencies with a 20 Hz sampling rate? I guess just setting it to 1 Khz in the code would yield incorrect results too since the data will always be sampled at 20 Hz regardless. I see no difference in peaks or any new peaks while doing so.
I am open to ideas and certainly appreciate your help.
There is no sampling in Ansys, you probably are using harmonic analysis. What you should be doing is modal and experimental modal analysis. Please read more about it, since there is a lot to write about.
First of all, what is this accelerometer data you mentioned in your question. How did you obtain it? If you are just acquiring data while the robot arm is moving while doing it's job, that is definitely not the way to obtain the natural frequencies. If this is an impulse response of the structure in the time domain, there is something wrong with it, you should have kept recording the signal to capture the complete response until it (almost) decays. Also, your you say you show displacement FRFs, but your file says accel. There was no integration anywhere in the code, and for FRF, you need to also have the input signal. So, what you are showing is just the acceleration in the frequency domain.
Sincere apology for my unstructured and rough comment, I just think you have to start slow in this topic.
Hello @Mario,
Thankyou for taking out time to respond. I have actually conducted modal analysis in Ansys. The natural frequencies and the data I am using for MATLAB is exported from Ansys after modal analysis. I must emphasize that this data is not from harmonic analysis. Please do let me know more about how Ansys calculates the natural frequencies, if you are educated on it, and why the exported displacement time data cannot be used to recalculate the expected frequencies. I will certainly appreciate it and it might help me in identifying if what I am after is fundamentally wrong.
Moving on, as mentioned in my post, this data is not from any sensor. You can ignore the name "accel", as it is just Ansys exported data. I have some acceleration data acquired and when I was trying to calculate natural frequencies from that data, I could tell straight away that the results are incorrect.
Hence, I have made this post so I can fix any fault there is in my approach/code and recreate the Ansys natural frequencies from the exported data. I believe if I can do that, sensor data will give better results too and I will be assured that its not my program I need to worry about incase of wrong results.
Again, feel free to correct me and recommend any measures to achieve what I aim to.
If I understand correctly you have time domain data from a simulation (Ansys). My advice: Re-run the simulation and force a constant (!) sample rate of about 0.0002s (instead more or less 0.05s). With the result you can perform a fft easily.
Mario Malic
Mario Malic on 12 Jun 2024
Edited: Mario Malic on 12 Jun 2024
Please do let me know more about how Ansys calculates the natural frequencies - You are free to look for this information on your own. ANSYS has a nice tutorial that I saw if you search for ANSYS modal analysis.
Why the exported displacement time data cannot be used to recalculate the expected frequencies?
If you think about your structure, it can be complex or simple - it doesn't matter. Take first form of vibration (not the rigid body mode), for example - how can you tell where to take the displacement from? If you take the displacement from one point only, and you see it's peak in frequency domain on the frequency of the first mode, it is not a sign that it is the first mode. What if you choose the point which is an anti-node, you won't see the peak at all.
So, you have to obtain data (read below) from multiple points, overlay them and find frequencies where most peaks coincide. So, you have to carefully choose multiple points on the structure.
What is this data that I am speaking about? FRFs are OUTPUT/INPUT ratio in the frequency domain. To excite the structure, you typically would use an impact hammer (impulse excitation), or shaker (random excitation) which is INPUT, and measure the response at different points which is OUTPUT. To display mode shapes, you do that by overlaying imaginary component of all FRFs. Then you will see the curves peaking (not all of them, and this is normal) at the specific frequencies.
As I am writing this now, I realised, that you probably have to do a random excitation on your model in ANSYS to obtain the response. However, I am not sure what type of analysis you should be doing, my thought is that you do a static one with such excitation.
I believe if I can do that, sensor data will give better results too and I will be assured that its not my program I need to worry about incase of wrong results.
If you have done your experiment correctly, then it's always your model that needs to be fixed.
Hope this helps, good luck with your work!
Aquatris
Aquatris on 12 Jun 2024
Edited: Aquatris on 12 Jun 2024
Ansys can find the natural frequencies from the physical properties of the parts, mass stiffness inertia height width lengths etc. So when you have a part in ansys, you define the material properties. Those material properties are then used along with the geometry information to find the natural frequencies.
Here are a few suggestions:
  • Make sure your sampling rate is constant
  • Make sure your sampling rate is at least 5 kHz
  • Make sure the excitation you apply to the system has enough frequency content (if you apply an excitation force that is a single sine wave, e.g., sin(30*time), then you will only see a single peak at 30 in your fft.) So impulse force might work best for you due to its simplicity.
@Aquatris Thank you so much for such a detailed and helpful response and apologies for not replying sooner.
I am not well versed when it comes to frequency analysis or DSP in general, and your publications definitely helped my concepts.
In the context of MATLAB, and my experiment, it is my understanding now that the data I collect through the sensors should also have some excitation element on the structure? I was initially planning on recording the data while the robot was doing some preset movements. Can I introduce the excitation through MATLAB while calculating FFT or will it require some physical form of it on the actual structure? I would just like to highlight that I do not have the robot modelled in MATLAB, I plan on using the accelerometer data only.
Thank you.
The excitation needs to be physical on the structure.
As long as your trajectory has the desired frequency content you do not need an additional excitation.
You cannot follow an arbitrary trajectory and assume it will give you all the information. You should design the trajectory carefully. There are different methods to find the 'optimal trajcetory' to be used in robot identification, most of which involve solving some form of optimization problem and might be advanced for you if you are not familiar with it. So you might consider manually designing a trajectory that has the frequency content you want without hitting the motion limits.

Sign in to comment.

Answers (0)

Asked:

on 11 Jun 2024

Commented:

on 17 Jun 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!