# SimpleDSP

SimpleDSP is a basic DSP library which is for Arduino and most of the microcontrollers which can be programmed in C/C++

## Performance:

Here is some examples for its performance. Actually it is not optimized for performance. Its main focuses are portability and education.

### Arduino Nano

• FFT 16 points: 2 ms
• FFT 32 points: 6 ms
• FFT 64 points: 16 ms
• fir filter 10 coefficients: 190 us
• fir filter 23 coefficients: 453 us
• fir filter 46 coefficients: 900 us

10 coefficients FIR filter can be run at 5khz max frequency on an Arduino Nano.

## Arduino Due

• FFT 64 points: 2 ms
• FFT 128 points: 6 ms
• FFT 256 points: 10 ms

## Fast Fourier Transform (FFT) and Inverse Fast Fourier Transform (IFFT)

detailed info

### Arduino Example

FFT and IFFT functions require 2 arguments.
data
data length
Do not forget to add #include "simpleDSP_FFT.h"

Full example for FFT and IFFT please refer here

FFT spectrum example

## FIR Filter

detailed info

### Arduino Example

FIR is filter structure which keep delays and coefficients of filter. There are 2 public functions. firInit initializes the structure according to parameters and makes required memory allocations. Coefficients and its length are given as parameter to this function
Do not forget to add #include "simpleDSP_fir.h"

## IIR Filter

detailed info

### Arduino Example

IIR is filter structure which keep delays and coefficient of filter. There are 2 functions to implement IIR filter using SimpleDSP library. initIIR function is the constructor function for the filter. Filter coefficients for a and b should be given as arguments to this function. After init, filtIIR must be used as filtering function. This function requires 2 arguments. Object instance and data. It returns the filtered output.

Do not forget to add #include "simpleDSP_iir.h" to your code.

IIR Full example

## Octave Test Code

This code create sample data and plot the signal and its FFT. The octave code only needed for testing of function.
Create sample signal which is at 10 kHz sample rate and it is the combination of 3.2 kHz and 800 Hz sine waves.

Calculate and plot x and FFT of x. For fft x axis values are calculated using kor=(1:N)*fo/N;

Output from octave

Graph of Raw Signal

Graph of FFT Signal

you can use octave from here

### Filter Design Using Octave

output of fir functions can be used as filter coefficients

Resource for FIR

Examples:

filter frequency response

Resource for IIR

Outputs after filtering

Time Domain Signal

FFT of Output Signal

Paylaş