CCW CW Control BLDC

Dependencies:   mbed mbed-rtos

sin.h

Committer:
oguro
Date:
2020-11-14
Revision:
1:333d2cdd26d0
Parent:
0:faa58403944a

File content as of revision 1:333d2cdd26d0:


/********* sin Drive *******************/
void PWM_sinU(){
     ut1=uT.read_us();   
     f1=(sin(2*3.14159*(1/(usi*1E-6))*zint)*16384); 
     a1=(2*cos(2*3.14159*(1/(usi*1E-6))*zint)*16384);        
     uz[0]=a1;uz[1]=0xC000;uz[2]=0; uz[3]=f1; uz[4]=0;
}
void EN_sinU(){
         ut2=uT.read_us();
         uT.reset();
}

void PWM_sinV(){   
     vt1=vT.read_us();
     f1=(sin(2*3.14159*(1/(vsi*1E-6))*zint)*16384);
     a1=(2*cos(2*3.14159*(1/(vsi*1E-6))*zint)*16384);     
     vz[0]=a1;vz[1]=0xC000;vz[2]=0; vz[3]=f1; vz[4]=0;
   
}
void EN_sinV(){
           vt2=vT.read_us();
           vT.reset();
}

void PWM_sinW(){  
    wt1=wT.read_us();
    f1=(sin(2*3.14159*(1/(wsi*1E-6))*zint)*16384);
    a1=(2*cos(2*3.14159*(1/(wsi*1E-6))*zint)*16384);    
    wz[0]=a1;wz[1]=0xC000;wz[2]=0; wz[3]=f1; wz[4]=0;
   
}
void EN_sinW(){
            wt2=wT.read_us();
            wT.reset();
}

/******************z transfer******************************/
void ztr(){
    
            uz[2] = ((uz[1]*uz[4])>>14) + ((uz[0]*uz[3])>>14);
            uz[4] = uz[3]; 
            uz[3] = uz[2];          
    
            vz[2] = ((vz[1]*vz[4])>>14) + ((vz[0]*vz[3])>>14);
            vz[4] = vz[3]; 
            vz[3] = vz[2];
            
            wz[2] = ((wz[1]*wz[4])>>14) + ((wz[0]*wz[3])>>14);
            wz[4] = wz[3]; 
            wz[3] = wz[2];
    }
/*********************************************************/
void time_UP(){
    ut1=uT.read_us(); 
    }
void time_UN(){
     ut2=uT.read_us();
     uT.reset();
    }
void time_VP(){
    vt1=vT.read_us();
    }
void time_VN(){
    vt2=vT.read_us();
    vT.reset();
    }
void time_WP(){
    wt1=wT.read_us();
    }
void time_WN(){
    wt2=wT.read_us();
    wT.reset();
    }