很早之前就想做一款无刷电机控制器,忙于工作一直没有弄。最近有点时间画板,打样,焊接,调试,总算顺利的转起来。期间也遇到很多问题,上网查资料,自己量波形前前后后搞了差不多近一个月,(中间又出差一周)总算搞的差不多了,特意写个总结。
speed_duty=30; //30% startBLDC_PHASE_CHANGE(Step[Phase]); //固定一相Delay_MS(200);speed_duty=pwm;timer = 300;while(1){for(i=0;i<timer; i++){Delay_US(120); //等待}timer-= timer/25+1;if(timer < 25){if(TEST_MANUELL){timer = 25; //开环强制换向}else{bldc_dev.motor_state=RUN;break;}}Phase++;Phase %= 6;BLDC_PHASE_CHANGE(Step[Phase]); //}
如下图,这个已经是比较好的了,还是有很多毛刺。这个给单片机中断,肯定一大堆问题,严重的换错相烧MOS管。
const unsigned int FilterNums = 0xff;static unsigned int nums =0;static unsigned int Queue_UStatus =0;static unsigned int Queue_VStatus =0;static unsigned int Queue_WStatus =0;static unsigned char EMF_SVal =0;unsigned char Filter_U_Status=0;unsigned char Filter_V_Status=0;unsigned char Filter_W_Status=0;unsigned char EMF_Val=0;unsigned int status_h;unsigned int status_l;unsigned int Delay30deg =0;/* 清除中断标志位 */if ( TIM_GetITStatus(TIM3 , TIM_IT_Update) != RESET ){TIM_ClearITPendingBit(TIM3 , TIM_FLAG_Update);}