
Xuven
USA
Asked
— Edited

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!
The boards are basically all the same just some have LEDs some don't, some have different layouts, some have on board regulators but fundamentally they are all the same, the L298n chip is the same so it will work the same way.
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.
The leds indicating which side is running always seemed to be crossed. So In2 and In3 will light up on reverse . In2 and In4 will light up when going forward so straight across from each. I'm at work now so going off memory . Might have to make a video if I can't figure it out later
A video would help see what's happening.
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.
I just noticed after all of that that In4 and In3 are the other way around to what I thought. It doesn't matter really but it's not quite right. Cyan and Magenta just need swapping over on the port numbers and my description.
Forgive me if this is a bit brief, I'm tired and just come back from a few days away where I had very little sleep so my brain isn't what it usually is.
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;
Forward
Reverse
Left
Right
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.
Hi @Xuven
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!
@Rich Thanks for all the help. I have tested all the jumpers with a toner to test for breaks and shorts. So far everything is good. At this point im going to assume its the H Bridge and replace it.