7 #ifndef HPM_MCL_ENCODER_H
8 #define HPM_MCL_ENCODER_H
70 #define MCL_ENCODER_CAL_STRUCT_MAX_MEMMORY (16)
#define MAKE_STATUS(group, code)
Definition: hpm_common.h:135
@ mcl_group_encoder
Definition: hpm_mcl_common.h:20
uint32_t hpm_mcl_stat_t
Definition: hpm_mcl_common.h:15
hpm_mcl_stat_t hpm_mcl_encoder_start_sample(mcl_encoder_t *encoder)
Encoder starts sampling.
Definition: hpm_mcl_encoder.c:64
hpm_mcl_stat_t hpm_mcl_encoder_init(mcl_encoder_t *encoder, mcl_cfg_t *mcl_cfg, mcl_encoer_cfg_t *encoder_cfg, mcl_filter_iir_df1_t *iir)
Initialize encoder data.
Definition: hpm_mcl_encoder.c:11
@ mcl_encoder_get_theta_error
Definition: hpm_mcl_encoder.h:16
@ mcl_encoder_get_tick_error
Definition: hpm_mcl_encoder.h:14
@ mcl_encoder_not_ready
Definition: hpm_mcl_encoder.h:17
@ mcl_encoder_get_uvw_error
Definition: hpm_mcl_encoder.h:18
@ mcl_encoder_update_tick_error
Definition: hpm_mcl_encoder.h:15
@ mcl_encoder_start_sample_error
Definition: hpm_mcl_encoder.h:13
float hpm_mcl_encoder_get_theta(mcl_encoder_t *encoder)
Get the encoder angle value.
Definition: hpm_mcl_encoder.c:216
hpm_mcl_stat_t hpm_mcl_encoder_set_initial_theta(mcl_encoder_t *encoder, float theta)
Sets the initial value of the angle. Normally, the programme does the initial value setting automatic...
Definition: hpm_mcl_encoder.c:79
float hpm_mcl_encoder_get_forecast_theta(mcl_encoder_t *encoder)
Get the angle predicted from the speed.
Definition: hpm_mcl_encoder.c:235
hpm_mcl_stat_t hpm_mcl_encoder_get_uvw_status(mcl_encoder_t *encoder, mcl_encoder_uvw_level_t *level)
Get level status of uvw.
Definition: hpm_mcl_encoder.c:246
hpm_mcl_stat_t hpm_mcl_encoder_process(mcl_encoder_t *encoder, uint32_t tick_deta)
Encoder processing, cycle call.
Definition: hpm_mcl_encoder.c:87
float hpm_mcl_encoder_get_speed(mcl_encoder_t *encoder)
Get speed.
Definition: hpm_mcl_encoder.c:230
void hpm_mcl_encoder_force_theta(mcl_encoder_t *encoder, float theta, bool enable)
Force setting of the output angle of the encoder function.
Definition: hpm_mcl_encoder.c:201
struct mcl_encoder_callback mcl_encoder_callback_t
callback function
#define MCL_ENCODER_CAL_STRUCT_MAX_MEMMORY
Maximum memory required for computational speed, word.
Definition: hpm_mcl_encoder.h:70
mcl_encoder_status_t
Definition: hpm_mcl_encoder.h:21
@ encoder_status_run
Definition: hpm_mcl_encoder.h:24
@ encoder_status_fail
Definition: hpm_mcl_encoder.h:25
@ encoder_status_null
Definition: hpm_mcl_encoder.h:22
@ encoder_status_init
Definition: hpm_mcl_encoder.h:23
hpm_mcl_stat_t hpm_mcl_encoder_get_absolute_theta(mcl_encoder_t *encoder, float *theta)
Get the absolute position of the angle.
Definition: hpm_mcl_encoder.c:240
mcl_encoder_cal_speed_function_t
Method of calculating speed.
Definition: hpm_mcl_encoder.h:32
@ encoder_method_m
Definition: hpm_mcl_encoder.h:34
@ encoder_method_pll
Definition: hpm_mcl_encoder.h:36
@ encoder_method_t
Definition: hpm_mcl_encoder.h:33
@ encoder_method_user
Definition: hpm_mcl_encoder.h:37
@ encoder_method_m_t
Definition: hpm_mcl_encoder.h:35
float hpm_mcl_encoder_get_sensorless_theta(mcl_encoder_t *encoder)
Get sensorless theta.
Definition: hpm_mcl_encoder.c:225
float hpm_mcl_encoder_get_raw_theta(mcl_encoder_t *encoder)
Getting the raw angle data of the encoder.
Definition: hpm_mcl_encoder.c:207
hpm_mcl_stat_t hpm_mcl_encoder_set_status(mcl_encoder_t *encoder, mcl_encoder_status_t status)
Force update of encoder status.
Definition: hpm_mcl_encoder.c:194
hall_phase_t
The mounting angle of the Hall sensor, 60 degrees or 120 degrees, is an inherent property of the moto...
Definition: hpm_mcl_physical.h:18
Definition: hpm_mcl_common.h:238
Definition: hpm_mcl_encoder.h:77
float theta_last
Definition: hpm_mcl_encoder.h:78
float ts_sigma
Definition: hpm_mcl_encoder.h:79
Definition: hpm_mcl_encoder.h:82
float speed_last
Definition: hpm_mcl_encoder.h:87
float ts_sigma
Definition: hpm_mcl_encoder.h:84
float speed_filter_last
Definition: hpm_mcl_encoder.h:86
float theta_last
Definition: hpm_mcl_encoder.h:83
float theta_sigma
Definition: hpm_mcl_encoder.h:85
pll filter configuration
Definition: hpm_mcl_encoder.h:94
float kp
Definition: hpm_mcl_encoder.h:95
float ki
Definition: hpm_mcl_encoder.h:96
Running data for the pll method of calculating speed.
Definition: hpm_mcl_encoder.h:103
float omega_integrator
Definition: hpm_mcl_encoder.h:107
float theta_last
Definition: hpm_mcl_encoder.h:108
mcl_encoder_cal_speed_pll_cfg_t * cfg
Definition: hpm_mcl_encoder.h:104
float * period_call_time_s
Definition: hpm_mcl_encoder.h:105
float pi_integrator
Definition: hpm_mcl_encoder.h:106
Definition: hpm_mcl_encoder.h:71
float ts_sigma
Definition: hpm_mcl_encoder.h:74
float theta_last
Definition: hpm_mcl_encoder.h:72
float speed_last
Definition: hpm_mcl_encoder.h:73
callback function
Definition: hpm_mcl_encoder.h:55
hpm_mcl_stat_t(* start_sample)(void)
Definition: hpm_mcl_encoder.h:59
_FUNC_OPTIONAL_ hpm_mcl_stat_t(* update_trig_lead_tick)(uint32_t lead_tick)
Definition: hpm_mcl_encoder.h:57
hpm_mcl_stat_t(* get_theta)(float *theta)
Definition: hpm_mcl_encoder.h:60
_FUNC_OPTIONAL_ hpm_mcl_stat_t(* get_lead_tick)(uint32_t *lead_tick)
Definition: hpm_mcl_encoder.h:58
_FUNC_OPTIONAL_ hpm_mcl_stat_t(* get_uvw_level)(mcl_encoder_uvw_level_t *level)
Definition: hpm_mcl_encoder.h:62
hpm_mcl_stat_t(* init)(void)
Definition: hpm_mcl_encoder.h:56
_FUNC_OPTIONAL_ hpm_mcl_stat_t(* process_by_user)(float theta, float *speed, float *theta_forecast)
Definition: hpm_mcl_encoder.h:63
_FUNC_OPTIONAL_ hpm_mcl_stat_t(* get_absolute_theta)(float *theta)
Definition: hpm_mcl_encoder.h:61
Encoder operation data.
Definition: hpm_mcl_encoder.h:132
mcl_filter_iir_df1_t * iirfilter
Definition: hpm_mcl_encoder.h:140
float theta_forecast
Definition: hpm_mcl_encoder.h:152
mcl_user_value_t force_set_theta
Definition: hpm_mcl_encoder.h:148
mcl_encoder_cal_speed_t_function_t t_method
Definition: hpm_mcl_encoder.h:134
mcl_encoder_cal_speed_m_function_t m_method
Definition: hpm_mcl_encoder.h:135
mcl_encoer_cfg_t * cfg
Definition: hpm_mcl_encoder.h:142
float theta_initial
Definition: hpm_mcl_encoder.h:146
bool * enable
Definition: hpm_mcl_encoder.h:155
float * theta
Definition: hpm_mcl_encoder.h:156
mcl_encoder_status_t status
Definition: hpm_mcl_encoder.h:141
float speed
Definition: hpm_mcl_encoder.h:150
float theta
Definition: hpm_mcl_encoder.h:151
int32_t * mcu_clock_tick
Definition: hpm_mcl_encoder.h:143
mcl_encoder_cal_speed_m_t_function_t m_t_method
Definition: hpm_mcl_encoder.h:136
hall_phase_t * phase
Definition: hpm_mcl_encoder.h:145
int32_t * pole_num
Definition: hpm_mcl_encoder.h:144
mcl_encoder_cal_speed_pll_function_t pll_method
Definition: hpm_mcl_encoder.h:137
float * current_loop_ts
Definition: hpm_mcl_encoder.h:147
uvw level 0 or 1
Definition: hpm_mcl_encoder.h:45
bool u
Definition: hpm_mcl_encoder.h:46
bool v
Definition: hpm_mcl_encoder.h:47
bool w
Definition: hpm_mcl_encoder.h:48
Encoder Configuration.
Definition: hpm_mcl_encoder.h:115
uint64_t communication_interval_us
Definition: hpm_mcl_encoder.h:117
float period_call_time_s
Definition: hpm_mcl_encoder.h:123
mcl_encoder_callback_t callback
Definition: hpm_mcl_encoder.h:124
float timeout_s
Definition: hpm_mcl_encoder.h:120
mcl_encoder_cal_speed_function_t speed_cal_method
Definition: hpm_mcl_encoder.h:118
mcl_encoder_cal_speed_pll_cfg_t cal_speed_pll_cfg
Definition: hpm_mcl_encoder.h:119
float speed_abs_switch_m_t
Definition: hpm_mcl_encoder.h:121
uint32_t precision
Definition: hpm_mcl_encoder.h:122
uint8_t disable_start_sample_interrupt
Definition: hpm_mcl_encoder.h:116
iir df1 running data
Definition: hpm_mcl_filter.h:51
User-defined data with data and enable bits.
Definition: hpm_mcl_common.h:29