Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Asked — Edited

Ez-B And Hbridge Are Fighting Me


Following rich's hbridge tutorial, which is the following wiring:


Vcc = Motor Supply Positive
Gnd = Motor Supply Ground (ensure this is common if using more than one supply)
+5V = Not Connected

In1 = Digital Port Signal (i.e. D8)
In2 = Digital Port Signal (i.e. D9)
In3 = Digital Port Signal (i.e. D10)
In4 = Digital Port Signal (i.e. D11)
EnA = Digital Port Signal (i.e. D12)*
EnB = Digital Port Signal (i.e. D13)*

I wired up my ez-b(V4) and now have triple checked my wiring so I do in fact have this exact wiring. Proof that my ARC control is correct:
User-inserted image

Now, when I press any button on my control, the hbridge does nothing. No lights(except the one indicating 5V), no motor movement, no nothing. When I mess up the control ports, I can get something to move.

With the current wiring, D10 when PWM'd will move the left track forward.
D11 PWM'd causes the left track to go backwards.
No other ports cause an action.

Any help is appreciated.


Upgrade to ARC Pro

Experience the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

But what I don't get is the motors move with a different configuration.
I'll do more testing when I'm home.
United Kingdom
If you set it up as my last post (D0 to D5) run the following script to test each connection.


# L298n H-Bridge Test Script
# Author: Rich Pyke
# Version: 1.3
# Last Updated: 2014-09-01

# Set Enable pins high
Set(D4, On)
Set(D5, On)

# Move Channel 1 Direction 1 for 5 seconds
Print("Channel 1 Forwards")
Set(D0, On)
Set(D1, Off)

# Move Channel 1 Direction 2 for 5 seconds
Print("Channel 1 Reverse")
Set(D0, Off)
Set(D1, On)

# Stop Channel 1
Print("Channel 1 Stopped")
Set(D0, Off)
Set(D1, Off)

# Move Channel 2 Direction 1 for 5 seconds
Print("Channel 2 Forwards")
Set(D2, On)
Set(D3, Off)

# Move Channel 2 Direction 2 for 5 seconds
Print("Channel 2 Reverse")
Set(D2, Off)
Set(D3, On)

# Stop Channel 2
Print("Channel 2 Stopped")
Set(D2, Off)
Set(D3, Off)

# PWM Ramping Test
# Kill both Enables
Set(D4, Off)
Set(D5, Off)

# Set H-Bridge Channels 1 and 2 for Direction 1
Set(D0, On)
Set(D1, Off)
Set(D2, On)
Set(D3, Off)

# Begin slow ramp up of PWM from 0 to 100
Print("Ramp Up Test")
$PWM_Speed = 0
RepeatWhile($PWM_Speed < 100)
PWM(D4, $PWM_Speed)
PWM(D5, $PWM_Speed)
Print("Speed: " + $PWM_Speed)

# Begin slow ramp down of PWM from 100 to 0
Print("Ramp Down Test")
RepeatWhile($PWM_Speed > 0)
$PWM_Speed = $PWM_Speed - 1
PWM(D4, $PWM_Speed)
PWM(D5, $PWM_Speed)
Print("Speed: " + $PWM_Speed)

# Reset all pins low
Set(D0, Off)
Set(D1, Off)
Set(D2, Off)
Set(D3, Off)
Set(D4, Off)
Set(D5, Off)

Print("Test Complete")

I can't remember if I ever tested or used the above but it's commented and if there are any errors with it you should be able to find out where and how to fix them.
Are you trying to operate a +5V device with a +3.3V controller board?
@Purple... H-bridges work perfectly with the ezb3 and ezb4... In fact Roli rolls off (pun intended) the assembly line with an H-bridge as a motor controller...
United Kingdom
He has the on board regulator providing the +5v required by the L298n based H-Bridge. This method works perfectly fine. The L298n will see the 3v3 from the signal pins as a high and operates correctly with the EZ-B V4.
@technopro do keep in mind that the polarity in which you have the motors hooked up does matter as well, if things seem to be backward on one motor try swapping the motor wires around (change polarity on that motor).
Well! Testing my hbridge without pwm using the hbridge (non pwn) control(going forward), my left motor went forward and my right motor went backward.

Left- both went forward

right- both went backward

reverse-left backward, right forward

So something pwm wise is weird.
To make the motors move properly, I used the following setup.

User-inserted image

Wiring didn't change from photos, other than the jumpers are on the hbridge and pwm wires disconnected.
@Tech... from your post #19, try reversing the wires on the right motor...
United Kingdom
Read my tutorial on the L298n, it explains what to do if forward/reverse turn left/right and left/right move forward/reverse.

To make it simple, reverse the polarity of one of the motors (whichever one you said moves in reverse when you hit forward) or swap over the Trigger A and Trigger B of that side in the control.

It has nothing at all to do with PWM.
Maybe you missed my last post. I can make it work by switching the trigger ports as mentioned in my last post, but I'm not using pwm. Once I charge my battery, I'll try to get pwm working.
United Kingdom
The "right" way to do it would be to connect the motor that spins the wrong way around the correct way, i.e. reverse the polarity of it. However, either way will work and there is no difference really (unless you're like me and need everything to be 100% exactly correct, call it an OCD/perfectionist trait).

As for the speed control/PWM, now you have the actual control sorted out the speed control should be a piece of cake. 2 ports, 2 PWMs, you can't go far wrong:)
PWM causes the setup to fail! Made a video to show it.

Hi @TechnoPro,

I noticed that you didn't test with the PWM sliders actually ON. By default the PWM sliders are at 0% PWM (OFF) so this won't allow your motors to move. Try bringing them both up over 30% and try again.

You could also try using the H-Bridge Movement Panel with PWM to have everything in one place. It makes things a little cleaner. Just make sure that if you don't use an "init" script, like in the Roli example, that you move the sliders a bit before use to initialize the PWM lines.
Worked! In the pwm 4wire hbridge control, the pwm sliders have to be moved around before it will actually work.

Thanks for the help guys!
United Kingdom
You must be setting something up incorrectly, if PWM didn't work on the EnA and EnB then neither would the +5V work. Also, with PWM at 100% it should be full on and practically the same as with the jumpers attached.

Double check continuity of the jumper wires connected to the EnA and EnB pins.
Double check they are attached to EnA and EnB not +5
Double check you have set a PWM (start at 100% and work down)

Failing that;
Try out the H-Bridge test script I posted the other day and see if that does anything.

Edit: I guess you edited the post once you found the issue however see post #11 -


Set the PWM on D4 and D5 using the sliders on the Movement Panel, you will need to move both of them even if they show being set to 100%
I have had bad l298n I bought in sets of 5 on ebay. One channel would not reverse. I swapped to another hour bridge all identical and worked fine. So sometimes you can get a dud.