![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
CCW CW Control BLDC
IO_define.h@1:333d2cdd26d0, 2020-11-14 (annotated)
- Committer:
- oguro
- Date:
- Sat Nov 14 02:43:13 2020 +0000
- Revision:
- 1:333d2cdd26d0
- Parent:
- 0:faa58403944a
test senina
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
oguro | 0:faa58403944a | 1 | Serial pc(USBTX,USBRX); |
oguro | 0:faa58403944a | 2 | |
oguro | 0:faa58403944a | 3 | PwmOut PWM_IN1_U(PA_8); |
oguro | 0:faa58403944a | 4 | PwmOut PWM_IN2_V(PA_9); |
oguro | 0:faa58403944a | 5 | PwmOut PWM_IN3_W(PA_10); |
oguro | 0:faa58403944a | 6 | |
oguro | 0:faa58403944a | 7 | DigitalOut EN1_U(PC_10); |
oguro | 0:faa58403944a | 8 | DigitalOut EN2_V(PC_11); |
oguro | 0:faa58403944a | 9 | DigitalOut EN3_W(PC_12); |
oguro | 0:faa58403944a | 10 | |
oguro | 0:faa58403944a | 11 | DigitalIn HALL_U(PA_15); |
oguro | 0:faa58403944a | 12 | DigitalIn HALL_V(PB_3); |
oguro | 0:faa58403944a | 13 | DigitalIn HALL_W(PB_10); |
oguro | 0:faa58403944a | 14 | |
oguro | 0:faa58403944a | 15 | /*DigitalIn HALL_U(PC_8); |
oguro | 0:faa58403944a | 16 | DigitalIn HALL_V(PC_6); |
oguro | 0:faa58403944a | 17 | DigitalIn HALL_W(PC_10);*/ |
oguro | 0:faa58403944a | 18 | |
oguro | 0:faa58403944a | 19 | |
oguro | 0:faa58403944a | 20 | /*InterruptIn HALL_Ui(PC_8); |
oguro | 0:faa58403944a | 21 | InterruptIn HALL_Vi(PC_6); |
oguro | 0:faa58403944a | 22 | InterruptIn HALL_Wi(PC_5);*/ |
oguro | 0:faa58403944a | 23 | |
oguro | 0:faa58403944a | 24 | InterruptIn HALL_Ui(PA_15); |
oguro | 0:faa58403944a | 25 | InterruptIn HALL_Vi(PB_3); |
oguro | 0:faa58403944a | 26 | InterruptIn HALL_Wi(PB_10); |
oguro | 0:faa58403944a | 27 | |
oguro | 0:faa58403944a | 28 | AnalogIn V_adc(PC_2); // gaibu Volume |
oguro | 0:faa58403944a | 29 | //AnalogIn V_adc(PB_1); //On Board Volume |
oguro | 0:faa58403944a | 30 | AnalogIn Curr_ui(PA_0); |
oguro | 0:faa58403944a | 31 | AnalogIn Curr_vi(PC_1); |
oguro | 0:faa58403944a | 32 | AnalogIn Curr_wi(PC_0); |
oguro | 0:faa58403944a | 33 | |
oguro | 0:faa58403944a | 34 | AnalogOut aout(PA_4); |
oguro | 0:faa58403944a | 35 | |
oguro | 1:333d2cdd26d0 | 36 | unsigned int UP,VP,WP; |
oguro | 0:faa58403944a | 37 | float Vr_adc,Vr_adc_i; |
oguro | 0:faa58403944a | 38 | |
oguro | 0:faa58403944a | 39 | unsigned short SH,frd=1,q; |
oguro | 0:faa58403944a | 40 | short f1=0,a1=0,f1c=0,a1c=0; |
oguro | 1:333d2cdd26d0 | 41 | float kido=0.5,START=5.0,STOP=1.0,power;//START=10.0 |
oguro | 0:faa58403944a | 42 | float y,ay,Speed; |
oguro | 0:faa58403944a | 43 | |
oguro | 0:faa58403944a | 44 | float ut1=0,ut2=0,usi=0; |
oguro | 0:faa58403944a | 45 | float vt1=0,vt2=0,vsi=0; |
oguro | 0:faa58403944a | 46 | float wt1=0,wt2=0,wsi=0; |
oguro | 0:faa58403944a | 47 | float ut1c=0,ut2c=0,usic=0; |
oguro | 0:faa58403944a | 48 | |
oguro | 1:333d2cdd26d0 | 49 | float tau=80; //drone 50 |
oguro | 0:faa58403944a | 50 | float zint=tau*1E-6; |
oguro | 0:faa58403944a | 51 | |
oguro | 0:faa58403944a | 52 | Timer uT; |
oguro | 0:faa58403944a | 53 | Timer vT; |
oguro | 0:faa58403944a | 54 | Timer wT; |
oguro | 0:faa58403944a | 55 | Timer uTc; |
oguro | 0:faa58403944a | 56 | |
oguro | 0:faa58403944a | 57 | Ticker zt; |
oguro | 0:faa58403944a | 58 | Ticker ztc; |
oguro | 0:faa58403944a | 59 | Ticker cnt; |
oguro | 0:faa58403944a | 60 | |
oguro | 0:faa58403944a | 61 | float Curr_u=0,Curr_uf=0,iu; |
oguro | 0:faa58403944a | 62 | float Curr_v=0,Curr_vf=0,iv; |
oguro | 0:faa58403944a | 63 | float Curr_w=0,Curr_wf=0,iw; |
oguro | 0:faa58403944a | 64 | |
oguro | 0:faa58403944a | 65 | short uz[5]={0x7FFF,0xC000,0,0x0001,0};//a1,a2,f0,f1,f2 |
oguro | 0:faa58403944a | 66 | short vz[5]={0x7FFF,0xC000,0,0x0001,0};//a1,a2,f0,f1,f2 |
oguro | 0:faa58403944a | 67 | short wz[5]={0x7FFF,0xC000,0,0x0001,0};//a1,a2,f0,f1,f2 |
oguro | 0:faa58403944a | 68 | |
oguro | 0:faa58403944a | 69 | short uc[5]={0x7FFF,0xC000,0,0x0001,0};//a1,a2,f0,f1,f2 |
oguro | 0:faa58403944a | 70 | |
oguro | 0:faa58403944a | 71 | float PI=3.141592; |
oguro | 0:faa58403944a | 72 | float ia=0,iaf=0,ib=0,ibf=0,iq=0,iqf=0,id=0,idf=0; |
oguro | 0:faa58403944a | 73 | float th; |
oguro | 0:faa58403944a | 74 | |
oguro | 0:faa58403944a | 75 | float zet=sqrt(2.0f/3.0f),cos23=cos((2.0f/3.0f)*PI); |
oguro | 0:faa58403944a | 76 | float cos43=cos((4.0f/3.0f)*PI),sin23=sin((2.0f/3.0f)*PI),sin43=sin((4.0f/3.0f)*PI); |
oguro | 0:faa58403944a | 77 | |
oguro | 0:faa58403944a | 78 | float sinth,costh; |
oguro | 0:faa58403944a | 79 | float id_diff,id_p,iq_diff,iq_p; |
oguro | 0:faa58403944a | 80 | float s_ki_id, ki_id,kp_id, s_ki_iq ,ki_iq,kp_iq; |
oguro | 1:333d2cdd26d0 | 81 | float su,sv,sw; |
oguro | 0:faa58403944a | 82 | |
oguro | 0:faa58403944a | 83 | float Vd,Vq; |
oguro | 0:faa58403944a | 84 | float Wz,s_ki_errth,s_kp_errth,derrth; |
oguro | 0:faa58403944a | 85 | float therr,dth,eth,phm; |
oguro | 0:faa58403944a | 86 | float sq32=sqrt(3.0f/2.0f); |
oguro | 0:faa58403944a | 87 | float sq23=2.0f/sqrt(3.0f); |
oguro | 0:faa58403944a | 88 | float sq3=1.0f/sqrt(3.0f); |
oguro | 0:faa58403944a | 89 | float Vdlink=0.6; //3.0f/5.0f; 0.45 |
oguro | 0:faa58403944a | 90 | float aVa; |
oguro | 0:faa58403944a | 91 | float a3Vb; |
oguro | 0:faa58403944a | 92 | |
oguro | 0:faa58403944a | 93 | float W,Ed; |
oguro | 0:faa58403944a | 94 | float errth,vst; |
oguro | 0:faa58403944a | 95 | |
oguro | 0:faa58403944a | 96 | float z=0.5;//0.7 |
oguro | 0:faa58403944a | 97 | float Va,Vb; |
oguro | 0:faa58403944a | 98 | float d1,d2,d3,d4,d5,d6,d07; |
oguro | 0:faa58403944a | 99 | float du,dv,dw; |
oguro | 0:faa58403944a | 100 |