![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
CCW CW Control BLDC
vector.h@0:faa58403944a, 2019-02-17 (annotated)
- Committer:
- oguro
- Date:
- Sun Feb 17 02:58:08 2019 +0000
- Revision:
- 0:faa58403944a
CCW/CW Control Kukei seigen HA
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
oguro | 0:faa58403944a | 1 | /***************Current Filter ************************/ |
oguro | 0:faa58403944a | 2 | void filterCurrent(){ |
oguro | 0:faa58403944a | 3 | float Itau=0.1,Idt=0.1; // Itau=1.0E-6,Idt=1.0E-6; |
oguro | 0:faa58403944a | 4 | /****Filter Iu********/ |
oguro | 0:faa58403944a | 5 | float Iu1,Iu2,Iu3,Iu4;//0.01 |
oguro | 0:faa58403944a | 6 | Iu1=Idt*(Curr_ui-Curr_u)/Itau; |
oguro | 0:faa58403944a | 7 | Iu2=Idt*(Curr_ui-(Curr_u+Iu1/2.0))/Itau; |
oguro | 0:faa58403944a | 8 | Iu3=Idt*(Curr_ui-(Curr_u+Iu2/2.0))/Itau; |
oguro | 0:faa58403944a | 9 | Iu4=Idt*(Curr_ui-(Curr_u+Iu3/2.0))/Itau; |
oguro | 0:faa58403944a | 10 | Curr_u=Curr_u+(Iu1+2.0*Iu2+2.0*Iu3+Iu4)/6.0; |
oguro | 0:faa58403944a | 11 | Curr_uf +=(Curr_u-Curr_uf)*0.2; |
oguro | 0:faa58403944a | 12 | /****Filter Iv********/ |
oguro | 0:faa58403944a | 13 | float Iv1,Iv2,Iv3,Iv4;//0.01 |
oguro | 0:faa58403944a | 14 | Iv1=Idt*(Curr_vi-Curr_v)/Itau; |
oguro | 0:faa58403944a | 15 | Iv2=Idt*(Curr_vi-(Curr_v+Iv1/2.0))/Itau; |
oguro | 0:faa58403944a | 16 | Iv3=Idt*(Curr_vi-(Curr_v+Iv2/2.0))/Itau; |
oguro | 0:faa58403944a | 17 | Iv4=Idt*(Curr_vi-(Curr_v+Iv3/2.0))/Itau; |
oguro | 0:faa58403944a | 18 | Curr_v=Curr_v+(Iv1+2.0*Iv2+2.0*Iv3+Iv4)/6.0; |
oguro | 0:faa58403944a | 19 | Curr_vf +=(Curr_v-Curr_vf)*0.2; |
oguro | 0:faa58403944a | 20 | /****Filter Iw********/ |
oguro | 0:faa58403944a | 21 | float Iw1,Iw2,Iw3,Iw4;//0.01 |
oguro | 0:faa58403944a | 22 | Iw1=Idt*(Curr_wi-Curr_w)/Itau; |
oguro | 0:faa58403944a | 23 | Iw2=Idt*(Curr_wi-(Curr_w+Iw1/2.0))/Itau; |
oguro | 0:faa58403944a | 24 | Iw3=Idt*(Curr_wi-(Curr_w+Iw2/2.0))/Itau; |
oguro | 0:faa58403944a | 25 | Iw4=Idt*(Curr_wi-(Curr_w+Iw3/2.0))/Itau; |
oguro | 0:faa58403944a | 26 | Curr_w=Curr_w+(Iw1+2.0*Iw2+2.0*Iw3+Iw4)/6.0; |
oguro | 0:faa58403944a | 27 | Curr_wf +=(Curr_w-Curr_wf)*0.2; |
oguro | 0:faa58403944a | 28 | /*************************************/ |
oguro | 0:faa58403944a | 29 | iu = -(Curr_uf - 0.5)/0.1 - 0.5; |
oguro | 0:faa58403944a | 30 | iv = -(Curr_vf - 0.5)/0.1 - 0.5; |
oguro | 0:faa58403944a | 31 | iw = -(Curr_wf - 0.5)/0.1 - 0.5; |
oguro | 0:faa58403944a | 32 | |
oguro | 0:faa58403944a | 33 | } |
oguro | 0:faa58403944a | 34 | /***********************************************************************/ |
oguro | 0:faa58403944a | 35 | |
oguro | 0:faa58403944a | 36 | |
oguro | 0:faa58403944a | 37 | /************Space Vector PWM***************/ |
oguro | 0:faa58403944a | 38 | void SVPWM(){ |
oguro | 0:faa58403944a | 39 | aVa=abs(Va); |
oguro | 0:faa58403944a | 40 | a3Vb=abs(sq3*Vb); |
oguro | 0:faa58403944a | 41 | if((Va>=0)&&(Vb>=0)&&(aVa>=a3Vb)){ //sect 0 |
oguro | 0:faa58403944a | 42 | |
oguro | 0:faa58403944a | 43 | d1=sq32*(Va-sq3*Vb)*Vdlink; |
oguro | 0:faa58403944a | 44 | d2=sq32*(sq23*Vb)*Vdlink; |
oguro | 0:faa58403944a | 45 | d07=(z-(d1+d2))*0.5; |
oguro | 0:faa58403944a | 46 | // d07=0; |
oguro | 0:faa58403944a | 47 | du=d1+d2+d07; |
oguro | 0:faa58403944a | 48 | dv=d2+d07; |
oguro | 0:faa58403944a | 49 | dw=d07; |
oguro | 0:faa58403944a | 50 | |
oguro | 0:faa58403944a | 51 | } |
oguro | 0:faa58403944a | 52 | if((aVa<=sq3*Vb)){ //sect 1 |
oguro | 0:faa58403944a | 53 | |
oguro | 0:faa58403944a | 54 | d3=sq32*(-Va+sq3*Vb)*Vdlink; |
oguro | 0:faa58403944a | 55 | d2=sq32*(Va+sq3*Vb)*Vdlink; |
oguro | 0:faa58403944a | 56 | d07=(z-(d2+d3))*0.5; |
oguro | 0:faa58403944a | 57 | //d07=0; |
oguro | 0:faa58403944a | 58 | du=d2+d07; |
oguro | 0:faa58403944a | 59 | dv=d2+d3+d07; |
oguro | 0:faa58403944a | 60 | dw=d07; |
oguro | 0:faa58403944a | 61 | } |
oguro | 0:faa58403944a | 62 | |
oguro | 0:faa58403944a | 63 | if((Va<=0)&&(Vb>=0)&&(aVa>=a3Vb)){ //sect 2 |
oguro | 0:faa58403944a | 64 | |
oguro | 0:faa58403944a | 65 | d3=sq32*sq23*Vb*Vdlink; |
oguro | 0:faa58403944a | 66 | d4=sq32*(-Va-sq3*Vb)*Vdlink; |
oguro | 0:faa58403944a | 67 | d07=(z-(d3+d4))*0.5; |
oguro | 0:faa58403944a | 68 | // d07=0; |
oguro | 0:faa58403944a | 69 | du=d07; |
oguro | 0:faa58403944a | 70 | dv=d3+d4+d07; |
oguro | 0:faa58403944a | 71 | dw=d4+d07; |
oguro | 0:faa58403944a | 72 | } |
oguro | 0:faa58403944a | 73 | |
oguro | 0:faa58403944a | 74 | if((Va<=0)&&(Vb<=0)&&(aVa>=a3Vb)){ //sect 3 |
oguro | 0:faa58403944a | 75 | |
oguro | 0:faa58403944a | 76 | d5=-sq32*sq23*Vb*Vdlink; |
oguro | 0:faa58403944a | 77 | d4=sq32*(-Va+sq3*Vb)*Vdlink; |
oguro | 0:faa58403944a | 78 | d07=(z-(d4+d5))*0.5; |
oguro | 0:faa58403944a | 79 | //d07=0; |
oguro | 0:faa58403944a | 80 | du=d07; |
oguro | 0:faa58403944a | 81 | dv=d4+d07; |
oguro | 0:faa58403944a | 82 | dw=d4+d5+d07; |
oguro | 0:faa58403944a | 83 | } |
oguro | 0:faa58403944a | 84 | |
oguro | 0:faa58403944a | 85 | if((aVa<=-sq3*Vb)){ //sect 4 |
oguro | 0:faa58403944a | 86 | |
oguro | 0:faa58403944a | 87 | d5=sq32*(-Va-sq3*Vb)*Vdlink;; |
oguro | 0:faa58403944a | 88 | d6=sq32*(Va-sq3*Vb)*Vdlink; |
oguro | 0:faa58403944a | 89 | d07=(z-(d5+d6))*0.5; |
oguro | 0:faa58403944a | 90 | //d07=0; |
oguro | 0:faa58403944a | 91 | du=d6+d07; |
oguro | 0:faa58403944a | 92 | dv=d07; |
oguro | 0:faa58403944a | 93 | dw=d5+d6+d07; |
oguro | 0:faa58403944a | 94 | } |
oguro | 0:faa58403944a | 95 | |
oguro | 0:faa58403944a | 96 | if((Va>=0)&&(Vb<=0)&&(aVa>=a3Vb)){ //sect 5 |
oguro | 0:faa58403944a | 97 | |
oguro | 0:faa58403944a | 98 | d1=sq32*(Va+sq3*Vb)*Vdlink;; |
oguro | 0:faa58403944a | 99 | d6=-sq32*sq23*Vb*Vdlink;; |
oguro | 0:faa58403944a | 100 | d07=(z-(d1+d6))*0.5; |
oguro | 0:faa58403944a | 101 | //d07=0; |
oguro | 0:faa58403944a | 102 | du=d1+d6+d07; |
oguro | 0:faa58403944a | 103 | dv=d07; |
oguro | 0:faa58403944a | 104 | dw=d6+d07; |
oguro | 0:faa58403944a | 105 | } |
oguro | 0:faa58403944a | 106 | } |