微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > stm8-MC KIT库中的主动刹车

stm8-MC KIT库中的主动刹车

时间:11-28 来源:互联网 点击:
刹车时间与刹车PWM可设.

刹车函数如下:

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下桥全开.将电能转为磁能,磁能之间互作用,实现主动刹车.

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top