akiyoshi oguro
/
Vector_sin_drive_F302R8_2
FOC sinewave drive ver2
Revision 1:e45063ee4be0, committed 2020-11-18
- Comitter:
- oguro
- Date:
- Wed Nov 18 06:24:19 2020 +0000
- Parent:
- 0:dcfc6150c1d6
- Commit message:
- Refine Vector Sine Wave 2
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r dcfc6150c1d6 -r e45063ee4be0 main.cpp --- a/main.cpp Fri Aug 21 01:45:36 2020 +0000 +++ b/main.cpp Wed Nov 18 06:24:19 2020 +0000 @@ -2,7 +2,7 @@ #include "rtos.h" #define TS1 0.2 #include <math.h> -int q=0,START=20,i=0,s=0,vector; +int q=0,START=10,i=0,s=0,vector; float uii=0,ut=0,ut1=0,ut2=0,usi=0; float vii=0,vt=0,vt1=0,vt2=0,vsi=0; float wii=0,wt=0,wt1=0,wt2=0,wsi=0; @@ -209,7 +209,7 @@ if((Vr_adc>0.08f)&&(q==0)){ while(q<10){ - #if 0 + #if 1 mypwmA.write(0.5f); mypwmB.write(0); mypwmC.write(0); @@ -225,7 +225,7 @@ mypwmC.write(0.5f); wait_ms(START); #endif - #if 1 + #if 0 EN1=1; EN2=1; EN3=0; @@ -413,9 +413,9 @@ EN1=1; EN2=1; EN3=1; - mypwmA.write(uvect); + mypwmA.write(wvect); mypwmB.write(vvect); - mypwmC.write(wvect); + mypwmC.write(uvect); } myled = !myled; @@ -564,7 +564,7 @@ Xin=6500*(1.25-Vr_adc)-vst; // 6500 1.15 float a,b,c,work[2]; float kp=1.1,ki=0.7,kd=0.0; // 1.2 0.7 0.0 - float dt=10.0E-6;//100E-6 + float dt=100E-6;//100E-6 a=Xin; b=work[1]+(Xin+work[0])/2.0*dt; c=(Xin-work[0])/dt; @@ -573,7 +573,7 @@ Xout=a*kp+b*ki+c*kd; vstt=Xout; /********************************/ - if(2000>abs(vst-vstt)){ + if(3000>abs(vst-vstt)){ //2000 vsti=vstt; //vstt vector=1; }