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 {
42 
43 
48 typedef struct hpm_mcl_over_zero_cfg {
49  int32_t adc_u;
50  int32_t adc_v;
51  int32_t adc_w;
54  uint32_t delay_degree_30;
55  uint32_t last_interval_tick;
56  uint32_t interval_tick;
58  uint8_t adc_zero_ph;
61  uint32_t speed_tick;
63  uint8_t pole_num;
64  float loop_time_in_sec; /*< Time interval to get the position, unit: s*/
67 
72 typedef struct hpm_mcl_over_zero_spd_par {
73  float speed;
74  float err;
75  float err_last;
76  float filter_coef;
77  float speedout;
78  float kp;
79  float ki;
80  float mem;
81  float integral_max;
82  float integral_min;
83  float output_max;
84  float output_min;
85  void (*func_getspd)(void *str);
87 
92 typedef struct hpm_mcl_over_zero_pi_par {
93  float kp;
94  float ki;
95  float kd;
96  float integral_max;
97  float integral_min;
98  float output_max;
99  float output_min;
100  float target;
101  float mem;
102  float cur;
103  float outval;
104  void (*func_pid)(void *str);
106 
114 
122 
129 void hpm_mcl_over_zero_pwm_ctrl(uint8_t motorindex, uint8_t step);
130 
138 
146 
147 #if defined(__cplusplus)
148 }
149 #endif /* __cplusplus */
150 
151 #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:35
@ hpm_mcl_interval_u_up
Definition: hpm_over_zero.h:40
@ hpm_mcl_interval_w_up
Definition: hpm_over_zero.h:38
@ hpm_mcl_interval_v_down
Definition: hpm_over_zero.h:39
@ hpm_mcl_interval_u_down
Definition: hpm_over_zero.h:37
@ hpm_mcl_interval_v_up
Definition: hpm_over_zero.h:36
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:48
uint32_t number_consecutive_zeros_w
Definition: hpm_over_zero.h:53
hpm_mcl_over_zero_interval_t interval
Definition: hpm_over_zero.h:62
uint32_t number_consecutive_zeros
Definition: hpm_over_zero.h:52
int32_t adc_v
Definition: hpm_over_zero.h:50
uint32_t speed_tick
Definition: hpm_over_zero.h:61
uint32_t delay_degree_30
Definition: hpm_over_zero.h:54
hpm_mcl_over_zero_fsm_t fsm
Definition: hpm_over_zero.h:65
int32_t adc_w
Definition: hpm_over_zero.h:51
uint8_t adc_zero_ph
Definition: hpm_over_zero.h:58
float loop_time_in_sec
Definition: hpm_over_zero.h:64
int32_t adc_u
Definition: hpm_over_zero.h:49
hpm_mcl_dir_t motor_dir
Definition: hpm_over_zero.h:57
hpm_mcl_over_zero_interval_t next_interval
Definition: hpm_over_zero.h:60
uint8_t pole_num
Definition: hpm_over_zero.h:63
uint32_t last_interval_tick
Definition: hpm_over_zero.h:55
hpm_mcl_over_zero_interval_t last_interval
Definition: hpm_over_zero.h:59
uint32_t interval_tick
Definition: hpm_over_zero.h:56
Speed PID control.
Definition: hpm_over_zero.h:92
float outval
Definition: hpm_over_zero.h:103
float cur
Definition: hpm_over_zero.h:102
float kp
Definition: hpm_over_zero.h:93
float mem
Definition: hpm_over_zero.h:101
float output_min
Definition: hpm_over_zero.h:99
float integral_min
Definition: hpm_over_zero.h:97
void(* func_pid)(void *str)
Definition: hpm_over_zero.h:104
float output_max
Definition: hpm_over_zero.h:98
float ki
Definition: hpm_over_zero.h:94
float target
Definition: hpm_over_zero.h:100
float integral_max
Definition: hpm_over_zero.h:96
float kd
Definition: hpm_over_zero.h:95
Filtering and phase-locked loop parameters.
Definition: hpm_over_zero.h:72
float err
Definition: hpm_over_zero.h:74
float integral_min
Definition: hpm_over_zero.h:82
void(* func_getspd)(void *str)
Definition: hpm_over_zero.h:85
float speedout
Definition: hpm_over_zero.h:77
float integral_max
Definition: hpm_over_zero.h:81
float output_max
Definition: hpm_over_zero.h:83
float filter_coef
Definition: hpm_over_zero.h:76
float mem
Definition: hpm_over_zero.h:80
float kp
Definition: hpm_over_zero.h:78
float ki
Definition: hpm_over_zero.h:79
float err_last
Definition: hpm_over_zero.h:75
float speed
Definition: hpm_over_zero.h:73
float output_min
Definition: hpm_over_zero.h:84