![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
CCW CW Control BLDC
sin.h@2:f23351f7af0b, 2020-11-17 (annotated)
- Committer:
- oguro
- Date:
- Tue Nov 17 01:31:35 2020 +0000
- Revision:
- 2:f23351f7af0b
- Parent:
- 1:333d2cdd26d0
New forward Revers sine Wave 2020 11 17
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
oguro | 1:333d2cdd26d0 | 1 | |
oguro | 0:faa58403944a | 2 | /********* sin Drive *******************/ |
oguro | 0:faa58403944a | 3 | void PWM_sinU(){ |
oguro | 0:faa58403944a | 4 | ut1=uT.read_us(); |
oguro | 0:faa58403944a | 5 | f1=(sin(2*3.14159*(1/(usi*1E-6))*zint)*16384); |
oguro | 0:faa58403944a | 6 | a1=(2*cos(2*3.14159*(1/(usi*1E-6))*zint)*16384); |
oguro | 0:faa58403944a | 7 | uz[0]=a1;uz[1]=0xC000;uz[2]=0; uz[3]=f1; uz[4]=0; |
oguro | 0:faa58403944a | 8 | } |
oguro | 0:faa58403944a | 9 | void EN_sinU(){ |
oguro | 0:faa58403944a | 10 | ut2=uT.read_us(); |
oguro | 0:faa58403944a | 11 | uT.reset(); |
oguro | 0:faa58403944a | 12 | } |
oguro | 0:faa58403944a | 13 | |
oguro | 0:faa58403944a | 14 | void PWM_sinV(){ |
oguro | 0:faa58403944a | 15 | vt1=vT.read_us(); |
oguro | 0:faa58403944a | 16 | f1=(sin(2*3.14159*(1/(vsi*1E-6))*zint)*16384); |
oguro | 0:faa58403944a | 17 | a1=(2*cos(2*3.14159*(1/(vsi*1E-6))*zint)*16384); |
oguro | 0:faa58403944a | 18 | vz[0]=a1;vz[1]=0xC000;vz[2]=0; vz[3]=f1; vz[4]=0; |
oguro | 0:faa58403944a | 19 | |
oguro | 0:faa58403944a | 20 | } |
oguro | 0:faa58403944a | 21 | void EN_sinV(){ |
oguro | 0:faa58403944a | 22 | vt2=vT.read_us(); |
oguro | 0:faa58403944a | 23 | vT.reset(); |
oguro | 0:faa58403944a | 24 | } |
oguro | 0:faa58403944a | 25 | |
oguro | 0:faa58403944a | 26 | void PWM_sinW(){ |
oguro | 0:faa58403944a | 27 | wt1=wT.read_us(); |
oguro | 0:faa58403944a | 28 | f1=(sin(2*3.14159*(1/(wsi*1E-6))*zint)*16384); |
oguro | 0:faa58403944a | 29 | a1=(2*cos(2*3.14159*(1/(wsi*1E-6))*zint)*16384); |
oguro | 0:faa58403944a | 30 | wz[0]=a1;wz[1]=0xC000;wz[2]=0; wz[3]=f1; wz[4]=0; |
oguro | 0:faa58403944a | 31 | |
oguro | 0:faa58403944a | 32 | } |
oguro | 0:faa58403944a | 33 | void EN_sinW(){ |
oguro | 0:faa58403944a | 34 | wt2=wT.read_us(); |
oguro | 0:faa58403944a | 35 | wT.reset(); |
oguro | 0:faa58403944a | 36 | } |
oguro | 0:faa58403944a | 37 | |
oguro | 0:faa58403944a | 38 | /******************z transfer******************************/ |
oguro | 0:faa58403944a | 39 | void ztr(){ |
oguro | 0:faa58403944a | 40 | |
oguro | 0:faa58403944a | 41 | uz[2] = ((uz[1]*uz[4])>>14) + ((uz[0]*uz[3])>>14); |
oguro | 0:faa58403944a | 42 | uz[4] = uz[3]; |
oguro | 0:faa58403944a | 43 | uz[3] = uz[2]; |
oguro | 0:faa58403944a | 44 | |
oguro | 0:faa58403944a | 45 | vz[2] = ((vz[1]*vz[4])>>14) + ((vz[0]*vz[3])>>14); |
oguro | 0:faa58403944a | 46 | vz[4] = vz[3]; |
oguro | 0:faa58403944a | 47 | vz[3] = vz[2]; |
oguro | 0:faa58403944a | 48 | |
oguro | 0:faa58403944a | 49 | wz[2] = ((wz[1]*wz[4])>>14) + ((wz[0]*wz[3])>>14); |
oguro | 0:faa58403944a | 50 | wz[4] = wz[3]; |
oguro | 0:faa58403944a | 51 | wz[3] = wz[2]; |
oguro | 0:faa58403944a | 52 | } |
oguro | 0:faa58403944a | 53 | /*********************************************************/ |
oguro | 0:faa58403944a | 54 | void time_UP(){ |
oguro | 0:faa58403944a | 55 | ut1=uT.read_us(); |
oguro | 0:faa58403944a | 56 | } |
oguro | 0:faa58403944a | 57 | void time_UN(){ |
oguro | 0:faa58403944a | 58 | ut2=uT.read_us(); |
oguro | 0:faa58403944a | 59 | uT.reset(); |
oguro | 0:faa58403944a | 60 | } |
oguro | 0:faa58403944a | 61 | void time_VP(){ |
oguro | 0:faa58403944a | 62 | vt1=vT.read_us(); |
oguro | 0:faa58403944a | 63 | } |
oguro | 0:faa58403944a | 64 | void time_VN(){ |
oguro | 0:faa58403944a | 65 | vt2=vT.read_us(); |
oguro | 0:faa58403944a | 66 | vT.reset(); |
oguro | 0:faa58403944a | 67 | } |
oguro | 0:faa58403944a | 68 | void time_WP(){ |
oguro | 0:faa58403944a | 69 | wt1=wT.read_us(); |
oguro | 0:faa58403944a | 70 | } |
oguro | 0:faa58403944a | 71 | void time_WN(){ |
oguro | 0:faa58403944a | 72 | wt2=wT.read_us(); |
oguro | 0:faa58403944a | 73 | wT.reset(); |
oguro | 0:faa58403944a | 74 | } |