@OP - why don’t you post your code and “we” will take it from there.
Well, I didn’t want to confuse the OP with 2 lines of discussions on the same issue. Trying to get it to work without Arduino and code seemed to be the right first step. Don’t worry, I’ll keep watching this thread and chip in if I think it would help.
int leftMotor = 9;
int rightMotor = 3;
void setup(){
}
void loop(){
digitalWrite(leftMotor, LOW);
digitalWrite(rightMotor, HIGH);
}
Here’s my code
Left motor and right motor are both connected to the same motor driver, but eventually i will add code for a second motor driver to control the second motor.
I will suggest that since leftMotor and rightMotor are names for I/O pins that their names better reflect that like leftMotorPin and rightMotorPin. Your sketch is simple enough that there’s no confusion but with longer programs with more variables … it helps to keep things simple to remember.
Lastly both of the aforementioned can be constants instead of variables. Afterall the pins you’re using aren’t going to change, they’re going to stay pins 3 and 9. So you can declare them as constants and not use up the SRAM needed to store variables. Again your code is not long enough that this matters but with longer programs using/needing more SRAM … so saving it for when it’s really needed is a good habit.
I can’t tell how you’ve got the Arduino and motor wired into this so I’ll assume the Arduino is still running off the USB 5V and not the 6V battery (though it could be). I will guess you haven’t connected the Arduino ground to the 6V battery - terminal, aka ground for the driver IC. You setup should look something like the below.
(click on to open)
ps - start with getting 1 motor working. Two motors in parallel might overtax the current capability of the driver.
It still doesn’t work though. I have the wiring set up as I had mentioned earlier.
Did you wire it up exactly as Mee_n_mac suggested earlier? As pin 2 and 5 both need to be connected to battery minus. There are 2x GND on this chip, probably one for digital signals, the other as the bottom of the H-bridge. As the (1st) datasheet says nothing about internal connection, better to be safe and connect them anyway like in the second datasheet.
In your picture I can only see pin 5 going to the battery minus rail. (and confirmed by your message in text) And that is even through a resistor (I can’t see which color rings exactly, red red brown gold I guess, so 220 ohm ). Why? There can be running quite a bit of current going through this resistor, and thus cause a voltage difference between battery-minus (0v) and what the chip considers 0v. Maybe less if the motor does not run, but it could offset the inputs and the output enable anyway. Does the wire to pin 2 also go to the battery-minus somewhere outside of the picture?
And how is the GND to the Arduino connected. Is it going to either of these pins, or both?
It worked for a while, then i altered the code to make a loop for it to run forward then back, and it worked for a little while. I then turned it off and when i turned it back on, it no longer worked!!! What happened??? I didn’t burn out my Arduino did i?
Well, I just had another look at the first datasheet and noticed this: “The GNDs of the logic unit and power unit are isolated.” So yes, you definitely need pin 2 and 5 to be connected on your breadboard. And these need to be connected to battery minus and arduino GND, without resistor. If not, it wil not work reliably.
I can’t say if your current problems are caused by it. But your latest code looks not very usefull to begin with. It reverses direction every 5 milisecond. No motor of descent size will stop and reverse that quick due to inertia. It might make it buzz though. But I do not wish to dive into this problem until you confirm the previous things mentioned.
Honestly I think your 5 msec on/off was a bad test, maybe even a fatal one. Try 5 secs (5000 msecs) to “test out” the forward and backward motions. With a 2 sec “off” in between.
Moreover since you now have an idea of how this works (in a small way), what do you think you’ll do with 18V motors ?
I’ll get an identical ic with a higher current load then make it radio operable. I’m not sure how to do that yet, but I’ll figure it out. I might make another topic for that.