BMCL_Config.h
10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
#ifndef __BMCL_CONFIG_H_
#define __BMCL_CONFIG_H_
#include "stdint.h"
#include "BMCL_DevSpecific.h"
#include "MGE_Hal.h"
//=================BMCL Config HW (Using LL Lib) =================
#define BMCL_CONFIG_SELECT_1_GPIO_PORT BMCL_DEVSPECIFIC_SELECT_1_GPIO_PORT
#define BMCL_CONFIG_SELECT_2_GPIO_PORT BMCL_DEVSPECIFIC_SELECT_2_GPIO_PORT
#define BMCL_CONFIG_SELECT_1_GPIO_PIN BMCL_DEVSPECIFIC_SELECT_1_GPIO_PIN
#define BMCL_CONFIG_SELECT_2_GPIO_PIN BMCL_DEVSPECIFIC_SELECT_2_GPIO_PIN
//=================BMCL Config Para=================
extern float pitchCenAngle;
extern float yawCenAngle ;
extern float rollCenAngle ;
//=================BMCL Config Live Setting=================
// PreSetting
#define BMCL_CONFIG_MOT_SELECT_UNKNOW -1
#define BMCL_CONFIG_MOT_SELECT_PITCH 0
#define BMCL_CONFIG_MOT_SELECT_ROLL 1
#define BMCL_CONFIG_MOT_SELECT_YAW 2
#define BMCL_CONFIG_IS_PITCH (bmcl_config_mot_select == BMCL_CONFIG_MOT_SELECT_PITCH)
#define BMCL_CONFIG_IS_ROLL (bmcl_config_mot_select == BMCL_CONFIG_MOT_SELECT_ROLL)
#define BMCL_CONFIG_IS_YAW (bmcl_config_mot_select == BMCL_CONFIG_MOT_SELECT_YAW)
//========Setting=======
#define BMCL_CONFIG_MOT_SELECT_SCANTIMES 50 // The scan times of Motor axis selection GPIO
//=================BMCL Config Setting & Define=================
#define BMCL_CONFIG_VERSION (uint32_t)1
#define BMCL_CONFIG_EEPROM_ADDR 0x0800F800 //62k
#define BMCL_CONFIG_EEPROM_ADDR2 0x0800FC00 //63k
#define BMCL_CONFIG_EEPROM_CRC_INIVAULE 0x1c81
// typedef enum
// {
// BMCL_CONFIG_MGE_CAL_STA_EMPTY = 0x00,
// BMCL_CONFIG_MGE_CAL_STA_CALED = 0x01,
// } BMCL_CONFIG_MGE_CAL_STA;
// typedef enum
// {
// BMCL_CONFIG_MOT_CAL_STA_EMPTY = 0x00,
// BMCL_CONFIG_MOT_CAL_STA_CALS1 = 0x01,
// BMCL_CONFIG_MOT_CAL_STA_CALS2 = 0x02,
// } BMCL_CONFIG_MOT_CAL_STA;
// typedef enum
// {
// BMCL_CONFIG_MOT_CAL_STA_EMPTY = 0x00,
// } BMCL_CONFIG_EEPROM_STA;
// _______________Default parameters_______________
// NOTE: BMCL_CD_Y -> BMCL_CONFIG_DEFPARA_YAW
// NOTE: Change it depend on Platform standard situation
//======================= F1 Motor Board Default Para Pitch
// ! BMCL_CD_P_MOT_FOC_PP is uint8_t
// ! BMCL_CD_P_MGE_DIRECTION is int8_t
// ! BMCL_CD_P_INTER_RANGE is uint32_t
#define BMCL_CD_P_MOT_FOC_Udc 12.0f
#define BMCL_CD_P_MOT_FOC_ULIMIT 5.0f
#define BMCL_CD_P_MOT_FOC_PP 7
#define BMCL_CD_P_MGE_DIRECTION MGE_DIRECTION_CW
#define BMCL_CD_P_MGE_ABSOFFSET 3.22241449f
#define BMCL_CD_P_MGE_ELEANGLE 2.77957392f
#define BMCL_CD_P_MOT_CENTER_ANG 0.0f
#define BMCL_CD_P_INTER_RANGE 2
#define BMCL_CD_P_INTER1_RANGE 3
#define BMCL_CD_P_ANG_GENPID_KP 700.0f
#define BMCL_CD_P_ANG_GENPID_KI 0.1f
#define BMCL_CD_P_ANG_GENPID_KD 15.0f
#define BMCL_CD_P_ANG_GENPID_IerrV 0.0f
#define BMCL_CD_P_ANG_GENPID_OUTPUTLIMIT 30.0f
#define BMCL_CD_P_ANG_GENPID_INTDETACH 10.0f
#define BMCL_CD_P_ANG_GENPID_DEADZONE 0.0f
#define BMCL_CD_P_ANG_GENPID_OUTPUTRAMP 0.0f
#define BMCL_CD_P_ANG_GENPID_INTLIMIT 10.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KPa 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KPb 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KPc 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KIa 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KIc 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KIe 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KI0 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KI1 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KDa 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KDb 0.0f
#define BMCL_CD_P_ANG_GENPID_VPID_KDc 0.0f
#define BMCL_CD_P_VEL_GENPID_KP 0.3f
#define BMCL_CD_P_VEL_GENPID_KI 10.0f
#define BMCL_CD_P_VEL_GENPID_KD 0.0f
#define BMCL_CD_P_VEL_GENPID_IerrV 0.0f
#define BMCL_CD_P_VEL_GENPID_OUTPUTLIMIT 6.0f
#define BMCL_CD_P_VEL_GENPID_INTDETACH 4.0f
#define BMCL_CD_P_VEL_GENPID_DEADZONE 0.0f
#define BMCL_CD_P_VEL_GENPID_OUTPUTRAMP 0.0f
#define BMCL_CD_P_VEL_GENPID_INTLIMIT 4.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KPa 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KPb 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KPc 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KIa 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KIc 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KIe 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KI0 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KI1 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KDa 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KDb 0.0f
#define BMCL_CD_P_VEL_GENPID_VPID_KDc 0.0f
#define BMCL_CD_P_KPF_VELP_Q 0.005f
#define BMCL_CD_P_KPF_VELP_R 20.0f
#define BMCL_CD_P_KPF_ANGP_Q 0.0001f
#define BMCL_CD_P_KPF_ANGP_R 0.01f
#define BMCL_CD_P_KPF_SSMQ_Q 0.01f
#define BMCL_CD_P_KPF_SSMQ_R 0.1f
#define BMCL_CD_P_KPF_MOTANGP_Q 0.01f
#define BMCL_CD_P_KPF_MOTANGP_R 0.1f
//======================= F1 Motor Board Default Para Roll
// ! BMCL_CD_R_MOT_FOC_PP is uint8_t
// ! BMCL_CD_R_MGE_DIRECTION is int8_t
// ! BMCL_CD_R_INTER_RANGE is uint32_t
#define BMCL_CD_R_MOT_FOC_Udc 24.0f
#define BMCL_CD_R_MOT_FOC_ULIMIT 5.0f
#define BMCL_CD_R_MOT_FOC_PP 7
#define BMCL_CD_R_MGE_DIRECTION MGE_DIRECTION_CCW
// #define BMCL_CD_R_MGE_ABSOFFSET 0.787124157f
#define BMCL_CD_R_MGE_ABSOFFSET -5.89930677f
// #define BMCL_CD_R_MGE_ELEANGLE 4.4036727f
#define BMCL_CD_R_MGE_ELEANGLE 6.10601282f
#define BMCL_CD_R_MOT_UP_ANG 120.0f //上限(角度制)
#define BMCL_CD_R_MOT_DOWN_ANG -90.0f //下限位
#define BMCL_CD_R_MOT_CENTER_ANG 4.6144133f*_RtoD
#define BMCL_CD_R_INTER_RANGE 2
#define BMCL_CD_R_INTER1_RANGE 3
#define BMCL_CD_R_ANG_GENPID_KP 200.0f
#define BMCL_CD_R_ANG_GENPID_KI 0.5f
#define BMCL_CD_R_ANG_GENPID_KD 1.0f
#define BMCL_CD_R_ANG_GENPID_IerrV 0.0f
#define BMCL_CD_R_ANG_GENPID_OUTPUTLIMIT 30.0f
#define BMCL_CD_R_ANG_GENPID_INTDETACH 10.0f
#define BMCL_CD_R_ANG_GENPID_DEADZONE 0.0f
#define BMCL_CD_R_ANG_GENPID_OUTPUTRAMP 0.0f
#define BMCL_CD_R_ANG_GENPID_INTLIMIT 10.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KPa 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KPb 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KPc 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KIa 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KIc 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KIe 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KI0 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KI1 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KDa 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KDb 0.0f
#define BMCL_CD_R_ANG_GENPID_VPID_KDc 0.0f
#define BMCL_CD_R_VEL_GENPID_KP 0.1f
#define BMCL_CD_R_VEL_GENPID_KI 1.0f
#define BMCL_CD_R_VEL_GENPID_KD 0.0f
#define BMCL_CD_R_VEL_GENPID_IerrV 0.0f
#define BMCL_CD_R_VEL_GENPID_OUTPUTLIMIT 6.0f
#define BMCL_CD_R_VEL_GENPID_INTDETACH 4.0f
#define BMCL_CD_R_VEL_GENPID_DEADZONE 0.0f
#define BMCL_CD_R_VEL_GENPID_OUTPUTRAMP 0.0f
#define BMCL_CD_R_VEL_GENPID_INTLIMIT 4.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KPa 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KPb 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KPc 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KIa 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KIc 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KIe 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KI0 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KI1 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KDa 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KDb 0.0f
#define BMCL_CD_R_VEL_GENPID_VPID_KDc 0.0f
#define BMCL_CD_R_KPF_VELP_Q 0.005f
#define BMCL_CD_R_KPF_VELP_R 20.0f
#define BMCL_CD_R_KPF_ANGP_Q 0.0001f
#define BMCL_CD_R_KPF_ANGP_R 0.01f
#define BMCL_CD_R_KPF_SSMQ_Q 0.01f
#define BMCL_CD_R_KPF_SSMQ_R 0.1f
#define BMCL_CD_R_KPF_MOTANGP_Q 0.01f
#define BMCL_CD_R_KPF_MOTANGP_R 0.1f
//======================= F1 Motor Board Default Para Yaw
// ! BMCL_CD_Y_MOT_FOC_PP is uint8_t
// ! BMCL_CD_Y_MGE_DIRECTION is int8_t
// ! BMCL_CD_Y_INTER_RANGE is uint32_t
#define BMCL_CD_Y_MOT_FOC_Udc 12.0f
#define BMCL_CD_Y_MOT_FOC_ULIMIT 5.0f
#define BMCL_CD_Y_MOT_FOC_PP 7
#define BMCL_CD_Y_MGE_DIRECTION MGE_DIRECTION_CCW
#define BMCL_CD_Y_MGE_ABSOFFSET 3.6f
#define BMCL_CD_Y_MGE_ELEANGLE 4.87077045
// #define BMCL_CD_Y_MGE_ELEANGLE 4.68861246f
#define BMCL_CD_Y_MOT_CENTER_ANG -3.6f*_RtoD
#define BMCL_CD_Y_INTER_RANGE 2
#define BMCL_CD_Y_INTER1_RANGE 3
#define BMCL_CD_Y_ANG_GENPID_KP 700.0f
#define BMCL_CD_Y_ANG_GENPID_KI 0.1f
#define BMCL_CD_Y_ANG_GENPID_KD 15.0f
#define BMCL_CD_Y_ANG_GENPID_IerrV 0.0f
#define BMCL_CD_Y_ANG_GENPID_OUTPUTLIMIT 30.0f
#define BMCL_CD_Y_ANG_GENPID_INTDETACH 10.0f
#define BMCL_CD_Y_ANG_GENPID_DEADZONE 0.0f
#define BMCL_CD_Y_ANG_GENPID_OUTPUTRAMP 0.0f
#define BMCL_CD_Y_ANG_GENPID_INTLIMIT 10.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KPa 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KPb 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KPc 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KIa 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KIc 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KIe 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KI0 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KI1 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KDa 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KDb 0.0f
#define BMCL_CD_Y_ANG_GENPID_VPID_KDc 0.0f
#define BMCL_CD_Y_VEL_GENPID_KP 0.2f
#define BMCL_CD_Y_VEL_GENPID_KI 5.0f
#define BMCL_CD_Y_VEL_GENPID_KD 0.0f
#define BMCL_CD_Y_VEL_GENPID_IerrV 0.0f
#define BMCL_CD_Y_VEL_GENPID_OUTPUTLIMIT 6.0f
#define BMCL_CD_Y_VEL_GENPID_INTDETACH 4.0f
#define BMCL_CD_Y_VEL_GENPID_DEADZONE 0.0f
#define BMCL_CD_Y_VEL_GENPID_OUTPUTRAMP 0.0f
#define BMCL_CD_Y_VEL_GENPID_INTLIMIT 4.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KPa 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KPb 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KPc 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KIa 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KIc 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KIe 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KI0 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KI1 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KDa 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KDb 0.0f
#define BMCL_CD_Y_VEL_GENPID_VPID_KDc 0.0f
#define BMCL_CD_Y_KPF_VELP_Q 0.005f
#define BMCL_CD_Y_KPF_VELP_R 20.0f
#define BMCL_CD_Y_KPF_ANGP_Q 0.0001f
#define BMCL_CD_Y_KPF_ANGP_R 0.01f
#define BMCL_CD_Y_KPF_SSMQ_Q 0.01f
#define BMCL_CD_Y_KPF_SSMQ_R 0.1f
#define BMCL_CD_Y_KPF_MOTANGP_Q 0.01f
#define BMCL_CD_Y_KPF_MOTANGP_R 0.1f
// _______________Default parameters_______________
//=======InitALL Fun
int bmcl_Config_Init();/// @brief 电机驱动参数初始化,固定值,只能通过宏定义修改
/// @param
void BMCL_motorSetting_PreLoad(void);
/// @brief 电机GenPID参数预初始化,使用.h文件中的值
/// @param
void BMCL_motorPID_PreLoad(void);
/// @brief 电机滤波器参数预初始化,使用.h文件中的值
/// @param
void BMCL_filter_PreLoad(void);
// //=======InitALL ForTest Fun
// void motor_PreLoadALL_CailJump(void);
#endif