akiyoshi oguro
/
Nucleo_Hall_rect_sin
CCW CW Control BLDC
IO_define.h
- Committer:
- oguro
- Date:
- 2020-11-14
- Revision:
- 1:333d2cdd26d0
- Parent:
- 0:faa58403944a
File content as of revision 1:333d2cdd26d0:
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); 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); unsigned int UP,VP,WP; 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=5.0,STOP=1.0,power;//START=10.0 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; float tau=80; //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; 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 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 su,sv,sw; float Vd,Vq; float Wz,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; //3.0f/5.0f; 0.45 float aVa; float a3Vb; float W,Ed; float errth,vst; float z=0.5;//0.7 float Va,Vb; float d1,d2,d3,d4,d5,d6,d07; float du,dv,dw;