![]() |
ADS_BP
|
#include "process.h"
Functions | |
float32_t | FilterHP (float32_t inData, unsigned char ch, uint32_t frequency) |
It filters a new sample applying a IIR high-pass filter in real time. More... | |
float32_t | FilterNOTCH (float32_t inData, unsigned char ch, uint32_t frequency) |
It filters a new sample applying a IIR notch filter in real time. More... | |
void | ResetFilterArrays (unsigned char nCh) |
Needed to reset the history of the filters and delete the previous states. More... | |
float32_t | FilterSample (float32_t inData, unsigned char filterIndex) |
It calls the routines for filtering a new sample. More... | |
void | UARTReceive4Bytes (uint32_t *ptr) |
This function can be used to easily handle the reception on the UART of 4bytes sized variables, e. g. float. More... | |
void | UARTSend4Bytes (unsigned char *ptr) |
This function can be used to easily handle the transmit on the UART of 4bytes sized variables, e. g. float. More... | |
void | UARTSend2Bytes (unsigned char *ptr) |
This function can be used to easily handle the transmit on the UART of 4bytes sized variables, e. g. int16. More... | |
void | UARTSendByte (unsigned char byte) |
This function can be used to easily handle the transmission on the UART of one byte. It is meant for the application of flow control. More... | |
Source file of process module of the NEUROMOTUS project.
----------------— Function Description ---------------— The process.c file contains all routines needed to properly process the EMG signals acquired from the ADS1299. It includes also helpful routines for communication.
----------------------— Updates ----------------------—
2015-10-01 / Enzo Mastinu / Creation
float32_t FilterHP | ( | float32_t | inData, |
unsigned char | ch, | ||
uint32_t | frequency | ||
) |
It filters a new sample applying a IIR high-pass filter in real time.
[in] | inData | float input value |
[in] | ch | index of the channel |
[in] | frequency | is the sampling frequency |
Butterworth HP 2nd order @ 20Hz IIR Filter this function takes a float input and applies a real time filter process. The filter needs information about the previous states of input and output values, they are stored into xv[order+1][nChannels] and yv[order+1][nChannels] global arrays. The filters used are IIR:
from current input, past inputs and past outputs we generate the current value. In FIR you use only the current and past inputs. IIR parameters are calculated via Matlab: Fc = x; Wn = 20 / (Fc/2); Order = 2; [num den] = butter(Order, Wn, 'high'); we normalize the coefficients num = num/num(1) den = den/den(1) then, the coefficients the multiply the inputs are x0 * num(1), x1 * num(2), x2 * num(3) while for the outputs is y2 * den(1), y1 * den(2), y0 * den(3)
Measured Execution Time @80MHz: 13/07/2016 -> 1.31 us
float32_t FilterNOTCH | ( | float32_t | inData, |
unsigned char | ch, | ||
uint32_t | frequency | ||
) |
It filters a new sample applying a IIR notch filter in real time.
[in] | inData | float input value |
[in] | ch | index of the channel |
[in] | frequency | is the sampling frequency |
Butterworth NOTCH 1st order @ 45-55 Hz IIR Filter this function takes a float input and applies a real time filter process. The filter needs information about the previous states of input and output values, they are stored into xvN[order+1][nChannels] and yvN[order+1][nChannels] global arrays. IIR parameters are calculated via Matlab: Fc = x; W0 = 50 / (Fc/2); Q = 35; Bw = W0/Q; [num den] = iirnotch(W0, Bw); we normalize the coefficients num = num/num(1) den = den/den(1) then, the coefficients the multiply the inputs are x0 * num(1), x1 * num(2), x2 * num(3) while for the outputs is y2 * den(1), y1 * den(2), y0 * den(3)
Measured Execution Time @80MHz: 13/07/2016 -> 1.38 us
float32_t FilterSample | ( | float32_t | inData, |
unsigned char | filterIndex | ||
) |
It calls the routines for filtering a new sample.
[in] | inData | float input value |
[in] | filterIndex | index of the channel which the sample belongs |
This function contains the routines needed to apply digital filters to the data in a on-fly technique. This means that the latest acquired sample is passed through the filters and the filtered version is returned by this function.
Measured Execution Time @80MHz: 13/07/2016 -> 3 us
void ResetFilterArrays | ( | unsigned char | nCh | ) |
Needed to reset the history of the filters and delete the previous states.
[in] | nCh | number of channels |
Measured Execution Time @80MHz: 13/07/2016 -> 16 us
void UARTReceive4Bytes | ( | uint32_t * | ptr | ) |
This function can be used to easily handle the reception on the UART of 4bytes sized variables, e. g. float.
[in] | *ptr | points the variable to receive |
void UARTSend2Bytes | ( | unsigned char * | ptr | ) |
This function can be used to easily handle the transmit on the UART of 4bytes sized variables, e. g. int16.
[in] | *ptr | points the variable to send |
void UARTSend4Bytes | ( | unsigned char * | ptr | ) |
This function can be used to easily handle the transmit on the UART of 4bytes sized variables, e. g. float.
[in] | *ptr | points the variable to send |
void UARTSendByte | ( | unsigned char | byte | ) |
This function can be used to easily handle the transmission on the UART of one byte. It is meant for the application of flow control.
[in] | byte | to send |