如何解决使用 arduino 的 TB6612FNG 电池电源问题
我有一个带有 TB6612FNG 和 Atmega328P 的定制板,带有 arduino uno 引导程序。当我对其进行编程时,电机控制器与 PWM 控制配合良好。但是,当我将电源从 USB 电源切换到电池电源时,电机不再工作,它有点抖动并且没有电机运动。但是,如果我将速度更新为 255 或 -255,则可以全速运行。
总而言之,无论 USB 电源或电池电源如何,电机控制器都可以全速运行。但是,如果我将速度降低到 255 或 -255 以外的任何速度,它就不能使用电池电源,而只能使用 USB 电源。当我同时连接电池和 USB 电源时,即使这样它也无法在较低的速度下工作。
电池 (VM) 连接到稳压器 (1117 - 5V - VCC),该稳压器为电路板和电机控制器和直流电源供电 - VM 连接到 TB6612FNG VM 引脚。这是否与电池电源如何为芯片和电机控制器供电,或者哪个先到达 VM 或 VCC 或类似的东西有关?
请找到下面的代码以及定制板的原理图。任何帮助表示赞赏。
#define PWMA 5
#define AIN1 10
#define AIN2 4
#define BIN1 7
#define BIN2 8
#define PWMB 6
#define motor_A 0
#define motor_B 1
#define FORWARD 1
#define REVERSE 0
#define RIGHT 1
#define LEFT 0
void setup()
{
pinMode(PWMA,OUTPUT);
pinMode(AIN1,OUTPUT);
pinMode(AIN2,OUTPUT);
pinMode(PWMB,OUTPUT);
pinMode(BIN1,OUTPUT);
pinMode(BIN2,OUTPUT);
delay(5000);
}
void loop()
{
motor_brake();
delay(1000);
motor_drive(FORWARD,150); // if this replaced with 255,it works on battery also,but at full speed
delay(1000);
motor_brake();
delay(1000);
motor_drive(REVERSE,150); // if this replaced with 255,but at full speed
delay(1000);
motor_brake();
delay(1000);
motor_turn(RIGHT,150,but at full speed
delay(1000);
motor_brake();
delay(1000);
}
void motor_brake()
{
digitalWrite(AIN1,1);
digitalWrite(AIN2,1);
digitalWrite(PWMA,LOW);
digitalWrite(BIN1,1);
digitalWrite(BIN2,1);
digitalWrite(PWMB,LOW);
}
void motor_drive(char direction,unsigned char speed)
{
if (direction == FORWARD)
{
motor_control(motor_A,FORWARD,speed);
motor_control(motor_B,speed);
}
else
{
motor_control(motor_A,REVERSE,speed);
}
}
void motor_turn(char direction,unsigned char speed_A,unsigned char speed_B )
{
if (direction == RIGHT)
{
motor_control(motor_A,speed_A);
motor_control(motor_B,speed_B);
}
else
{
motor_control(motor_A,speed_B);
}
}
void motor_control(char motor,char direction,unsigned char speed)
{
if (motor == motor_A)
{
if (direction == FORWARD)
{
digitalWrite(AIN1,HIGH);
digitalWrite(AIN2,LOW);
}
else
{
digitalWrite(AIN1,LOW);
digitalWrite(AIN2,HIGH);
}
analogWrite(PWMA,speed);
}
else
{
if (direction == FORWARD)
{
digitalWrite(BIN1,LOW);
digitalWrite(BIN2,HIGH);
}
else
{
digitalWrite(BIN1,HIGH);
digitalWrite(BIN2,LOW);
}
analogWrite(PWMB,speed);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。