RTOS_MSPM0  1.1
ECE445M starter code
Functions
LPF.h File Reference

implements four FIR low-pass filters More...

#include <stdint.h>

Go to the source code of this file.

Functions

uint32_t sqrt2 (uint32_t s)
 square root More...
 
void LPF_Init (int32_t initial, int32_t size)
 Initialize first LPF. More...
 
int32_t LPF_Calc (int32_t newdata)
 FIR low pass filter. More...
 
int32_t Noise1 (void)
 
void LPF_Init2 (int32_t initial, int32_t size)
 Initialize second LPF. More...
 
int32_t LPF_Calc2 (int32_t newdata)
 FIR low pass filter. More...
 
int32_t Noise2 (void)
 
void LPF_Init3 (int32_t initial, int32_t size)
 Initialize third LPF. More...
 
int32_t LPF_Calc3 (int32_t newdata)
 FIR low pass filter. More...
 
int32_t Noise3 (void)
 
void LPF_Init4 (int32_t initial, int32_t size)
 Initialize third LPF. More...
 
int32_t LPF_Calc4 (int32_t newdata)
 FIR low pass filter. More...
 
int32_t Noise4 (void)
 
void LPF_Init5 (int32_t initial, int32_t size)
 Initialize fifth LPF. More...
 
int32_t LPF_Calc5 (int32_t newdata)
 FIR low pass filter. More...
 
int32_t Noise5 (void)
 
void LPF_Init6 (int32_t initial, int32_t size)
 Initialize Sixth LPF. More...
 
int32_t LPF_Calc6 (int32_t newdata)
 FIR low pass filter. More...
 
int32_t Noise6 (void)
 
void LPF_Init7 (int32_t initial, int32_t size)
 Initialize Seventh LPF. More...
 
int32_t LPF_Calc7 (int32_t newdata)
 FIR low pass filter. More...
 
int32_t Noise7 (void)
 
int32_t Median (int32_t newdata)
 Median filter. More...
 
int32_t Median5 (int32_t newdata)
 Median filter. More...
 
int32_t Median7 (int32_t newdata)
 Median filter. More...
 
int32_t Filter (int32_t data)
 60-Hz notch high-Q, IIR filter More...
 

Detailed Description

implements four FIR low-pass filters

Finite length LPF
1) Size is the depth 2 to 16
2) y(n) = (sum(x(n)+x(n-1)+...+x(n-size-1))/size
3) To use a filter
a) initialize it once
b) call the filter at the sampling rate

Version
from TI-RSLK MAX v1.1
Author
Daniel Valvano and Jonathan Valvano
Warning
AS-IS
Note
For more information see http://users.ece.utexas.edu/~valvano/
Date
January 15, 2020

Function Documentation

◆ Filter()

int32_t Filter ( int32_t  data)

60-Hz notch high-Q, IIR filter

60-Hz notch high-Q, alpha=0.99, IIR filter, assuming fs=1000 Hz.
y(n) = (256x(n) -503x(n-1) + 256x(n-2) + 498y(n-1)-251y(n-2))/256 (2k sampling)
y(n) = (256x(n) -476x(n-1) + 256x(n-2) + 471y(n-1)-251y(n-2))/256 (1k sampling)

Parameters
datanew ADC data
Returns
result filter output

◆ LPF_Calc()

int32_t LPF_Calc ( int32_t  newdata)

FIR low pass filter.

First LPF, calculate one filter output
Called at sampling rate

Parameters
newdatanew ADC data
Returns
result filter output

◆ LPF_Calc2()

int32_t LPF_Calc2 ( int32_t  newdata)

FIR low pass filter.

Second LPF, calculate one filter output
Called at sampling rate

Parameters
newdatanew ADC data
Returns
result filter output

◆ LPF_Calc3()

int32_t LPF_Calc3 ( int32_t  newdata)

FIR low pass filter.

Third LPF, calculate one filter output
Called at sampling rate

Parameters
newdatanew ADC data
Returns
result filter output

◆ LPF_Calc4()

int32_t LPF_Calc4 ( int32_t  newdata)

FIR low pass filter.

Fourth LPF, calculate one filter output
Called at sampling rate

Parameters
newdatanew ADC data
Returns
result filter output

◆ LPF_Calc5()

int32_t LPF_Calc5 ( int32_t  newdata)

FIR low pass filter.

fifth LPF, calculate one filter output
Called at sampling rate

Parameters
newdatanew ADC data
Returns
result filter output

◆ LPF_Calc6()

int32_t LPF_Calc6 ( int32_t  newdata)

FIR low pass filter.

Sixth LPF, calculate one filter output
Called at sampling rate

Parameters
newdatanew ADC data
Returns
result filter output

◆ LPF_Calc7()

int32_t LPF_Calc7 ( int32_t  newdata)

FIR low pass filter.

Seventh LPF, calculate one filter output
Called at sampling rate

Parameters
newdatanew ADC data
Returns
result filter output

◆ LPF_Init()

void LPF_Init ( int32_t  initial,
int32_t  size 
)

Initialize first LPF.

Initialize first LPF
Set all data to an initial value

Parameters
initialvalue to preload into MACQ
sizedepth of the filter, 2 to 16
Returns
none

◆ LPF_Init2()

void LPF_Init2 ( int32_t  initial,
int32_t  size 
)

Initialize second LPF.

Initialize second LPF
Set all data to an initial value

Parameters
initialvalue to preload into MACQ
sizedepth of the filter, 2 to 16
Returns
none

◆ LPF_Init3()

void LPF_Init3 ( int32_t  initial,
int32_t  size 
)

Initialize third LPF.

Initialize third LPF
Set all data to an initial value

Parameters
initialvalue to preload into MACQ
sizedepth of the filter, 2 to 16
Returns
none

◆ LPF_Init4()

void LPF_Init4 ( int32_t  initial,
int32_t  size 
)

Initialize third LPF.

Initialize fourth LPF
Set all data to an initial value

Parameters
initialvalue to preload into MACQ
sizedepth of the filter, 2 to 16
Returns
none

◆ LPF_Init5()

void LPF_Init5 ( int32_t  initial,
int32_t  size 
)

Initialize fifth LPF.

Initialize fifth LPF
Set all data to an initial value

Parameters
initialvalue to preload into MACQ
sizedepth of the filter, 2 to 16
Returns
none

◆ LPF_Init6()

void LPF_Init6 ( int32_t  initial,
int32_t  size 
)

Initialize Sixth LPF.

Initialize Sixth LPF
Set all data to an initial value

Parameters
initialvalue to preload into MACQ
sizedepth of the filter, 2 to 16
Returns
none

◆ LPF_Init7()

void LPF_Init7 ( int32_t  initial,
int32_t  size 
)

Initialize Seventh LPF.

Initialize Seventh LPF
Set all data to an initial value

Parameters
initialvalue to preload into MACQ
sizedepth of the filter, 2 to 16
Returns
none

◆ Median()

int32_t Median ( int32_t  newdata)

Median filter.

3-wide non recursive Median filter
Called with new data at sampling rate

Parameters
newdatanew ADC data
Returns
result filter output

◆ Median5()

int32_t Median5 ( int32_t  newdata)

Median filter.

5-wide non recursive Median filter
Called with new data at sampling rate

Parameters
newdatanew ADC data
Returns
result filter output

◆ Median7()

int32_t Median7 ( int32_t  newdata)

Median filter.

7-wide non recursive Median filter
Called with new data at sampling rate

Parameters
newdatanew ADC data
Returns
result filter output

◆ sqrt2()

uint32_t sqrt2 ( uint32_t  s)

square root

Newton's method sqrt

Parameters
sis an integer
Returns
sqrt(s) is an integer