This is bugging the hell out of me...I have a L298N H bridge setup and for the life of me cant seem to figure out why Megabyte turns to the right . Instead of reversing straight back! Ive tried swapping all the combos for movement in EZ builder. Forward, left and right work. But reverse he seems to pull to one side. Im sure its something obvious,...but im stumped!
Upgrade to ARC Pro
Your robot can be more than a simple automated machine with the power of ARC Pro!
You can swap around the connections in the Movement Panel all you want but if one side is wired backwards it will turn instead of reversing straight back.
Flipped the wires and still nothing baffled. I pinned it out using Richs guide and it worked before o started cleaning up wires
One signal to each of the Ins (In1, In2, In3, In4)?
+5V to the +5V? Or the switch pressed for on board regulation (if your board has that option)?
Voltage for the motors also plus a common ground?
If so it should work provided the Enables are high and the In1 to In4 have the correct High/Low to make the motor move.
Pay careful attention to the labels on the L298N board, there are a number of variations, yours looks different to mine.
Then, provided D16-D19 are on In1-In4 in the same order it should just be a case of setting the H-Bridge control to D16 down to D19 in order. One motor (or both) may run the wrong way due to polarity of the motors, if that's the case swap D16 with D17 in the control and/or D18 with D19.
Provided you have D0 giving EnA and EnB +5V or a PWM the control should at least do something.
If it doesn't work test all wires from EZ-B to H-Bridge for continuity, make sure there isn't a break in one of them.
If it still doesn't work take some jumper wires and carefully connect up from the Vcc (i.e. +5V - I assume this is a V3 you are using, don't do this with a V4) like so;
Vcc to EnA
Vcc to In1
Ground to In2
Does motor 1 spin?
Vcc to EnB
Vcc to In3
Ground to In4
Does motor 2 spin?
That should check if the H-Bridge and motors are working. If nothing happens then there is an issue with the H-Bridge or the motor. If that is the case, eliminate the motor from being the problem and just provide it with a Vcc and Ground to check it spins. If it does then the H-Bridge has an issue. If it doesn't then the motor is toast.
@ Rich this is the board im using. Will it make any difference when trying to trouble shoot? The motors turn and i can see the lights on the bridge come up. But i still cant get it to reverse. If i do get it to reverse it wont move forward. Tried swapping jumpers and there good
If the lights come on that's a good thing, this will tell you if it's set up correctly or what is happening at least.
There should be 2 LEDs per motor. One LED indicates forwards movement, the other indicates backwards movement. The same for the other side.
What do the LEDs show when you try and make it move forwards and reverse? Does each side show an LED lit up? And if doing the other direction do the other two light up instead?
Does it not move at all when you try to reverse?
Have you tried it with the +5v to EnA and +5v to EnB jumpers attached and no PWM for speed control (keeping those jumpers on will make it run at full speed always and removes the requirement for PWM)?
Does it turn OK?
Your H-Bridge doesn't seem to have a switch but looks like it has a regulator. Is the jumper that's on it's own in the middle of the board control the on board regulator? You can use it with or without but if you use it with the regulator you don't need the +5V to the screw terminals. Doing so will provide a back feed to the EZ-B, I don't think it will damage it but it's safer not to connect it.
Here are some images to help show how it should be wired (however I believe it is wired OK)
First remove these jumpers (indicated in red)
This should expose these required pins (indicated in green)
The run the wires from the EZ-B and battery as shown (note ground can come from either the battery or the EZ-B, I prefer to take it from the battery however have done both methods, it makes no difference really)
Where digital ports are specified this means the Signal.
In1 - Orange to D16 Signal
In2 - Yellow to D17 Signal
In3 - Cyan to D18 Signal
In4 - Magenta to D19 Signal
EnA & EnB - Grey to D0 Signal
+5V - Pinkish Red to any digital port Vcc (if required)
Vcc - Red to Battery positive
Gnd - Black to Battery ground (or any digital port ground)
Then connect the motors to the 2 motor outputs. Either way around it doesn't make much difference and can be corrected in the config.
In ARC set up the H-Bridge Control like this;
Or like this with a PWM control
Slide either the PWM to 100% or the speed controls on the H-Bridge with PWM to 100% for both
Move the robot.
If it turns left when set to move forwards your left motor is running backwards, either reverse the polarity on the H-Bridge itself or swap over the ports in the control (depending on which motor is connected to which side will determine which ports to swap)
If it turns right when set to move forwards your right motor is running backwards, reverse the polarity of it on the H-Bridge or swap the ports in the control, same note as before.
If it moves in reverse when set to move forward both motors are running backwards, reverse the polarity or swap over the ports in the config for both pairs (i.e. swap D16 for D17, D17 for D16, D18 for D19 and D19 for D18)
The full list of what to change if it doesn't act correctly is in my tutorial previously linked to. If it is doing something that I didn't list in it then a video will be needed really.
It's wired correctly. For some reason though on some directions the H-Bridge is acting like it isn't getting a signal. You should be getting 2 green lights for each of the movement directions. For two of them you are getting only one green light.
Basically, check those green lights when you run the directions. If one of them never comes on then it's likely a problem with the wire or that connection on the H-Bridge.
Say a 0 is a light off and 1 is a light on, it should follow this pattern;
Or something similar to that. In each case you should have one green light on each side of the H-Bridge light up. If any of the lights never light up then check the wire going to that In connection on the H-Bridge.
If the wires are all OK it could be the H-Bridge which is faulty. I could guide you through testing continuity between the In pins and the chip however check the LEDs and the wires first, by which time I should have had some sleep.
I'm with @Rich I believe one of your input signals isn't reaching the H-bridge from the EZ-B. Replace the jumper wires on D4 and D5 with new ones (I know it's one of them but I don't know exactly which one). The green LEDs should both always be lit up when direction signals are sent to the H-bridge. Thanks for the video it definitely helps in troubleshooting the issue!
@xuven, if you look on the L298n datasheet you can see which pin on the L298n chip (the big thing with lots of pins and a heatsink on it) should go to In1 to In4 (labelled as Input 1 to Input 4). With a multimeter you could check continuity between the In1 pin and Input 1 of the L298n, In2 pin and Input 2 of the L298n, etc. (Inputs on the L298n are pins 5, 7, 10 and 12) just to make sure the H-Bridge isn't faulty.
You could also ground 3 of the 4 In pins and apply a signal set to On to the fourth pin and see if an LED lights up, then move to the next In, ground the others, apply the on signal to the In etc. and test each one at a time (if that makes sense).