Sfoglia il codice sorgente

通过宏定义选择电机

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 3 anni fa
parent
commit
05b5dd1b99

+ 2 - 0
Applications/bsp/board_gd32demo.h

@@ -170,5 +170,7 @@
 
 #define ENC_Duty(d, t) ((d)/(t))
 
+#define MOTOR_3505
+
 #endif /*_BOARD_GD32DEMO_H__ */
 

+ 4 - 0
Applications/bsp/board_mc_v1.h

@@ -230,6 +230,10 @@
 
 #define DEBUG_PORT_UART2
 
+#define MOTOR_BLUESHARK_NEW1  //蓝鲨大功率电机,双E形
+//#define MOTOR_BLUESHARK_NEW2  //蓝鲨大功率电机,V形
+//#define MOTOR_BLUESHARK_OLD   //目前量产的电机
+
 //#define CONFIG_DQ_STEP_RESPONSE
 
 #endif /*_BOARD_MC_V1_H__ */

+ 5 - 1
Applications/foc/motor/encoder.c

@@ -6,8 +6,12 @@
 #include "libs/logger.h"
 #include "app/nv_storage.h"
 #include "math/fast_math.h"
+#ifdef MOTOR_BLUESHARK_OLD
+#include "encoder_off2.h"
+#elif defined MOTOR_BLUESHARK_NEW1
 #include "encoder_off3.h"
-
+#elif defined MOTOR_BLUESHARK_NEW2
+#endif
 static void encoder_do_offset_calibrate(void) ;
 static void _detect_off_finished(void);
 

+ 19 - 8
Applications/foc/motor/motor_param.h

@@ -1,24 +1,35 @@
 #ifndef _MOTOR_PARAM_H__
 #define _MOTOR_PARAM_H__
+#include "bsp/bsp.h"
 
-#if 1
+#ifdef MOTOR_BLUESHARK_NEW1
 #define MOTOR_R   0.010f
 #define MOTOR_Ld (0.000120f*0.5f)
 #define MOTOR_Lq (0.000200f*0.5f)
 #define MOTOR_POLES  4
 #define MOTOR_ENC_OFFSET 0.0F
-#elif 0
-//编码器电机 3505
-#define MOTOR_R 0.08f
-#define MOTOR_Ld 0.000032f
-#define MOTOR_Lq 0.000032f
-#define MOTOR_POLES  10
-#else
+
+#elif defined MOTOR_BLUESHARK_NEW2
+#define MOTOR_R   0.010f
+#define MOTOR_Ld (0.000120f*0.5f)
+#define MOTOR_Lq (0.000200f*0.5f)
+#define MOTOR_POLES  4
+#define MOTOR_ENC_OFFSET 0.0F
+
+#elif defined MOTOR_BLUESHARK_OLD
+
 #define MOTOR_R 0.012f
 #define MOTOR_Ld (0.000143f*0.5f)
 #define MOTOR_Lq (0.000205f*0.5f)
 #define MOTOR_POLES  5
 #define MOTOR_ENC_OFFSET 180.0F
+
+#elif defined MOTOR_3505
+//编码器电机 3505
+#define MOTOR_R 0.08f
+#define MOTOR_Ld 0.000032f
+#define MOTOR_Lq 0.000032f
+#define MOTOR_POLES  10
 #endif
 
 #endif /* _MOTOR_PARAM_H__ */