Ver código fonte

去掉整车相关参数,加入弱磁开启,启动占空比参数

Signed-off-by: kevin <huhui@sharkgulf.com>
kevin 2 anos atrás
pai
commit
928c0f4dbd

+ 2 - 3
Applications/autogen_config.h

@@ -11,9 +11,8 @@
 #define CONFIG_Motor_PLLBand  200
 #define CONFIG_Motor_EpmPLL  400
 #define CONFIG_Motor_PosPLL  500
-#define CONFIG_Motor_VehicleW  190
-#define CONFIG_Motor_WheelC  145
-#define CONFIG_Motor_GearRatio  6.25f
+#define CONFIG_Motor_FwEnable  1
+#define CONFIG_Motor_FwDutyStart  90
 #define CONFIG_Motor_MaxFwDCurr  100
 #define CONFIG_Motor_MaxTorque  200
 #define CONFIG_Motor_EncOffset  -103

+ 10 - 9
Applications/foc/mc_config.c

@@ -187,9 +187,9 @@ void mc_conf_default(void) {
 	conf.m.nor_pll_band = CONFIG_Motor_PLLBand;
 	conf.m.epm_pll_band = CONFIG_Motor_EpmPLL;
 	conf.m.pos_pll_band = CONFIG_Motor_PosPLL;
-	conf.m.vehicle_w = CONFIG_Motor_VehicleW;
-	conf.m.wheel_c = CONFIG_Motor_WheelC;
-	conf.m.gear_ratio = CONFIG_Motor_GearRatio;
+	//conf.m.vehicle_w = CONFIG_Motor_VehicleW;
+	//conf.m.wheel_c = CONFIG_Motor_WheelC;
+	//conf.m.gear_ratio = CONFIG_Motor_GearRatio;
 	conf.m.max_fw_id = CONFIG_Motor_MaxFwDCurr;
 	conf.m.max_torque = CONFIG_Motor_MaxTorque;
 	conf.m.encoder_offset = CONFIG_Motor_EncOffset;
@@ -302,12 +302,14 @@ int mc_conf_decode_motor(u8 *buff) {
 	conf.m.nor_pll_band = (float)decode_u16(buff); buff += 2;
 	conf.m.epm_pll_band = (float)decode_u16(buff); buff += 2;
 	conf.m.pos_pll_band = (float)decode_u16(buff); buff += 2;
-	conf.m.vehicle_w = decode_u16(buff);buff += 2;
-	conf.m.wheel_c = decode_u16(buff);buff += 2;
-	conf.m.gear_ratio = decode_float(buff);buff += 4;
+	conf.m.fw_enable = decode_u8(buff);buff += 1;
+	conf.m.fw_duty_start = decode_u8(buff);buff += 1;
 	conf.m.max_fw_id = decode_u16(buff); buff += 2;
 	conf.m.max_torque = decode_u16(buff); buff += 2;
 	conf.m.encoder_offset = decode_s16(buff); buff += 2;
+	if (conf.m.fw_duty_start > 100) {
+		conf.m.fw_duty_start = 100;
+	}
 	return buff - ori;
 }
 
@@ -321,9 +323,8 @@ int mc_conf_encode_motor(u8 *buff) {
 	encode_u16(buff, (u16)conf.m.nor_pll_band); buff += 2;
 	encode_u16(buff, (u16)conf.m.epm_pll_band); buff += 2;
 	encode_u16(buff, (u16)conf.m.pos_pll_band); buff += 2;
-	encode_u16(buff, conf.m.vehicle_w);buff += 2;
-	encode_u16(buff, conf.m.wheel_c);buff += 2;
-	encode_float(buff, conf.m.gear_ratio);buff += 4;
+	encode_u8(buff, (u8)conf.m.fw_enable);buff += 1;
+	encode_u8(buff, conf.m.fw_duty_start);buff += 1;
 	encode_u16(buff, conf.m.max_fw_id); buff += 2;
 	encode_u16(buff, conf.m.max_torque); buff += 2;
 	encode_s16(buff, conf.m.encoder_offset); buff += 2;

+ 2 - 3
Applications/foc/mc_config.h

@@ -30,9 +30,8 @@ typedef struct
 	float nor_pll_band;
 	float epm_pll_band;
 	float pos_pll_band;
-   	int vehicle_w;
-   	int wheel_c;
-   	float gear_ratio;
+	bool  fw_enable;
+	u8  fw_duty_start; //0-100
 	u16	max_fw_id;
 	u16 max_torque;
 	s16 encoder_offset;

+ 3 - 4
Applications/foc/motor/motor_param.c

@@ -373,11 +373,10 @@ void motor_mpta_fw_lookup(float rpm, float torque, dq_t *dq_out) {
 		}
 	}
 #else
-#if CONFIG_CONTRL_FW_ENABLE
-	if ((mot_contrl()->duty_filterd >= CONFIG_CONTRL_FW_START_DUTY) && (CONFIG_CONTRL_FW_START_DUTY < CONFIG_SVM_MODULATION)) {
-		d = -f_map(mot_contrl()->duty_filterd, CONFIG_CONTRL_FW_START_DUTY, CONFIG_SVM_MODULATION, 0, mc_conf()->m.max_fw_id);
+	float fw_start_duty = (float)mc_conf()->m.fw_duty_start/100.0f;
+	if (mc_conf()->m.fw_enable && (mot_contrl()->duty_filterd >= fw_start_duty)) {
+		d = -f_map(mot_contrl()->duty_filterd, fw_start_duty, CONFIG_SVM_MODULATION, 0, mc_conf()->m.max_fw_id);
 	}
-#endif
 	q = torque;
 #endif
  	step_towards(&dq_out->d, d, 10.0f);