arduinoFFT/README.md

82 wiersze
3.3 KiB
Markdown
Czysty Zwykły widok Historia

2014-07-20 00:55:27 +00:00
arduinoFFT
==========
# Fast Fourier Transform for Arduino
2014-07-20 01:01:14 +00:00
This is a fork from https://code.google.com/p/makefurt/ which has been abandoned since 2011.
~~This is a C++ library for Arduino for computing FFT.~~ Now it works both on Arduino and C projects.
Tested on Arduino 1.6.11 and 1.8.10.
2014-07-20 01:08:55 +00:00
## Installation on Arduino
2014-07-20 01:08:55 +00:00
Use the Arduino Library Manager to install and keep it updated. Just look for arduinoFFT. Only for Arduino 1.5+
## Manual installation on Arduino
2014-07-20 01:08:55 +00:00
To install this library, just place this entire folder as a subfolder in your Arduino installation. When installed, this library should look like:
2014-07-20 01:08:55 +00:00
`Arduino\libraries\arduinoFTT` (this library's folder)
`Arduino\libraries\arduinoFTT\arduinoFTT.h` (the library header file, uses 32 bit floats or 64bit doubles)
`Arduino\libraries\arduinoFTT\keywords.txt` (the syntax coloring file)
`Arduino\libraries\arduinoFTT\examples` (the examples in the "open" menu)
`Arduino\libraries\arduinoFTT\LICENSE` (GPL license file)
`Arduino\libraries\arduinoFTT\README.md` (this file)
2014-07-20 01:08:55 +00:00
## Building on Arduino
2014-07-20 01:08:55 +00:00
After this library is installed, you just have to start the Arduino application.
You may see a few warning messages as it's built.
To use this library in a sketch, go to the Sketch | Import Library menu and
select arduinoFTT. This will add a corresponding line to the top of your sketch:
2014-07-30 14:41:55 +00:00
`#include <arduinoFTT.h>`
2014-11-09 08:03:01 +00:00
## TODO
2017-04-25 20:26:25 +00:00
* Ratio table for windowing function.
* Document windowing functions advantages and disadvantages.
* Optimize usage and arguments.
* Add new windowing functions.
* ~~Spectrum table?~~
## API
* **ArduinoFFT**(T *vReal, T *vImag, uint_fast16_t samples, T samplingFrequency, T * weighingFactors = nullptr);
Constructor.
The type `T` can be `float` or `double`. `vReal` and `vImag` are pointers to arrays of real and imaginary data and have to be allocated outside of ArduinoFFT. `samples` is the number of samples in `vReal` and `vImag` and `weighingFactors` (if specified). `samplingFrequency` is the sample frequency of the data. `weighingFactors` can optionally be specified to cache weighing factors for the windowing function. This speeds up repeated calls to **windowing()** significantly.
* **~ArduinoFFT**(void);
Destructor.
* **complexToMagnitude**();
Convert complex values to their magnitude and store in vReal.
* **compute**(FFTDirection dir);
2017-04-26 13:46:41 +00:00
Calcuates the Fast Fourier Transform.
* **dcRemoval**();
2018-11-24 10:42:59 +00:00
Removes the DC component from the sample data.
* **majorPeak**();
Looks for and returns the frequency of the biggest spike in the analyzed signal.
* **revision**();
2017-04-26 13:46:41 +00:00
Returns the library revision.
* **windowing**(FFTWindow windowType, FFTDirection dir);
2017-04-26 13:46:41 +00:00
Performs a windowing function on the values array. The possible windowing options are:
* Rectangle
* Hamming
* Hann
* Triangle
* Nuttall
* Blackman
* Blackman_Nuttall
* Blackman_Harris
* Flat_top
* Welch
## Special flags
You can define these before including arduinoFFT.h:
* #define FFT_SPEED_OVER_PRECISION
Define this to use reciprocal multiplication for division and some more speedups that might decrease precision.
* #define FFT_SQRT_APPROXIMATION
Define this to use a low-precision square root approximation instead of the regular sqrt() call. This might only work for specific use cases, but is significantly faster. Only works if `T == float`.