中级会员
 
- 积分
- 411
- 金钱
- 411
- 注册时间
- 2014-4-18
- 在线时间
- 94 小时
|
发表于 2017-10-14 19:53:50
|
显示全部楼层
常用多旋翼PWM电调频率最大频率都是400hz左右 高电平时间1-2ms左右驱动即可,
如果要标定电调行程,必须在上电时候立即将高电平时间拉到最高
[mw_shl_code=c,true]//用来标定电调行程
void CAL_MOT(void)
{
motor_output(1000,1000,1000,1000);
DelayMs(20000);
motor_output(0,0,0,0);
DelayMs(20000);
motor_output(1000,1000,1000,1000);
DelayMs(20000);
motor_output(0,0,0,0);
DelayMs(20000);
}
//电机输出 1ms-2ms=1000-2000
void motor_output(int16_t M1,int16_t M2,int16_t M3,int16_t M4)
{
M1 = math_limit(M1+MOTOT_DIE,1000,0);
M2 = math_limit(M2+MOTOT_DIE,1000,0);
M3 = math_limit(M3+MOTOT_DIE,1000,0);
M4 = math_limit(M4+MOTOT_DIE,1000,0);
TIM2->CCR3 = M1 + 1000;
TIM2->CCR4 = M2 + 1000;
TIM2->CCR2 = M3 + 1000;
TIM2->CCR1 = M4 + 1000;
}[/mw_shl_code] |
|