Browse Source

1、Iq和Id参考值修改为全局变量,便于调试信息发出;
2、转把力矩模式时,力矩和转把电压呈抛物线。

CN\zhouxiong9 1 year ago
parent
commit
7bb9743ccf

+ 3 - 2
Core/Src/adc.c

@@ -532,12 +532,13 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
 	if( MC_HallSensorData.InverterExistFlag == FALSE )
 	{
 		Temp_32 = (ADC1_Result[ADC1_RANK_CURRENT] - uw_current_offset) * 39449 >> 10; //3300/4095* 0.98/8.2 /0.0025
+	  Temp_32 = (Temp_32 <= 0) ? 0 : ((Temp_32 >= 39449) ? 39448 : Temp_32);
 	}
 	else
 	{
 		Temp_32 = (ADC1_Result[ADC1_RANK_CURRENT] - uw_current_offset) * 50000 >> 11;  //3300/4095* 0.98/13 /0.0025
-	}
-	Temp_32 = (Temp_32 <= 0) ? 0 : ((Temp_32 >= 50000) ? 50000 : Temp_32);
+		Temp_32 = (Temp_32 <= 0) ? 0 : ((Temp_32 >= 50000) ? 50000 : Temp_32);
+	}	
 	IdcFltSum += ((Temp_32 << 10) - IdcFltSum) >> 9;
 	MC_RunInfo.BusCurrent = IdcFltSum >> 10;
 	

+ 8 - 17
J-scope.jscope

@@ -6,9 +6,9 @@
             <JLink>
                 <Options IsRTTSession="0" IsRTTWithTimeStamp="1" SamplingPeriod="100" Connection="1" SerialNo="0" IP="" TargetDevice="Cortex-M3" TargetInterface="SWD" InterfaceSpeed="4000" />
             </JLink>
-            <ElfFile Name="D:\SoftDesign\20190311_QD007A_CTL\TT-KZ-010A_CTRL_APP\TT-KZ-010A_CTRL_APP\MDK-ARM\QD007A_CTL_APP\QD007A_CTL_APP.axf" />
-            <DataFile Name="C:\Users\zhouxiong9\Desktop\PSXµ÷ÊÔÊý¾Ý\Data.csv\" />
-            <RawFile Name="C:\Users\zhouxiong9\Desktop\PSXµ÷ÊÔÊý¾Ý\Data.jraw\" />
+            <ElfFile Name="D:\MyData\zhouxiong9\Desktop\TT-KZ-010A_CTRL_APP\MDK-ARM\QD007A_CTL_APP\QD007A_CTL_APP.axf" />
+            <DataFile Name="" />
+            <RawFile Name="" />
             <Scope>
                 <Options TimeResolutionUs="500000" />
             </Scope>
@@ -19,28 +19,19 @@
         </Windows>
         <SelectedSymbols>
             <Symbol>
-                <Options Name="qI_Component1" Address="0x20000028" Type="short" TypeID="11" Size="2" GraphColorRed="255" GraphColorGreen="215" GraphColorBlue="0" YMinSampled="-797" YMaxSampled="1912" YAvgSampled="4" Offset="4" ShowInGraph="1" YOffset="300" IsAutoConfig="1" YResolution="1000" MaxValue="3000" File="..\User\Src\MC_Globals.c" Scope="0" DrawStyle="0" />
+                <Options Name="Ref_Torque" Address="0x200000D8" Type="short" TypeID="11" Size="2" GraphColorRed="255" GraphColorGreen="215" GraphColorBlue="0" YMinSampled="-1" YMaxSampled="24592" YAvgSampled="85" Offset="4" ShowInGraph="1" YOffset="200" IsAutoConfig="0" YResolution="1000" MaxValue="40000" File="..\User\Src\motor_control.c" Scope="0" DrawStyle="0" />
             </Symbol>
             <Symbol>
-                <Options Name="IqFdbFlt" Address="0x20000004" Type="int" TypeID="12" Size="4" GraphColorRed="0" GraphColorGreen="255" GraphColorBlue="0" YMinSampled="-1859" YMaxSampled="1241695" YAvgSampled="3772" Offset="6" ShowInGraph="1" YOffset="300" IsAutoConfig="1" YResolution="1000000" MaxValue="3000000" File="..\User\Src\MC_FOC_Driver.c" Scope="0" DrawStyle="0" />
+                <Options Name="Ref_Speed" Address="0x200000DA" Type="short" TypeID="11" Size="2" GraphColorRed="0" GraphColorGreen="255" GraphColorBlue="0" YMinSampled="-1" YMaxSampled="18461" YAvgSampled="0" Offset="6" ShowInGraph="1" YOffset="200" IsAutoConfig="0" YResolution="1000" MaxValue="20000" File="..\User\Src\motor_control.c" Scope="0" DrawStyle="0" />
             </Symbol>
             <Symbol>
-                <Options Name="Ref_Torque" Address="0x200000D8" Type="short" TypeID="11" Size="2" GraphColorRed="0" GraphColorGreen="0" GraphColorBlue="176" YMinSampled="-229" YMaxSampled="1050" YAvgSampled="8" Offset="10" ShowInGraph="1" YOffset="300" IsAutoConfig="1" YResolution="1000" MaxValue="3000" File="..\User\Src\motor_control.c" Scope="0" DrawStyle="0" />
+                <Options Name="BusCurrent" Address="0x2000081C" Type="ushort" TypeID="7" Size="2" GraphColorRed="0" GraphColorGreen="0" GraphColorBlue="176" YMinSampled="0" YMaxSampled="65535" YAvgSampled="2763" Offset="8" ShowInGraph="1" YOffset="200" IsAutoConfig="1" YResolution="20000" MaxValue="97600" File="..\User\Src\var.c" Scope="0" DrawStyle="0" />
             </Symbol>
             <Symbol>
-                <Options Name="ADC1_Result[1]" Address="0x20001EC6" Type="ushort" TypeID="11" Size="2" GraphColorRed="160" GraphColorGreen="32" GraphColorBlue="240" YMinSampled="2022" YMaxSampled="2998" YAvgSampled="2767" Offset="12" ShowInGraph="1" YOffset="300" IsAutoConfig="0" YResolution="1000" MaxValue="4000" File="..\Core\Src\adc.c" Scope="0" DrawStyle="0" />
+                <Options Name="qV_Component1" Address="0x2000002C" Type="short" TypeID="11" Size="2" GraphColorRed="255" GraphColorGreen="0" GraphColorBlue="0" YMinSampled="-27856" YMaxSampled="25557" YAvgSampled="3115" Offset="10" ShowInGraph="0" YOffset="200" IsAutoConfig="1" YResolution="20000" MaxValue="40000" File="..\User\Src\MC_Globals.c" Scope="0" DrawStyle="0" />
             </Symbol>
             <Symbol>
-                <Options Name="ADC1_Result[3]" Address="0x20001ECA" Type="ushort" TypeID="11" Size="2" GraphColorRed="255" GraphColorGreen="0" GraphColorBlue="0" YMinSampled="2029" YMaxSampled="3007" YAvgSampled="2035" Offset="14" ShowInGraph="1" YOffset="300" IsAutoConfig="0" YResolution="1000" MaxValue="4000" File="..\Core\Src\adc.c" Scope="0" DrawStyle="0" />
-            </Symbol>
-            <Symbol>
-                <Options Name="uw_phase_a" Address="0x20000514" Type="short" TypeID="11" Size="2" GraphColorRed="0" GraphColorGreen="191" GraphColorBlue="255" YMinSampled="-23125" YMaxSampled="24155" YAvgSampled="34" Offset="16" ShowInGraph="1" YOffset="100" IsAutoConfig="1" YResolution="20000" MaxValue="40000" File="..\Core\Src\adc.c" Scope="0" DrawStyle="0" />
-            </Symbol>
-            <Symbol>
-                <Options Name="uw_phase_b" Address="0x20000516" Type="short" TypeID="11" Size="2" GraphColorRed="0" GraphColorGreen="100" GraphColorBlue="0" YMinSampled="-23159" YMaxSampled="25801" YAvgSampled="-10" Offset="18" ShowInGraph="1" YOffset="100" IsAutoConfig="1" YResolution="20000" MaxValue="40000" File="..\Core\Src\adc.c" Scope="0" DrawStyle="0" />
-            </Symbol>
-            <Symbol>
-                <Options Name="uw_phase_c" Address="0x20000518" Type="short" TypeID="11" Size="2" GraphColorRed="205" GraphColorGreen="133" GraphColorBlue="63" YMinSampled="-24629" YMaxSampled="25371" YAvgSampled="66" Offset="20" ShowInGraph="1" YOffset="100" IsAutoConfig="1" YResolution="20000" MaxValue="40000" File="..\Core\Src\adc.c" Scope="0" DrawStyle="0" />
+                <Options Name="GasSensor" Address="0x20000510" Type="ushort" TypeID="7" Size="2" GraphColorRed="255" GraphColorGreen="0" GraphColorBlue="0" YMinSampled="0" YMaxSampled="65535" YAvgSampled="339" Offset="12" ShowInGraph="1" YOffset="200" IsAutoConfig="0" YResolution="2000" MaxValue="97600" File="..\Core\Src\adc.c" Scope="0" DrawStyle="0" />
             </Symbol>
         </SelectedSymbols>
     </Project>

+ 7 - 2
MDK-ARM/QD007A_CTL_APP.uvprojx

@@ -14,6 +14,8 @@
         <TargetCommonOption>
           <Device>STM32F103RB</Device>
           <Vendor>STMicroelectronics</Vendor>
+          <PackID>Keil.STM32F1xx_DFP.1.1.0</PackID>
+          <PackURL>http://www.keil.com/pack/</PackURL>
           <Cpu>IROM(0x08000000,0x20000) IRAM(0x20000000,0x5000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
           <FlashUtilSpec></FlashUtilSpec>
           <StartupFile></StartupFile>
@@ -82,6 +84,8 @@
             <UserProg2Name>.\crc_gen_keil.bat</UserProg2Name>
             <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
             <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopA1X>0</nStopA1X>
+            <nStopA2X>0</nStopA2X>
           </AfterMake>
           <SelectedForBatchBuild>0</SelectedForBatchBuild>
           <SVCSIdString></SVCSIdString>
@@ -125,7 +129,7 @@
             <LoadApplicationAtStartup>1</LoadApplicationAtStartup>
             <RunToMain>1</RunToMain>
             <RestoreBreakpoints>1</RestoreBreakpoints>
-            <RestoreWatchpoints>0</RestoreWatchpoints>
+            <RestoreWatchpoints>1</RestoreWatchpoints>
             <RestoreMemoryDisplay>1</RestoreMemoryDisplay>
             <RestoreFunctions>1</RestoreFunctions>
             <RestoreToolbox>1</RestoreToolbox>
@@ -143,7 +147,6 @@
             <RestoreToolbox>1</RestoreToolbox>
             <RestoreTracepoints>1</RestoreTracepoints>
             <RestoreSysVw>1</RestoreSysVw>
-            <UsePdscDebugDescription>1</UsePdscDebugDescription>
           </Target>
           <RunDebugAfterBuild>0</RunDebugAfterBuild>
           <TargetSelection>6</TargetSelection>
@@ -360,6 +363,8 @@
             <uSurpInc>0</uSurpInc>
             <uC99>1</uC99>
             <useXO>0</useXO>
+            <v6Lang>0</v6Lang>
+            <v6LangP>0</v6LangP>
             <VariousControls>
               <MiscControls></MiscControls>
               <Define>USE_HAL_DRIVER,STM32F103xB,PEGASI_48V</Define>

File diff suppressed because it is too large
+ 2625 - 2625
MDK-ARM/QD007A_CTL_APP/QD007A_CTL_APP_CRC.hex


BIN
MDK-ARM/bin/MC_PSX0XX(250K)-TC011000-MS0000-V7.2.2.0.0_20231115.bin


BIN
MDK-ARM/bin/QD007A_CTL_APP.bin


+ 2 - 0
User/Inc/MC_FOC_Driver.h

@@ -3,6 +3,8 @@
 
 #include "stm32f1xx_hal.h"
 
+extern int32_t IqFluxLessRef;
+extern int32_t IdFluxLessRef;
 extern int32_t IqFdbFlt;
 extern int32_t IdFdbFlt;
 extern int32_t VoltSquareFlt;

+ 3 - 2
User/Src/MC_FOC_Driver.c

@@ -10,6 +10,8 @@
 
 //全局变量定义
 
+int32_t IqFluxLessRef = 0;
+int32_t IdFluxLessRef = 0;
 int32_t IqFdbFlt = 0;
 int32_t IdFdbFlt = 0;
 int32_t VoltSquareFlt = 0;
@@ -25,8 +27,7 @@ void FOC_Model(int16_t Ref, int16_t MotorSpeed, uint16_t SVM_Angle)	  //
 	#if FluxWeak_Control
 	int32_t VoltSquare = 0;    //弱磁控制预留
 	int32_t VoltMax = 0; 
-	#endif
-	static int32_t IdFluxLessRef = 0, IqFluxLessRef = 0;
+	#endif 
 	int32_t UqCal = 0;
 	static int32_t FOC_IqLim = 0;
 	Curr_Components Stat_Curr_a_b;       // Stator currents Ia,Ib

+ 1 - 1
User/Src/MC_PID_regulators.c

@@ -327,7 +327,7 @@ const PID_Struct_t PID_Torque_InitStructure_Pegasi_Plus =
   (int16_t)0,          //hKd_Gain
   (uint16_t)1024,      //hKd_Divisor
   (int32_t)0,          //wPreviousError
-  (int32_t)-100,     //hLower_Limit_Output   //电流环给微弱的负值,给转子施加反向扭矩让电机可以缓慢降速
+  (int32_t)-100,       //hLower_Limit_Output   //电流环给微弱的负值,给转子施加反向扭矩让电机可以缓慢降速
   (int32_t)32767,      //hUpper_Limit_Output
   (int32_t)(-32768 * 1024),  //wLower_Limit_Integral
   (int32_t)(32767 * 1024),   //wUpper_Limit_Integral

+ 8 - 5
User/Src/motor_control.c

@@ -527,8 +527,8 @@ MC_CalParam_Struct_t MC_AssistRunMode_GasTorque_Process(MC_GasMode_Struct_t GasM
 	static uint8_t TorqueRefEndUpdateCount = 0;
 	
 	
-	//踩踏力矩输入
-  MC_TorqueProcess_Param.TorqueApp = (GasSensorData < TorqueSensorData) ? TorqueSensorData : GasSensorData;
+	//力矩输入
+  MC_TorqueProcess_Param.TorqueApp = (GasSensorData < TorqueSensorData) ? ((TorqueSensorData * TorqueSensorData) >> 11) : ((GasSensorData * GasSensorData) >> 11);
 	MC_TorqueProcess_Param.TorqueApp = (MC_TorqueProcess_Param.TorqueApp > 2048) ? 2048 : MC_TorqueProcess_Param.TorqueApp;
 
   //输出目标力矩
@@ -757,14 +757,15 @@ MC_CalParam_Struct_t MC_AssistRunMode_GasTorque_Process(MC_GasMode_Struct_t GasM
 	#endif
 	
 	//根据SOC计算限流
-	IqRefByInPower = PID_Regulator((CurrentLimitPresent * MC_LimitCurrent_Cal_K_BySOC((((MC_ConfigParam1.CurrentLimit >> 7) & 0x01) == 0 ? ENABLE : DISABLE), MC_RunInfo.SOC) / 100) >> 10, (MC_RunInfo.BusCurrent >> 7), &PID_IMax);
+	IqRefByInPower = PID_Regulator((CurrentLimitPresent * MC_LimitCurrent_Cal_K_BySOC((((MC_ConfigParam1.CurrentLimit >> 7) & 0x01) == 0 ? ENABLE : DISABLE), MC_RunInfo.SOC) / 100) >> 10, 
+	                               (MC_RunInfo.BusCurrent >> 7), &PID_IMax);
 		
 	Torque_Ref_Temp = ((int32_t)MC_TorqueProcess_Param.TorqueRefEnd * K_ByVoltage_Result) >> 10;
 	Torque_Ref_Temp = (Torque_Ref_Temp * K_ByTemperature_Result) >> 10;
 	Torque_Ref_Temp = (Torque_Ref_Temp + IqRefByInPower) >> 1;
 	
 	//Iq输出
-	p_MC_CalParam.Ref_Torque = (int16_t)Torque_Ref_Temp;
+	p_MC_CalParam.Ref_Torque = (int16_t)(Torque_Ref_Temp < 0 ? 0 : Torque_Ref_Temp);
 	p_MC_CalParam.Foc_Flag = SET;
 	p_MC_CalParam.AssistRunMode = MC_AssistRunMode_GAS;
 	
@@ -1395,7 +1396,7 @@ MC_CalParam_Struct_t MC_AssistRunMode_Torque_Process(uint16_t SenorData, MC_Gear
 	Torque_Ref_Temp = (Torque_Ref_Temp + IqRefByInPower) >> 1;
 	
 	//Iq输出
-	p_MC_CalParam.Ref_Torque = (int16_t)Torque_Ref_Temp;
+	p_MC_CalParam.Ref_Torque = (int16_t)(Torque_Ref_Temp < 0 ? 0 : Torque_Ref_Temp);;
 	p_MC_CalParam.Foc_Flag = SET;
 	p_MC_CalParam.AssistRunMode = MC_AssistRunMode_TORQUE;
 	
@@ -1474,6 +1475,8 @@ void MC_ControlParam_Init(void)
 	MC_TorqueProcess_Param.TorqueRefEnd = 0;
 	
 	//全局运算变量归零
+	IqFluxLessRef = 0;
+	IdFluxLessRef = 0;
 	IqFdbFlt =0;
 	IdFdbFlt = 0;
 	VoltSquareFlt = 0;

+ 3 - 3
User/Src/tasks.c

@@ -304,14 +304,14 @@ void MC_DebugInfo_Update(void)
 		MC_DebugInfo.SysFSM2 = FOC_Status;                                //FOC状态
 		MC_DebugInfo.SysFSM3 = 0;
 		MC_DebugInfo.SysFSM4 = 0;
-		MC_DebugInfo.IdRef = Stat_Curr_q_d.qI_Component2;                 //IdRef
-		MC_DebugInfo.IqRef = Stat_Curr_q_d.qI_Component1;                 //IqRef
+		MC_DebugInfo.IdRef = IqFluxLessRef;                               //IdRef
+		MC_DebugInfo.IqRef = IdFluxLessRef;                               //IqRef
 		MC_DebugInfo.UdRef = Stat_Volt_q_d.qV_Component2;                 //UdRef
 		MC_DebugInfo.UqRef = Stat_Volt_q_d.qV_Component1;                 //UqRef
 		MC_DebugInfo.PedalTorquePer = ADC_SensorData.TorqueSensor;        //力矩AD,减去零点
 		MC_DebugInfo.PedalTorqueAvg = ADC_SensorData.GasSensor;           //转把AD,减去零点
 		MC_DebugInfo.PedalTorqueByCad = MC_CadenceResult.torqueByCadence; //力矩AD,根据踏频滤波
-		MC_DebugInfo.IdFdb = IdFdbFlt >> 10;                              //IddFdb
+		MC_DebugInfo.IdFdb = IdFdbFlt >> 10;                              //IdFdb
 		MC_DebugInfo.IqFdb = IqFdbFlt >> 10;                              //IqFdb
 		if(MC_CalParam.AssistRunMode == MC_AssistRunMode_TORQUE)
 			MC_DebugInfo.AssistOut = MC_CalParam.Ref_Torque;

Some files were not shown because too many files changed in this diff