33 float time_const = 1.0f / (6.2831852f * cutoff_freq);
36 param->
coefficient1 = (1.0f / (1.0f + time_const * sample_freq)) * coefficient;
37 param->
coefficient2 = (time_const * sample_freq) / (1.0f + time_const * sample_freq);
59 if (value < 200 && value > -200)
used to place important parameter configurations for users
#define SPEED_UP_FREQ
set speed update frequency to 200Hz
#define TIM13_FREQUENCY
set speed/angle PID loop frequency to 100Hz
void filter_coefficient_config(Filter_Structure_t *param, float cutoff_freq, float sample_freq, float coefficient)
configure low-pass filter parameters
float filter_update_value(Filter_Structure_t *param, short value)
update the output value of the first-order low-pass filter
volatile Filter_Structure_t velocity_filter
motor rotation speed low pass filter handle
void filter_config(void)
configure low-pass filter parameters
this is the header file of filter.c, which defines the structure of filter algorithm.
this is the header file of foc.c, which defines the structure of FOC algorithm and angle conversion f...
#define SPEED_COEFFICIENT
mechanical rotate speed conversion factor
structure of low-pass filter algorithm
float coefficient2
low-pass filter coefficient 2
float last_result
previous calculation results of low-pass filter
float current_result
current calculation results of low-pass filter
float coefficient1
low-pass filter coefficient 1
void user_memset(void *buf, unsigned char data, unsigned char num)
format buffer array to fixed value, replace memset function
system basic function header file