剎車時間與剎車PWM可設(shè).
本文引用地址:http://butianyuan.cn/article/201611/322714.htm剎車函數(shù)如下:
void BrakeMotor( void )
{
u16 brake_pwm_cnt;
brake_pwm_cnt = (u16)(((u32)hArrPwmVal * BRAKE_DUTY) / 100);
ToCMPxH( TIM1->CCR1H, brake_pwm_cnt );
ToCMPxL( TIM1->CCR1L, brake_pwm_cnt );
ToCMPxH( TIM1->CCR2H, brake_pwm_cnt );
ToCMPxL( TIM1->CCR2L, brake_pwm_cnt );
ToCMPxH( TIM1->CCR3H, brake_pwm_cnt );
ToCMPxL( TIM1->CCR3L, brake_pwm_cnt );
//Disable update interrupt
TIM1->IER &= (u8)(~BIT0);
TIM1->CCMR1 = CCMR_PWM;
TIM1->CCMR2 = CCMR_LOWSIDE;
TIM1->CCMR3 = CCMR_LOWSIDE;
TIM1->CCER1 = (A_ON|B_COMP);
TIM1->CCER2 = C_COMP;
TIM1->EGR |= BIT5;
#ifdef LS_GPIO_CONTROL
LS_GPIO_BRAKE();
#endif
}
比較簡單就是A上橋PWM,BC下橋全開.將電能轉(zhuǎn)為磁能,磁能之間互作用,實現(xiàn)主動剎車.
評論