ADS_BP
Macros | Functions | Variables
process.c File Reference
#include "process.h"
Include dependency graph for process.c:

Macros

#define NZEROS   2
 
#define NPOLES   2
 
#define GAIN_HP_2000   1.092933031f
 
#define GAIN_N_2000   1.002243999f
 
#define GAIN_HP_1000   1.045431062f
 
#define GAIN_N_1000   1.004488020f
 
#define GAIN_HP_500   1.194615832f
 
#define GAIN_N_500   1.008976220f
 

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...
 

Variables

const float32_t lsbVolt = 0.000000536442f
 
float32_t xv [NZEROS+1][8]
 
float32_t yv [NZEROS+1][8]
 
float32_t xvN [NPOLES+1][8]
 
float32_t yvN [NPOLES+1][8]
 
volatile unsigned char nChannels = 8
 
volatile unsigned char filterEnable = 1
 
volatile float32_t temperatureMCU = 0
 
volatile float32_t batteryVoltage = 0
 
volatile float32_t batteryTemperature = 0
 
volatile uint32_t sF
 

Detailed Description

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

Function Documentation

§ FilterHP()

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.

Parameters
[in]inDatafloat input value
[in]chindex of the channel
[in]frequencyis the sampling frequency
Returns
float filtered value.

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

§ FilterNOTCH()

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.

Parameters
[in]inDatafloat input value
[in]chindex of the channel
[in]frequencyis the sampling frequency
Returns
float filtered value.

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

§ FilterSample()

float32_t FilterSample ( float32_t  inData,
unsigned char  filterIndex 
)

It calls the routines for filtering a new sample.

Parameters
[in]inDatafloat input value
[in]filterIndexindex of the channel which the sample belongs
Returns
float output value.

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

§ ResetFilterArrays()

void ResetFilterArrays ( unsigned char  nCh)

Needed to reset the history of the filters and delete the previous states.

Parameters
[in]nChnumber of channels
Returns
none.

Measured Execution Time @80MHz: 13/07/2016 -> 16 us

§ UARTReceive4Bytes()

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.

Parameters
[in]*ptrpoints the variable to receive
Returns
none.

§ UARTSend2Bytes()

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.

Parameters
[in]*ptrpoints the variable to send
Returns
none.
Here is the call graph for this function:

§ UARTSend4Bytes()

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.

Parameters
[in]*ptrpoints the variable to send
Returns
none.
Here is the call graph for this function:

§ UARTSendByte()

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.

Parameters
[in]byteto send
Returns
none.
Here is the caller graph for this function: