miniFOC 1.0.3
This open-source project aims to accomplish a FOC(Field Oriented Control) scheme that is operatable with minimum costs in China.
Functions | Variables
filter.c File Reference

this file contains the code implementation of first-order digital RC low-pass filter algorithm and the code implementation of low-pass filter coefficient calculation. More...

#include "filter.h"
#include "system.h"
#include "foc.h"
#include "config.h"

Go to the source code of this file.

Functions

void filter_coefficient_config (Filter_Structure_t *param, float cutoff_freq, float sample_freq, float coefficient)
 configure low-pass filter parameters More...
 
void filter_config (void)
 configure low-pass filter parameters More...
 
float filter_update_value (Filter_Structure_t *param, short value)
 update the output value of the first-order low-pass filter More...
 

Variables

volatile Filter_Structure_t velocity_filter
 motor rotation speed low pass filter handle More...
 

Detailed Description

this file contains the code implementation of first-order digital RC low-pass filter algorithm and the code implementation of low-pass filter coefficient calculation.

Author
Lao·Zhu
Version
V1.0.2
Date
29. October 2021

Definition in file filter.c.

Function Documentation

◆ filter_coefficient_config()

void filter_coefficient_config ( Filter_Structure_t param,
float  cutoff_freq,
float  sample_freq,
float  coefficient 
)

configure low-pass filter parameters

Parameters
[in]paramfirst order low pass filter parameter handler
[in]cutoff_freqcut off frequency in Hz
[in]sample_freqsample frequency in Hz
[in]coefficientinput data weight, usually is 1

Definition at line 28 of file filter.c.

References Filter_Structure_t::coefficient1, Filter_Structure_t::coefficient2, Filter_Structure_t::current_result, Filter_Structure_t::last_result, and user_memset().

Referenced by filter_config().

◆ filter_config()

void filter_config ( void  )

configure low-pass filter parameters

Definition at line 45 of file filter.c.

References filter_coefficient_config(), SPEED_COEFFICIENT, SPEED_UP_FREQ, TIM13_FREQUENCY, and velocity_filter.

Referenced by main().

◆ filter_update_value()

float filter_update_value ( Filter_Structure_t param,
short  value 
)

update the output value of the first-order low-pass filter

Parameters
[in]paramfirst order low pass filter parameter handler
[in]valuethe sampled value to be filtered at this moment
Return values
currentcalculation results of low-pass filter

Definition at line 56 of file filter.c.

References Filter_Structure_t::coefficient1, Filter_Structure_t::coefficient2, Filter_Structure_t::current_result, and Filter_Structure_t::last_result.

Referenced by encoder_update_speed().

Variable Documentation

◆ velocity_filter

volatile Filter_Structure_t velocity_filter

motor rotation speed low pass filter handle

Definition at line 19 of file filter.c.

Referenced by encoder_update_speed(), and filter_config().