Asked — Edited

Ez-B And Hbridge Are Fighting Me

Hey.

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

Quote:

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.


ARC Pro

Upgrade to ARC Pro

ARC Pro is your passport to a world of endless possibilities in robot programming, waiting for you to explore.

PRO
Synthiam
#1  

Well, clearly it's not connected correctly:)

The PWM will be necessary for the HBridge to move. So it sounds like the PWM is connected to the Trigger ports instead.

Perhaps you can draw a schematic or take a photo so we can help you fix the connections

PRO
Canada
#2  

One thing that might help you is using the Roli example in ARC which has an "init" script to initialize your pwm lines on "connect".

Do note that the physical connections will be different as the Roli example uses D0-D5 for H-bridge control.

#3  

@Technopro @Jeremie

Sometimes even if wired correctly! It will not work!

Since I have three h-bridges wired to one ezb v4!

I had to logically change order of d8 and d9 to d9 and d8.

If you get more movement then also change d10 and d11 to d11 and d10.

Rich Explains' this in his tutorial...

Also is h-bridge showing a light on? Edited yes you said...

J:D

I will power up my PC in few minutes and check my settings!

Jad

PRO
Synthiam
#4  

Keep in mind that if something is wired correctly, it will work - always:)

Logic prevails, if it isn't working... it isn't wired correctly:D

#5  

i have it this way and it works!

l trigger a d3 l trigger b d2

r trigger a d1 r trigger b d0

@dj sures you are correct,

but depending how the motors state was left by pwm's... try it..

j:D

United Kingdom
#6  

@technopro.

This might be an obvious one and forgive me if you have done this already, but have you pressed the little white regulator button (click up for +5v, click down for external power source, 12v ect) on the H-bridge? Another thing I would suggest is to unwire and repconnect the H-bridge to different ports on the EZ-B, D0 to D5 for example, and see if that makes a difference.

User-inserted image

The photo is how I had mine wired. White wires from the left: D0 D1 D2 D3 Red wires from left (speed control): D4 D5 A little playing with the config menu and this worked great for me.

Anyway, just a thought I hope that helps. ;)

Steve.

United Kingdom
#7  

As DJ says, if it's wired correctly it will always work.

I've spent a lot of time with the L298n H-Bridge and (so far) haven't had one which didn't work as desired.

First check your PWM ports are set, by default these are low or off. They must be set before attempting to move the robot otherwise it'll be trying to move with the speed set to nothing. Just adding the control doesn't set the PWM high. Add a couple of lines in the Init script which is run on connection;

PWM(EnA, 100)
PWM(EnB, 100)

Where EnA and EnB would be the port numbers.

Assuming the In1 to In4 are connected correctly to Left Trigger A, Left Trigger B, Right Trigger A and Right Trigger B it should work as desired.

If it doesn't you need to check the connections are correct and check continuity between the EZ-B and the H-Bridge. Broken wires are not a rare thing.

If that still doesn't work correctly the problem would be with the H-Bridge. You can test a H-Bridge using a couple of jumper cables.

Provide the H-Bridge with +5V, Vcc and Ground Put a jumper from the ground to In2 Put a jumper from +5V to In1 Put a jumper from +5V to EnA Motor 1 should spin forwards

Disconnect the jumpers

Put a jumper from the ground to In1 Put a jumper from +5V to In2 Put a jumper from +5V to EnA Motor 1 should spin backwards

Disconnect the jumpers

Put a jumper from the ground to In3 Put a jumper from +5V to In4 Put a jumper from +5V to EnB Motor 1 should spin forwards

Disconnect the jumpers

Put a jumper from the ground to In4 Put a jumper from +5V to In3 Put a jumper from +5V to EnB Motor 1 should spin backwards

If it doesn't, and you are sure your jumper wires and power supply are OK then you must have a faulty H-Bridge.

#8  

I replicated the my wiring order of my dewy robot and it still work. i can truthfully say that the wiring is correct and checked 5 times. I believe the hbridge might be faulty.

Yes the 5v reg is on.

I'll will take pictures as soon as I can.

#9  

I have wired the connections differently twice, once following the tutorial and once on my own.

Here are the pics.

User-inserted image

User-inserted image

United Kingdom
#10  

The L298n H-Bridge is a very robust and solid H-Bridge, they don't go faulty too easily to be honest.

Have you checked the EnA and EnB pins are getting a PWM or +5V? Pop the two jumpers back on to them and try it without speed control first.

I would say from your earlier posts regarding PWM on the Trigger Ports making it work that the H-Bridge isn't at fault but the wiring may be or the configuration since the H-Bridge would not act that way under fault conditions.

Can you try it on another EZ-B? Even a V3 would do.

Connect In1 to D0 Connect In2 to D1 Connect In3 to D2 Connect In4 to D3 Connect EnA to D4 Connect EnB to D5

Set Left Trigger A to D0 Set Left Trigger B to D1 Set Right Trigger A to D2 Set Right Trigger B to D3 Set Left PWM to D4 Set Right PWM to D5

Connect to the EZ-B in ARC 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% Test the H-Bridge with the Movement Panel direction controls (pay attention to the LEDs on the H-Bridge, it could be as simple as faulty motors).

#11  

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
#12  

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)
Sleep(5000)

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

# 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)
Sleep(5000)

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

# 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_Speed++
PWM(D4, $PWM_Speed)
PWM(D5, $PWM_Speed)
Print("Speed: " + $PWM_Speed)
Sleep(50)
EndRepeatWhile

# 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)
Sleep(50)
EndRepeatWhile

# 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")
Halt()

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.

#13  

Are you trying to operate a +5V device with a +3.3V controller board?

#14  

@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
#15  

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.

PRO
Canada
#17  

@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).

#18  

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.

#19  

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.

#20  

@Tech... from your post #19, try reversing the wires on the right motor...

United Kingdom
#21  

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.

#22  

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
#23  

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:)

#25  

PWM causes the setup to fail! Made a video to show it.

PRO
Canada
#26  

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.

#27  

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
#28  

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 -

Quote:

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%

#30  

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.