LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FFT of Signal to get Motor Speed, Does it need to be all on FPGA?

I have a motor that I am controlling using FPGA (crio 9054), I am doing other things but right now I just want to be able to read the speed it is rotating at. I have tried various method but the one I am posting, I am using a hall effect sensor to read the rotor angle and this produces a sine wave (with some noise) so I have been trying to use FFT to get the speed. I am calculating the FFT on the "upper" level I am not sure what to call it but its not the FPGA and in the under the crio drop down in the project tree. I do not get the best results doing FFT here and I started to wonder if the fact that I am doing the FFT on this level and not on FPGA it is causing me issues because the loop timing is slower and less consistent on the "upper" level and I am just sending single points from the FPGA level.

I was looking for input on this.  I have attached images of the upper level FFT and then the sub VI in that while loop. The larger code is pretty big and does a dozen other things right now so I didn't you guys to have wade through it.

I have attached the FPGA level code,  the upper most while look is the signal that is feeding the upper level codes in the images. 

 

Possibly unrelated, but that while loop that is in mod4 is with the single input is running at 80uS with a 9201 where as mod3 is also a 9201 but has 2 inputs and filters and is running at 5uS, whats the deal with that? but even then I feel like that sample rate is way more than fast enough to same a 3000rpm (or 50 Hz) signal.

thank you guys, let me know if you want me to upload more things

 

 

0 Kudos
Message 1 of 3
(219 Views)

I used what I found from the "FFT" example and incorporated it into my own code but the time between valid outputs is on the order of 5 seconds which is not the best for something that may change speed every second or so(I had this issue even with the original example un modified). Is there are way to speed that up FFT or a different method to calculate speed on the FPGA. I am just feeding it a pure 50HZ sine wave from a signal generator

I tried this method

https://forums.ni.com/t5/Example-Code/Decoding-Tachometer-Signals-Using-CompactRIO-and-LabVIEW-FPGA/...

which works if I feed it a pure square wave but in my system I will only have a sine wave. So, for that I tried to convert the sine wave to a square wave but that results in an inconsistent time between pulses. I ran the square wave to an AO and then read that signal on an oscilloscope and yeah I can see the noise from the transition from low to high. I am going to try an analog schmitt trigger but I wanted to know if my code could be improved to do it digiitally.

Download All
0 Kudos
Message 2 of 3
(160 Views)

Hi there,

 

Implementing FFTs on LabVIEW FPGA can get a little tricky.  If you have LabVIEW FPGA installed, you can search for this example:

 

<LabVIEW folder>\examples\CompactRIO\FPGA Fundamentals\FPGA Math and Analysis\FFT\FFT.lvproj

 

However, if you are just capturing a sine wave with the NI-9201 module, running the FFT in LabVIEW Real-Time (you refer to this as "upper level") should be more than sufficient.  I would start from a fresh NI-9201 shipping example, and start by acquiring some waveforms in LV Real-Time.  Try this example:

<LabVIEW folder>\examples\CompactRIO\Module Specific\NI 9201\NI 9201 Getting Started\NI 9201 Getting Started.lvproj

 

Once you see your waveform on the front panel, just add a FFT.vi to your Real-Time code.  It will be much simpler than implementing on LV FPGA.

 

BR

John

Add motion to LabVIEW in 30min or less - TENET EMotion
Finding it hard to source legacy NI hardware? Try Extend Test

Message 3 of 3
(124 Views)