07-07-2020 01:00 PM
@layman93 wrote:
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
In Matlab you are processing the whole array, in LabVIEW you are processing it point-by-point?
From your VI, it appears you are downloading a single point at a time, is this true or are you downloading the data after you have collected 29 seconds worth of data? From your current response, it seems like the latter.
The Matlab plot looks like a power or amplitude spectrum. The plain FFT will give a complex result, you would need to feed this into a magnitude function. From your VI it also looks like you are getting the power spectrum, proportional to the square of the amplitude. Your Matlab plot may be that.
If you are not collecting point by point you are using the wrong VIs. If you are collecting point by point, at a 338 Hz sampling rate, then 100 points (your length) will give you a 3.38 Hz bin size, which would make your 35 Hz signal show up in the 10th bin with some leakage. Your front panel for the power spectrum shows about the 14th bin max, are you sure your frequency is correct?
mcduff
07-07-2020 01:28 PM
Hello Mcduff,
I am downloading data point by point and plotting real time. Yes I am sure the target frequency is around 35 hz since the motor rotates at 2100 rpm.
If you are not collecting point by point you are using the wrong VIs. If you are collecting point by point, at a 338 Hz sampling rate, then 100 points (your length) will give you a 3.38 Hz bin size, which would make your 35 Hz signal show up in the 10th bin with some leakage. Your front panel for the power spectrum shows about the 14th bin max, are you sure your frequency is correct?
Yes this makes more sense now actually, I never understood the concept of frequency bin properly, thank you for explaining.
Is there something wrong with the ptbypt VI's that i am using or the graph inputs?
The aim of the work is to show the data in real time actually without the need of post processing so in that case I am not really looking for pin point accuracy but approximate values.
I attached Matlab code to show the actual frequency peak which I am not able to see in Lab view,
Is there any way to work around this?
layman93
07-07-2020 02:06 PM
Attached is a simulation that you can play with, 2015 Version. It is quick and dirty and probably can be improved.
mcduff
07-07-2020 02:19 PM
Thank you, let me try with this.
layman93
07-07-2020 02:36 PM
@layman93 wrote:
Thank you, let me try with this.
layman93
Clear the charts before starting and put a 100ms wait in the loop, you can see the fft accumulate.
mcduff
07-07-2020 11:47 PM
Hi Layman,
You are almost near to your FFT plot which you want to achieve.
Only thing is you need to set the scale of your waveform graph as shown below:
where 0.03554 is scaling factor which is 1/max(t) i.e. 1/(28.13) and maximum value is the value as
total number of samples*0.03554+1.
Based on your data in CSV file,i got the plot as this:
07-08-2020 02:24 PM
Hello McDuff,
It works now perfectly. Thank you so much for this. Although I do have the last question. The Arduino board sampling rate is not always same it varies highly depending on the frequency I guess. Is there any way to work around it or should I just keep an average sample size for the program and just leave it like that.
07-08-2020 02:27 PM
Hello Sri,
Thanks for the help, yeah I can also work with this.
This has really made it simple :).
07-08-2020 02:48 PM
@layman93 wrote:
Hello McDuff,
It works now perfectly. Thank you so much for this. Although I do have the last question. The Arduino board sampling rate is not always same it varies highly depending on the frequency I guess. Is there any way to work around it or should I just keep an average sample size for the program and just leave it like that.
I believe there are routines that can handle a non-constant sampling rate for a point-by-point analysis. Not sure if they are included with base LabVIEW, there may be a toolkit.
You have options:
You are communicating to Arduino by serial port; this will be imprecise. Your computer has to send the command, Arduino process, then Arduino send response. All of these steps are not deterministic. You can experiment with sampling frequencies to see where things go awry and then try to avoid those regions.
mcduff
07-08-2020 04:53 PM
Yes, Even I thought so too that the sampling rate will be imprecise due to serial communication.
Yeah, I will try to put an interpolating tool or something to fix it.
Thank you so much for your help.
-layman93