Context: I have 4 BO motors that I am trying to power but for the life of me, it is not working. Frequently one or two motors will stop working and sometimes all four will work. It is incredibly unreliable and I have just spend the last 3 days (2.5 hrs per day) trying to get it to work. I am not sure why this happening, but I have four primary questions:
1.) is my wiring an issue?
2.) are the 9v batteries enough?
3.) (this is a variant of question 1) should the GND of my arduino mega be connected to the GND of the two L298Ns
4.) Should I remove the female jumper cable for the power regulator here? (On the L298N).
And yes, I know I'm using three 9V batteries but that is for some reason the only way to supply enough current to get the motors to work (idk why).
I have attached an image of the wiring: (Also all the motors/batteries etc... used in the wiring are the same equipment I am using to build the robot)
FYI: I have only added the power wiring in this image. I do of course know that I have to connect jumper cables between the mega and L298N to program it.
I thought connecting batteries in parallel was a common thing to do, like it introduced in circuits so i figured it would be fine. And for the last part, I'm using the 5v port from the arduino to power the logic circuits of the l298n.
I have unfortunately disassembled the project in frustration but the diagram is accurate to the T. I do have DMM with me. And no code because that would require pinout connections and I am only asking about the wiring. But if it is important, this is the code:
void setup() {
// put your setup code here, to run once:
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(14, OUTPUT);
pinMode(15, OUTPUT);
pinMode(16, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(2, HIGH);
digitalWrite(4, HIGH);
digitalWrite(3, LOW);
digitalWrite(5, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(14, HIGH);
digitalWrite(15, HIGH);
digitalWrite(16, LOW);
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
}
When you feel like rebuilding it, here is some advice.
Leave out those L298. They are a very old design and perform poorly, especially at lower voltages.
The reason the modules have those honking-great heatsinks on them is because they are so inefficient, and a large proportion of the battery power gets wasted as heat. With 9V input and both motors running, the motors may receive as little as 6V, the other 3V being lost, or "dropped" by the L298.
So why are L298 modules like these so commonly sold for Arduino projects? Because there is a never-ending supply of inexperienced beginners to buy them.
If you choose your motor drivers wisely, you should be able to use 4x AA packs instead of 6x.
TB6612FNG driver modules will probably be a good choice, but post the specs of your motors for confirmation. These will drop only a fraction of a volt, so your motors get almost all the power from the batteries and the drivers won't get hot and may not need heatsinks at all, or only small ones.
And these are the motor specs:
Operating Voltage: 3V~6V DC
Gear Ratio 1:48
No-load speed(5V): about 208RPM
Rated Torque: 0.8 Kg.cm @ 5V
Load current: 170 mA (when it is 4.5V)
Size: 70 x 23 x 18 mm
Weight: 28g
Shaft Length: 10 mm
Shaft Type: 6 mm, Double-D
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(2, HIGH);
digitalWrite(4, HIGH);
digitalWrite(3, LOW);
}