Quellcode durchsuchen

加入DQ电流MTPA校准命令

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui vor 3 Jahren
Ursprung
Commit
afc294643b
3 geänderte Dateien mit 28 neuen und 4 gelöschten Zeilen
  1. 23 1
      Applications/foc/commands.c
  2. 4 2
      Applications/foc/commands.h
  3. 1 1
      Applications/foc/core/PMSM_FOC_Core.h

+ 23 - 1
Applications/foc/commands.c

@@ -136,7 +136,7 @@ static void process_foc_command(foc_cmd_body_t *command) {
 			len += 1;
 			break;
 		}
-		case Foc_Set_Phase_Current:
+		case Foc_Set_Phase_CurrLim:
 		{
 			s16 curr = decode_s16(((u8 *)command->data));
 			PMSM_FOC_PhaseCurrLim((float)curr);
@@ -185,6 +185,28 @@ static void process_foc_command(foc_cmd_body_t *command) {
 			}
 			break;
 		}
+		case Foc_Start_DQ_Calibrate:
+		{
+			u8 start = decode_u8((u8 *)command->data);
+			if (start == Foc_Start) {
+				PMSM_FOC_MTPA_Calibrate(true);
+			}else {
+				PMSM_FOC_MTPA_Calibrate(false);
+			}
+			break;
+		}
+		case Foc_Set_IS_Curr_Angle:
+		{
+			if (command->len != 4) {
+				erroCode = FOC_Param_Err;
+			}else {
+				s16 is_curr = decode_s16((u8 *)command->data);
+				s16 is_angle = decode_s16((u8 *)command->data + 2);
+				PMSM_FOC_Set_Current(is_curr);
+				PMSM_FOC_Set_Angle(is_angle);
+			}
+			break;
+		}
 		default:
 		{
 			erroCode = FOC_Unknow_Cmd;

+ 4 - 2
Applications/foc/commands.h

@@ -12,13 +12,15 @@ typedef enum {
 	Foc_Set_Speed_Target,    //u32, set the target speed, just for test
 	Foc_Set_Cruise_Speed,    //u32, set the speed for curise riding
 	Foc_Set_Cruise_Mode,
-	Foc_Set_Phase_Current,
+	Foc_Set_Phase_CurrLim,
 	Foc_Set_Ctrl_Mode,
-	Foc_Set_Gear_Limit,
+	Foc_Set_Gear_Limit,    //通过设置限速,限相电流,限母线电流上层可以实现任意挡位
 	Foc_Set_Open_Dq_Vol,		//u32, u32, 114d000000000a000000, 114d0000000000000000
 	Foc_Set_EPM_Mode,
 	Foc_Start_EPM_Move,
 	Foc_Conf_Pid,
+	Foc_Start_DQ_Calibrate,
+	Foc_Set_IS_Curr_Angle,  //设置DQ电流矢量和超前角
 	Foc_Hall_Phase_Cali_Result = 160,
 	Foc_Hall_Offset_Cali_Result,
 	Foc_Report_Speed,

+ 1 - 1
Applications/foc/core/PMSM_FOC_Core.h

@@ -51,7 +51,7 @@ typedef struct {
 	bool    b_motLock;
 	bool    b_eBrake;
 	bool    b_epmMode;
-	bool    b_MTPA_calibrate;
+	volatile bool    b_MTPA_calibrate;
 	float   s_manualAngle; //mainly used when calibrate hall/mtpa. 
 }FOC_InP;