![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Trapezoid sin Vector
Diff: IO_define.h
- Revision:
- 0:fa432f8ea1a6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IO_define.h Fri Jun 28 11:52:27 2019 +0000 @@ -0,0 +1,113 @@ +Serial pc(USBTX,USBRX); + +PwmOut PWM_IN1_U(PA_8); +PwmOut PWM_IN2_V(PA_9); +PwmOut PWM_IN3_W(PA_10); + +DigitalOut EN1_U(PC_10); +DigitalOut EN2_V(PC_11); +DigitalOut EN3_W(PC_12); + +DigitalOut Vector(PC_4); + +DigitalIn HALL_U(PA_15); +DigitalIn HALL_V(PB_3); +DigitalIn HALL_W(PB_10); + +/*DigitalIn HALL_U(PC_8); +DigitalIn HALL_V(PC_6); +DigitalIn HALL_W(PC_10);*/ + + +/*InterruptIn HALL_Ui(PC_8); +InterruptIn HALL_Vi(PC_6); +InterruptIn HALL_Wi(PC_5);*/ + +InterruptIn HALL_Ui(PA_15); +InterruptIn HALL_Vi(PB_3); +InterruptIn HALL_Wi(PB_10); + +AnalogIn V_adc(PC_2); // gaibu Volume +//AnalogIn V_adc(PB_1); //On Board Volume +AnalogIn Curr_ui(PA_0); +AnalogIn Curr_vi(PC_1); +AnalogIn Curr_wi(PC_0); + +AnalogOut aout(PA_4); + +float Vr_adc,Vr_adc_i; + +unsigned short SH,frd=1,q; +short f1=0,a1=0,f1c=0,a1c=0; +float kido=0.5,START=10.0,STOP=1.0,power; +float y,ay,Speed; + +float ut1=0,ut2=0,usi=0; +float vt1=0,vt2=0,vsi=0; +float wt1=0,wt2=0,wsi=0; +float ut1c=0,ut2c=0,usic=0; +unsigned int ui=0,vi=0,wi=0,et=0; +int r=0,i=0,s=0; +float Xin,Xout; + +float thave,th,thu,thv,thw,Ed,Vd,Vq,Vqi,West,Wz,Wo,Icom,Wcom; +float vst=0,vstt=0,vsti=0,vstf=0,Edw=0; +float iso=0,Vqp; +//float tau=50; //drone 50 +//float zint=tau*1E-6; + +Timer uT; +Timer vT; +Timer wT; +Timer uTc; + +Ticker zt; +Ticker ztc; +Ticker cnt; + +float Curr_u=0,Curr_uf=0,iu; +float Curr_v=0,Curr_vf=0,iv; +float Curr_w=0,Curr_wf=0,iw; +float iuvw[3]; +float iab[2],Vab[2]; +float idq[2],idqi[2],idqo[2]; + +float Idin,Vdout,Iqin,Vqout,Xsi; + +short uz[5]={0x7FFF,0xC000,0,0x0001,0};//a1,a2,f0,f1,f2 +short vz[5]={0x7FFF,0xC000,0,0x0001,0};//a1,a2,f0,f1,f2 +short wz[5]={0x7FFF,0xC000,0,0x0001,0};//a1,a2,f0,f1,f2 + +short uc[5]={0x7FFF,0xC000,0,0x0001,0};//a1,a2,f0,f1,f2 +short vc[5]={0x7FFF,0xC000,0,0x0001,0};//a1,a2,f0,f1,f2 +short wc[5]={0x7FFF,0xC000,0,0x0001,0};//a1,a2,f0,f1,f2 + +float PI=3.141592; +float ia=0,iaf=0,ib=0,ibf=0,iq=0,iqf=0,id=0,idf=0; +//float th; + +float zet=sqrt(2.0f/3.0f),cos23=cos((2.0f/3.0f)*PI); +float cos43=cos((4.0f/3.0f)*PI),sin23=sin((2.0f/3.0f)*PI),sin43=sin((4.0f/3.0f)*PI); + +float sinth,costh; +float id_diff,id_p,iq_diff,iq_p; +float s_ki_id, ki_id,kp_id, s_ki_iq ,ki_iq,kp_iq; +float Wnon,Ednon,W,PLL; +//float Vd,Vq; +float s_ki_errth,s_kp_errth,derrth; +float therr,dth,eth,phm; +float sq32=sqrt(3.0f/2.0f); +float sq23=2.0f/sqrt(3.0f); +float sq3=1.0f/sqrt(3.0f); +float Vdlink=0.6; //0.6 +float aVa; +float a3Vb; + +float errth; +float su=0,sv=0,sw=0,suv=0,svv=0,swv=0; + +float z=0.3;//0.5 +float Va,Vb; +float d1,d2,d3,d4,d5,d6,d07; +float du,dv,dw; +