HPM SDK
HPMicro Software Development Kit
hpm_over_zero.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 #ifndef HPM_OVER_ZERO_H
8 #define HPM_OVER_ZERO_H
9 
10 #include "hpm_common.h"
11 #if defined(__cplusplus)
12 extern "C" {
13 #endif /* __cplusplus */
14 
19 typedef enum {
24 
29 typedef enum {
33 
34 typedef enum {
43 
44 
49 typedef struct hpm_mcl_over_zero_cfg {
50  int32_t adc_u;
51  int32_t adc_v;
52  int32_t adc_w;
55  uint32_t delay_degree_30;
56  uint32_t last_interval_tick;
57  uint32_t interval_tick;
59  uint8_t adc_zero_ph;
62  uint32_t speed_tick;
64  uint8_t pole_num;
65  float loop_time_in_sec; /*< Time interval to get the position, unit: s*/
68 
73 typedef struct hpm_mcl_over_zero_spd_par {
74  float speed;
75  float err;
76  float err_last;
77  float filter_coef;
78  float speedout;
79  float kp;
80  float ki;
81  float mem;
82  float integral_max;
83  float integral_min;
84  float output_max;
85  float output_min;
86  void (*func_getspd)(void *str);
88 
93 typedef struct hpm_mcl_over_zero_pi_par {
94  float kp;
95  float ki;
96  float kd;
97  float integral_max;
98  float integral_min;
99  float output_max;
100  float output_min;
101  float target;
102  float mem;
103  float cur;
104  float outval;
105  void (*func_pid)(void *str);
107 
115 
123 
130 void hpm_mcl_over_zero_pwm_ctrl(uint8_t motorindex, uint8_t step);
131 
139 
147 
148 #if defined(__cplusplus)
149 }
150 #endif /* __cplusplus */
151 
152 #endif
float hpm_mcl_over_zero_speed_filter(hpm_mcl_over_zero_spd_para_t *par)
Speed filter.
Definition: hpm_over_zero.c:268
void hpm_mcl_over_zero_pwm_ctrl(uint8_t motorindex, uint8_t step)
pwm output for different angle intervals
Definition: hpm_over_zero.c:15
struct hpm_mcl_over_zero_pi_par hpm_mcl_over_zero_pi_para_t
Speed PID control.
hpm_mcl_dir_t
Motor Direction.
Definition: hpm_over_zero.h:29
@ hpm_motor_dir_reverse
Definition: hpm_over_zero.h:31
@ hpm_motor_dir_forward
Definition: hpm_over_zero.h:30
int8_t hpm_mcl_over_zero_step_get(hpm_mcl_over_zero_cfg_t *cfg)
Get commutation position.
Definition: hpm_over_zero.c:72
hpm_mcl_over_zero_fsm_t
Over-zero method fsm.
Definition: hpm_over_zero.h:19
@ hpm_mcl_over_zero_fsm_location
Definition: hpm_over_zero.h:21
@ hpm_mcl_over_zero_fsm_running
Definition: hpm_over_zero.h:22
@ hpm_mcl_over_zero_fsm_init
Definition: hpm_over_zero.h:20
float hpm_mcl_over_zero_cal_speed(hpm_mcl_over_zero_cfg_t *cfg)
alculating speed by clock cycles
Definition: hpm_over_zero.c:306
struct hpm_mcl_over_zero_spd_par hpm_mcl_over_zero_spd_para_t
Filtering and phase-locked loop parameters.
hpm_mcl_over_zero_interval_t
Definition: hpm_over_zero.h:34
@ hpm_mcl_interval_w_down
Definition: hpm_over_zero.h:36
@ hpm_mcl_interval_u_up
Definition: hpm_over_zero.h:41
@ hpm_mcl_interval_w_up
Definition: hpm_over_zero.h:39
@ hpm_mcl_interval_v_down
Definition: hpm_over_zero.h:40
@ hpm_mcl_interval_u_down
Definition: hpm_over_zero.h:38
@ hpm_mcl_interval_init
Definition: hpm_over_zero.h:35
@ hpm_mcl_interval_v_up
Definition: hpm_over_zero.h:37
struct hpm_mcl_over_zero_cfg hpm_mcl_over_zero_cfg_t
Over-zero method configuration data.
float hpm_mcl_over_zero_pi_contrl(hpm_mcl_over_zero_pi_para_t *par)
Speed pi control.
Definition: hpm_over_zero.c:312
Over-zero method configuration data.
Definition: hpm_over_zero.h:49
uint32_t number_consecutive_zeros_w
Definition: hpm_over_zero.h:54
hpm_mcl_over_zero_interval_t interval
Definition: hpm_over_zero.h:63
uint32_t number_consecutive_zeros
Definition: hpm_over_zero.h:53
int32_t adc_v
Definition: hpm_over_zero.h:51
uint32_t speed_tick
Definition: hpm_over_zero.h:62
uint32_t delay_degree_30
Definition: hpm_over_zero.h:55
hpm_mcl_over_zero_fsm_t fsm
Definition: hpm_over_zero.h:66
int32_t adc_w
Definition: hpm_over_zero.h:52
uint8_t adc_zero_ph
Definition: hpm_over_zero.h:59
float loop_time_in_sec
Definition: hpm_over_zero.h:65
int32_t adc_u
Definition: hpm_over_zero.h:50
hpm_mcl_dir_t motor_dir
Definition: hpm_over_zero.h:58
hpm_mcl_over_zero_interval_t next_interval
Definition: hpm_over_zero.h:61
uint8_t pole_num
Definition: hpm_over_zero.h:64
uint32_t last_interval_tick
Definition: hpm_over_zero.h:56
hpm_mcl_over_zero_interval_t last_interval
Definition: hpm_over_zero.h:60
uint32_t interval_tick
Definition: hpm_over_zero.h:57
Speed PID control.
Definition: hpm_over_zero.h:93
float outval
Definition: hpm_over_zero.h:104
float cur
Definition: hpm_over_zero.h:103
float kp
Definition: hpm_over_zero.h:94
float mem
Definition: hpm_over_zero.h:102
float output_min
Definition: hpm_over_zero.h:100
float integral_min
Definition: hpm_over_zero.h:98
void(* func_pid)(void *str)
Definition: hpm_over_zero.h:105
float output_max
Definition: hpm_over_zero.h:99
float ki
Definition: hpm_over_zero.h:95
float target
Definition: hpm_over_zero.h:101
float integral_max
Definition: hpm_over_zero.h:97
float kd
Definition: hpm_over_zero.h:96
Filtering and phase-locked loop parameters.
Definition: hpm_over_zero.h:73
float err
Definition: hpm_over_zero.h:75
float integral_min
Definition: hpm_over_zero.h:83
void(* func_getspd)(void *str)
Definition: hpm_over_zero.h:86
float speedout
Definition: hpm_over_zero.h:78
float integral_max
Definition: hpm_over_zero.h:82
float output_max
Definition: hpm_over_zero.h:84
float filter_coef
Definition: hpm_over_zero.h:77
float mem
Definition: hpm_over_zero.h:81
float kp
Definition: hpm_over_zero.h:79
float ki
Definition: hpm_over_zero.h:80
float err_last
Definition: hpm_over_zero.h:76
float speed
Definition: hpm_over_zero.h:74
float output_min
Definition: hpm_over_zero.h:85