HPM SDK
HPMicro Software Development Kit
hpm_hfi.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 
8 #ifndef HPM_SQUARE_WAVE_INJECT_H
9 #define HPM_SQUARE_WAVE_INJECT_H
10 
11 #include "hpm_common.h"
12 #include "hpm_bldc_define.h"
13 #include "hpm_foc.h"
14 #include "hpm_smc.h"
15 
23 #if defined(__cplusplus)
24 extern "C" {
25 #endif /* __cplusplus */
26 
27 #ifndef PI
28 #define PI HPM_PI
29 #endif
30 
35 typedef struct hpm_hfi_para {
36  float vh;
37  float last_alpha;
38  float last_beta;
39  float e_alpha;
40  float e_beta;
41  float e_theta;
42  float alpha;
43  float beta;
44  bool period;
45  void (*func)(void *str);
47 
48 #define BLDC_CONTROL_INJECT_PARA_DEFAULTS {\
49  0, 0, 0,\
50  0, 0, 0, 0, 0, 0,\
51  NULL\
52 }
53 
58 typedef struct hpm_hfi_pole_detect_para {
59  int16_t currentd_force;
60  volatile uint8_t status;
61  uint16_t times;
62  uint16_t current_d_init_val;
63  int32_t theta_pi;
64  int32_t theta_zero;
65  bool (*func)(void *foc, void *inject,
66  void *pll, void *pole);
68 
69 #define BLDC_CONTROL_INJECT_POLE_DETECT_PARA_DEFAULTS {\
70  0, 0, 0, 0, 0, 0,\
71  NULL\
72 }
73 
78 typedef struct hpm_hfi_pll_para {
79  float theta_last;
80  float err_last;
81  float low_pass;
82  float filter;
83  float deta;
84  float theta;
85  float kp;
86  float ki;
87  float mem_max;
88  float mem_min;
89  float mem;
90  float loop_s;
91  float err;
92  void (*func)(void *str);
94 
95 #define BLDC_CONTROL_INJECT_PLL_PARA_DEFAULTS {\
96  0, 0, 0, 0, 0,\
97  0, 0, 0, 0, 0, 0, 0, 0,\
98  NULL\
99 }
100 
111 
124 #if defined(__cplusplus)
125 }
126 #endif /* __cplusplus */
127 
133 #endif
bool hpm_mcl_hfi_pole_detect(BLDC_CONTROL_FOC_PARA *foc, hpm_hfi_para_t *inject, hpm_hfi_pll_para_t *pll, hpm_hfi_pole_detect_para_t *pole)
HFI Magnetic Pole Detection.
Definition: hpm_hfi.c:112
struct hpm_hfi_para hpm_hfi_para_t
HFI parameters and calculation data.
void hpm_mcl_hfi_loop(BLDC_CONTROL_FOC_PARA *par, hpm_hfi_para_t *inject, hpm_hfi_pll_para_t *pll, hpm_hfi_pole_detect_para_t *pole)
HFI current loop.
Definition: hpm_hfi.c:80
struct hpm_hfi_pole_detect_para hpm_hfi_pole_detect_para_t
HFI of magnetic pole identification parameters.
struct hpm_hfi_pll_para hpm_hfi_pll_para_t
HFI pll Filter Parameters.
foc control
Definition: hpm_bldc_define.h:234
HFI parameters and calculation data.
Definition: hpm_hfi.h:35
float e_beta
Definition: hpm_hfi.h:40
float e_theta
Definition: hpm_hfi.h:41
float last_alpha
Definition: hpm_hfi.h:37
float last_beta
Definition: hpm_hfi.h:38
float vh
Definition: hpm_hfi.h:36
bool period
Definition: hpm_hfi.h:44
void(* func)(void *str)
Definition: hpm_hfi.h:45
float beta
Definition: hpm_hfi.h:43
float alpha
Definition: hpm_hfi.h:42
float e_alpha
Definition: hpm_hfi.h:39
HFI pll Filter Parameters.
Definition: hpm_hfi.h:78
float theta
Definition: hpm_hfi.h:84
float err_last
Definition: hpm_hfi.h:80
float err
Definition: hpm_hfi.h:91
float low_pass
Definition: hpm_hfi.h:81
float ki
Definition: hpm_hfi.h:86
float deta
Definition: hpm_hfi.h:83
float mem_max
Definition: hpm_hfi.h:87
float mem
Definition: hpm_hfi.h:89
float filter
Definition: hpm_hfi.h:82
float mem_min
Definition: hpm_hfi.h:88
float kp
Definition: hpm_hfi.h:85
float loop_s
Definition: hpm_hfi.h:90
void(* func)(void *str)
Definition: hpm_hfi.h:92
float theta_last
Definition: hpm_hfi.h:79
HFI of magnetic pole identification parameters.
Definition: hpm_hfi.h:58
bool(* func)(void *foc, void *inject, void *pll, void *pole)
Definition: hpm_hfi.h:65
int32_t theta_pi
Definition: hpm_hfi.h:63
volatile uint8_t status
Definition: hpm_hfi.h:60
uint16_t current_d_init_val
Definition: hpm_hfi.h:62
int32_t theta_zero
Definition: hpm_hfi.h:64
int16_t currentd_force
Definition: hpm_hfi.h:59
uint16_t times
Definition: hpm_hfi.h:61