Hi,
I am attempting to use two TB6612FNG motor drives to drive four 12V DC motors.
For some reason, the following code runs motor1 and motor4, which are connected to different motor drivers. Any suggestions on how to get it to run all four motors would be appreciated.
Serial.print("Motors Start");
forward(motor1, motor2, motorSpeed);
forward(motor3, motor4, motorSpeed);
delay(2000);
Serial.print(" -> Motors Stop");
brake(motor1, motor2);
brake(motor3, motor4);
delay(2000);
Post all the code.
Poat a schematic or wiring diagram.
JCA34F
April 3, 2024, 3:28am
3
@JCA34F , @groundFungus thank you for the responses.
Electrical Schematic:
Note: Using an Arduino Giga, not a Mega
Full Code:
/**************************Header Files***************************/
#include <Arduino.h>
#include <SparkFun_TB6612.h>
/*****************************Pin Definitions***************************/
// Motors
#define motorSpeed 100
#define motorOn false
// Right Motor Pins
#define AIN1_L 28
#define BIN1_L 24
#define AIN2_L 30
#define BIN2_L 22
#define PWMA_L 12
#define PWMB_L 13
#define STBY_L 26
// Left Motor Pins
#define AIN1_R 38
#define BIN1_R 34
#define AIN2_R 40
#define BIN2_R 32
#define PWMA_R 10
#define PWMB_R 11
#define STBY_R 36
/*****************************Global Variables***************************/
// Motors
const int offsetA_R = 1;
const int offsetB_R = 1;
const int offsetA_L = 1;
const int offsetB_L = -1;
Motor motor1 = Motor(AIN1_R, AIN2_R, PWMA_R, offsetA_R, STBY_R);
Motor motor2 = Motor(BIN1_R, BIN2_R, PWMB_R, offsetB_R, STBY_R);
Motor motor3 = Motor(AIN1_L, AIN2_L, PWMA_L, offsetA_L, STBY_L);
Motor motor4 = Motor(BIN1_L, BIN2_L, PWMB_L, offsetB_L, STBY_L);
uint32_t motorTimer = millis();
/******************************Setup*******************************/
void setup() {
// Initialize serial and wait for port to open
Serial.begin(115200);
delay(1500);
}
/****************************Main Loop*****************************/
void loop() {
Serial.print("Motors Start");
forward(motor1, motor2, motorSpeed);
forward(motor3, motor4, motorSpeed);
delay(2000);
Serial.print(" -> Motors Stop");
brake(motor1, motor2);
brake(motor3, motor4);
delay(2000);
}
SparkFun TB6612FNG Arduino Library
JCA34F
April 3, 2024, 3:46am
5
Sorry, your drawing is too low resolution for my old eyes, if I blow it up 400% it blurs out.
JCA34F
April 3, 2024, 3:51am
6
What is the current draw of your motor(s), what is the current rating of your 12V power supply?
I believe the motors are rated to 1A. We are using two 12V 8Ah LiFEPO4 batteries in series and then stepping them down to 12V.
JCA34F
April 3, 2024, 4:00am
8
Keep in mind, the starting current of the motor(s) may be 5 to 10 times the full load current. I forget what the TB6612's current rating is. What are the motors driving?
JCA34F
April 3, 2024, 4:02am
9
What is the current rating of the buck converter?
JCA34F
April 3, 2024, 4:06am
11
Should be OK power wise. need to see your complete code.
EDIT: I see it!
Any ideas on why this may not be working?
I can call forward(motor1, motor2, motorSpeed);
motors 1and 2 will run.
I can call forward(motor3, motor4, motorSpeed);
motors 3 and 4 will run.
Yet when I call both:
forward(motor1, motor2, motorSpeed); forward(motor3, motor4, motorSpeed);
Only motor1 and motor4 run.
xfpd
April 13, 2024, 10:54pm
13
My guess is the TB6612FNG have a priority channel.
Comment-out 1 and 4 to see if 2 and 3 run.
Comment out 1 and 2 to see if 3 and 4 run.
Comment out 3 and 4 to see if 1 and 2 run.
system
Closed
October 10, 2024, 10:54pm
14
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.