瀏覽代碼

SVPWM调制设置1,pwm duty 放置饱和

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 3 年之前
父節點
當前提交
58e259f377
共有 4 個文件被更改,包括 19 次插入3 次删除
  1. 2 2
      Applications/foc/core/PMSM_FOC_Core.c
  2. 14 0
      Applications/foc/core/svpwm.c
  3. 1 1
      Applications/foc/foc_config.h
  4. 2 0
      Project/GD32_DEMO.uvoptx

+ 2 - 2
Applications/foc/core/PMSM_FOC_Core.c

@@ -197,7 +197,7 @@ void PMSM_FOC_Schedule(void) {
 
 	PMSM_FOC_Update_Hardware();
 	if (_gFOC_Ctrl.ctrl_count % 5 == 0) {
-		plot_3data16(FtoS16x1000(iabc[0]), FtoS16x1000(iabc[1]), _gFOC_Ctrl.out.test_sample * 100);
+		///plot_3data16(FtoS16x1000(iabc[0]), FtoS16x1000(iabc[1]), _gFOC_Ctrl.out.test_sample * 100);
 	}
 
 	if (_gFOC_Ctrl.out.n_RunMode != CTRL_MODE_OPEN) {
@@ -241,7 +241,7 @@ void PMSM_FOC_Schedule(void) {
 		//plot_2data16(_gFOC_Ctrl.in.s_motRPM, FtoS16x1000(_gFOC_Ctrl.in.s_targetTorque));
 		//plot_2data16(FtoS16(_gFOC_Ctrl.in.s_hallAngle), FtoS16(_gFOC_Ctrl.in.s_motAngle));
 		//plot_3data16(_gFOC_Ctrl.in.s_motRPM, FtoS16x1000(_gFOC_Ctrl.out.s_OutVdq.d), FtoS16x1000(_gFOC_Ctrl.out.s_OutVdq.q));
-		//plot_3data16(FtoS16x1000(iabc[0]), FtoS16x1000(iabc[1]), FtoS16x1000(iabc[2]));
+		plot_3data16(FtoS16x1000(iabc[0]), FtoS16x1000(iabc[1]), FtoS16x1000(iabc[2]));
 		//plot_1data16(FtoS16(_gFOC_Ctrl.in.s_hallAngle));
 	}	
 }

+ 14 - 0
Applications/foc/core/svpwm.c

@@ -524,6 +524,14 @@ void SVM_Duty_Fix(AB_t *alb, s16q5_t vbus, u32 PWM_half_period, FOC_OutP *out) {
 }
 
 #else
+#define Duty_Sat(max, t1, t2) \
+	do { \
+		if (t1+t2 > max) { \
+			float r = (float)max/(float)(t1 + t2); \
+			t1 = r * t1; \
+			t2 = r * t2; \
+		} \
+	}while(0);
 void SVM_Duty_Fix(AB_t *alb, s16q5_t vbus, u32 PWM_half_period, FOC_OutP *out) {
 	float alpha = (alb->a) * SQRT3_BY_2;
 	float beta  = (alb->b)  * SQRT3_BY_2;
@@ -578,6 +586,7 @@ void SVM_Duty_Fix(AB_t *alb, s16q5_t vbus, u32 PWM_half_period, FOC_OutP *out) {
 		case SECTOR_1: // 3
 		{	u32 T4 = -Z;
 			u32 T6 = X;
+			Duty_Sat(PWM_Period, T4, T6);
 			tC = (PWM_Period - T4 - T6)/4;
         	tB = tC + T6/2;
         	tA = tB + T4/2;
@@ -589,6 +598,7 @@ void SVM_Duty_Fix(AB_t *alb, s16q5_t vbus, u32 PWM_half_period, FOC_OutP *out) {
 		{
 			u32 T6 = Y;
 			u32 T2 = Z;
+			Duty_Sat(PWM_Period, T2, T6);
 			tC = (PWM_Period - T6 - T2)/4;
         	tA = tC + T6/2;
         	tB = tA + T2/2;
@@ -600,6 +610,7 @@ void SVM_Duty_Fix(AB_t *alb, s16q5_t vbus, u32 PWM_half_period, FOC_OutP *out) {
 		{
 			u32 T2 = X;
 			u32 T3 = -Y;
+			Duty_Sat(PWM_Period, T2, T3);
 			tA = (PWM_Period - T2 - T3)/4;
 			tC = tA + T3/2;
 			tB = tC + T2/2;
@@ -611,6 +622,7 @@ void SVM_Duty_Fix(AB_t *alb, s16q5_t vbus, u32 PWM_half_period, FOC_OutP *out) {
 		{
 			u32 T1 = -X;
 			u32 T3 = Z;
+			Duty_Sat(PWM_Period, T1, T3);
 			tA = (PWM_Period - T1 - T3)/4;
 			tB = tA + T3/2;
 			tC = tB + T1/2;
@@ -622,6 +634,7 @@ void SVM_Duty_Fix(AB_t *alb, s16q5_t vbus, u32 PWM_half_period, FOC_OutP *out) {
 		{
 			u32 T1 = -Y;
 			u32 T5 = -Z;
+			Duty_Sat(PWM_Period, T1, T5);
 			tB = (PWM_Period - T1 - T5)/4;
 			tA = tB + T5/2;
 			tC = tA + T1/2;
@@ -633,6 +646,7 @@ void SVM_Duty_Fix(AB_t *alb, s16q5_t vbus, u32 PWM_half_period, FOC_OutP *out) {
 		{
 			u32 T4 = Y;
 			u32 T5 = -X;
+			Duty_Sat(PWM_Period, T4, T5);
 			tB = (PWM_Period - T4 - T5)/4;
 			tC = tB + T5/2;
 			tA = tC + T4/2;

+ 1 - 1
Applications/foc/foc_config.h

@@ -34,7 +34,7 @@
 #define VDQ_RAMP_FINAL_TIME 3000
 #define CURRENT_BANDWITH 1000 /* 电流环带宽 */
 
-#define SVM_Modulation (0.96f)
+#define SVM_Modulation 1.0f //(0.96f)
 
 #endif /* _FOC_CONFIG_H__ */
 

+ 2 - 0
Project/GD32_DEMO.uvoptx

@@ -120,6 +120,8 @@
         <SetRegEntry>
           <Number>0</Number>
           <Key>DLGUARM</Key>
+          <Name> ?
+?</Name>
         </SetRegEntry>
         <SetRegEntry>
           <Number>0</Number>