Showing results for 
Search instead for 
Did you mean: 

How to fft the myRIO accelorometer readings?

Go to solution

Hello guys,


I'm trying to FFT the internal accelerometer readings of myRIO 1900, to study the spectrum in frequency domain.

I'm kinda new to this so I dunno how to do it but here's what I know ( but I still don't know how to do it ).

* I need to take samples with a certain sampling rate from the myrio Z axis for example.

* Storing these samples in an array.

* FFTing the array of samples.

* Loop to update the values.


I am also trying to achieve a figure that's very near to that if I connected a simulate signal with FFT then a graph to have an output like this.



Anyway, here is the project I am working with.



And here is the meaning less graph I get.



Please help me to achieve what I am failing to.

Thanks in advance.

0 Kudos
Message 1 of 8

You have two things that are important for the FFT to give you a meaningful result: the samples and the sample rate.


When you pull the data from the accelerometer, you're pulling a single data point.  This isn't an array of points. It's a single point.  The FFT wouldn't make much sense here.  You'll first want to build an array of points and then work with that.  When you do have that array, you can't extract frequency data without having the sample rate included.  You'll want to build a waveform to pass into the express VI that includes the dt value so you can let it know how fast you're sampling.  Alternatively, you can use one of the non-express FFT VIs and give it the sample rate.

Message 2 of 8

Thanks for the reply.


Well I now understand that I should have a certain block that takes samples and saves it in an array with a certain sampling rate, Then this block's output should be passed to another block that converts these samples to a waveform passing the waveform to FFT then graph?

If that's right, If you please to tell me how that could be acheived, I'd be more than thankful.

0 Kudos
Message 3 of 8
Accepted by topic author Michel66



You may want to try something like this:




This code will take 100 samples per while loop cycle at a sampling rate of 1000 Hz (1/loop period, loop period = 1 ms), format the data into a waveform and send that waveform to the spectral measurements VI. 


Quick edit: Attached VI

Product Support Engineer
National Instruments
Message 4 of 8

Thank you so much @yea_likethecity for your reply.


This was exactly what I was looking for.



0 Kudos
Message 5 of 8

How can it be adjusted for higher sampling rate? myRIO seems to be poor for this. I was hoping that the FPGA core would make it incredible.

0 Kudos
Message 6 of 8

This seems to be unrelated to the original topic. You might have better luck if you make a new thread.

0 Kudos
Message 7 of 8

@mbriago wrote:

How can it be adjusted for higher sampling rate? myRIO seems to be poor for this. I was hoping that the FPGA core would make it incredible.

I may have misunderstood your question... are you asking how to get a speedup by running the solution VI on your FPGA?

From the looks of it, the VI above isn't necessarily set up to run on an FPGA so a post more along the lines of "How do I adjust this VI to run on an FPGA" might get you better results.

I see that you have another post asking about FFT Acquisition and Sampling Rates. If this is the code you are trying to run on your FPGA, I'd link this post there!


0 Kudos
Message 8 of 8