各位大佬,有没有遇过L298N用pwm调速,结果两边输出电压不一样?
时间:10-02
整理:3721RD
点击:
void right_moto_speed()
{
if(pwmval_right <= pwmval_right_init)
{
EN1 = 1;
}
else if(pwmval_right > pwmval_right_init)
{
EN1 = 0;
}
if(pwmval_right > 20)
{
pwmval_right = 0;
}
}
void left_moto_speed()
{
if(pwmval_left <= pwmval_left_init)
{
EN2 = 1;
}
else if(pwmval_left > pwmval_left_init)
{
EN2 = 0;
}
if(pwmval_left > 20)
{
pwmval_left = 0;
}
}
void Interrupt_Timer0_1ms() interrupt 5
{
TF2 = 0;
pwmval_right++;
pwmval_left++;
right_moto_speed();
left_moto_speed();
}
{
if(pwmval_right <= pwmval_right_init)
{
EN1 = 1;
}
else if(pwmval_right > pwmval_right_init)
{
EN1 = 0;
}
if(pwmval_right > 20)
{
pwmval_right = 0;
}
}
void left_moto_speed()
{
if(pwmval_left <= pwmval_left_init)
{
EN2 = 1;
}
else if(pwmval_left > pwmval_left_init)
{
EN2 = 0;
}
if(pwmval_left > 20)
{
pwmval_left = 0;
}
}
void Interrupt_Timer0_1ms() interrupt 5
{
TF2 = 0;
pwmval_right++;
pwmval_left++;
right_moto_speed();
left_moto_speed();
}
自顶