Using Two 2.5 Amp L298 Motor Controllers With One Ez-b.


Hi everyone.

I posted a question in regards to reducing the speed of my two 12v motors on the forum last week and I have been pointed in the direction of using motor controllers, and after a response I got from Rich, I found out that it is possible to use two controllers through one EZ-B, so I have ordered two 2.5 amp motor controllers from EZ Robots.

The reason why I need to use two is because the drivetrain for my robot build runs off a 12v battery and has two 12v drive motors that draw about 0.50 amps while running, but can hit about 1.4 amps peak for a split second, so using both channels on the 2.5 amp motor controller with a max peak limit of 3 amps per channel, that takes care of the drive motors.

The drive train also has one 12v steering motor that runs at 0.24 amps with a peak of about 1.3 to 1.4 amps, so apart from needing a third channel I wanted to leave a safety margin, that's why I will require a second motor controller (only using one channel) connected to the EZ-B v4, which I wasn't sure could be done. But as I mentioned above, Rich told me that although it is not done often, it can be done but the second controller would require scripting. So what I would like to ask is...

1.) Has anybody else done this with a similar set up to my example?

2.) Are there any examples of this in action? e.g, controlled via on screen sliders ect.

3.) I'm assuming that I will have to run 2 pairs of power leads from my 12v battery and connect to each L298. Is this correct?

4.) How would to L298's be wired up to a single EZ-B with speed control? I know Rich has a tutorial but I would also like to hear from other members who have done this.

5.) And finally, and this is the main point I am unclear of, one L298 can be controlled through the EZ-B via on screen sliders, smartphone or Wii remote accelerometer movement, voice control ect ect. But I have read that the EZ software will only have these controls for one L298, so how will I be able to control the second L298 for the steering, say for example if I wanted to use it in a "radio controlled" scenario, with both the drive motor control slider and the steering motor slider on one computer/touch screen?

I am waiting for my first batch of EZ goodies to arrive sometime this month, so I am new to all this and only going by what I have read and seen online so far, so any help and/or advice any of you kind people can offer would be gratefully received. There is not that much mentioned about using 2 controllers with one EZ-B on the forum so hopefully any answers or advice given will go towards helping others too. Rich has already offered me help in regards to scripting a second controller which I surly will take him up on, but it this "how will my finished robot physically be controlled Via an iPhone of tablet PC once its scripted" thing I'm scratching my head over.

Thanks everyone.

Steve Winky


I have been thinking about your setup, and I have some ideas, but it will take some experimentation to get everything right.

First, for the drive motors, you could set them up with the H-bridge Movement Panel. Technically, with a little re-design, that is all you would need. It will do differential steering (ie, when you turn, one motor turns faster than the other, or even goes backwards) so you don't need to have a powered steering wheel at all.

However, since your physical build is already started, you may not want to redesign to make the single wheel just a passive caster.

Instead of the H-bridge Movement Panel, you would use a custom Movement Panel and script commands to send signals to the drive wheels H-bridge for forward/back, and PWM speed control, and to the steering motor H-bridge for left/right turning.



Forgive me if I go too fast, just ask if anything doesn't make sense.

To connect them up is pretty much as my tutorial. In1, In2, In3 and In4 need to connect to 1 free Digital Port Signal pin in each case (so 4 pins). If speed control is used then EnA and EnB need to connect to 1 free Digital Port Signal pin each also (you could combine them like I did and have uniform speed over both channels or you could leave the jumpers in place and have them set to full speed).

The second H-Bridge we only need In1 and In2 (and possibly EnA if you want speed control). These connect to free digital port signal pins also.

So to list out the connections (ports can be changed if required, the below are just an example).

H-Bridge 1 (drive Motors)
In1 connects to the Signal pin (white) of Port D8
In2 connects to the Signal pin (white) of Port D9
In3 connects to the Signal pin (white) of Port D10
In4 connects to the Signal pin (white) of Port D11
EnA Connects to the Signal Pin (white) of Port D16
EnB Connects to the Signal Pin (white) of Port D17

H-Bridge 2 (Steering Motors)
In1 connects to the Signal pin (white) of Port D12
In2 connects to the Signal pin (white) of Port D13
EnA connects to the Signal pin (white) of Port D18

Notice I have put the Enable pins on a different "block" of pins, this isn't necessary I just like to do it this way. You could put the enable pins of D12 & D13 for the first H-Bridge then move the second H-Bridge up a bit and put it on D14, D15 & D16 if you wanted. (Hope that didn't come across too confusing, if it did just ignore this paragraph, it's not that important at this stage).

Then this is where the custom Movement Panel comes in to play.

With the custom Movement Panel you script the controls for forwards, reverse, left and right. Then the arrows will perform those tasks.

It will involve having 5 (maybe even 6 with speed control) scripts written based around the L298n truth tables.

First work out what needs to happen for each movement command. I'll do the first so you can attempt the others (I find it's a better way of learning this way)

Both motors need to move forwards, steering motor needs to stop.



Turn Left

Turn right

Once you have all of the movement requirements figured out you need to convert that in to EZ-Scripts which tell the H-Bridge what to do. In my tutorial I posted the "truth tables". These are simple tables which tell you what happens when specific combinations of pins are high and low. (A high is basically the signal pin of the EZ-B going to +5v (or +3.3v in the V4), a low is the signal pin of the EZ-B going to ground).

I'll give you the first script for forwards as an example.

So for forwards,
Steering Motor wants to stop (if moving)
Left Motor (Motor 1) wants to move forwards
Right Motor (Motor 2) wants to move forwards

We look at the truth table


In4 | In3 | In2 | In1 | Function
0 | 0 | 0 | 0 | Stop/Free Wheel
0 | 0 | 0 | 1 | Motor 1 Forward
0 | 0 | 1 | 0 | Motor 1 Reverse
0 | 0 | 1 | 1 | Motor 1 Brake
0 | 1 | 0 | 0 | Motor 2 Forward
1 | 0 | 0 | 0 | Motor 2 Reverse
1 | 1 | 0 | 0 | Motor 2 Brake

On the drive H-Bridge;
We see that we need In1 set to 1 (high) and In2 set to 0 (low) to move Motor 1 forward.
We also see that we need In3 set to 1 (high) and In4 set to 0 (low) to move Motor 2 forward.

On the steering H-Bridge;
We see we need In1 set to 0 (low) and In2 set to 0 (low) to enable "free wheel" or stop.

We do this with the Set() command.

Assuming we have used D8 (In1), D9 (In2), D10 (In3) & D11 (In4) for H-Bridge 1 (drive) and D12 (In1) & D13 (In2) for H-Bridge 2 (steering) the code to achieve the above would be;


# Stop the steering motor
Set(D12, Off) # In1 Low
Set(D13, Off) # In2 Low

# Move the drive motors
Set(D8, On) # In1 High
Set(D9, Off) # In2 Low
Set(D10, On) # In3 High
Set(D11, Off) # In4 Low

That right there is the script required for Forward movement in the custom Movement Panel.

To save this becoming a huge post with too much information causing information overload and a headache I'll leave it here for now. You should be able to follow the same logic above to produce the scripts needed for the other movements. If you think you have the script for another movement sorted post it and I'll give you some feedback on it (the same goes for anyone else, you can all give this a go and test your scripting abilities.


P.S. Alan has a good point. I thought that earlier today too however it depends on your robot. That method is common, it's how most of my robots steer and it works very well on them. I don't know enough about your build to know if that method would work or not, it would certainly be a lot easier.


I realise this is a moot point here, but when my Roli arrives, I am throwing the H bridge in the garbage or I will give it away for whom ever wants it and is willing to pay for shipping... I am sticking with sabertooths, they are so much easier to use...


See I would rather use the L298n H-Bridge personally but then I do know it inside out and could probably build one on a piece of perf board blind folded now Smile

The only real reason I see the Sabertooth being "better" than the L298n is for saving of digital ports on big builds and for larger loads. If the motors are under 2.5a and you have 6 free digital ports (4 if you don't want speed control) then there's no reason to pay a lot more for a device that will do the exact same thing. But that's just 1 man's opinion, everyone will have their preferred methods of doing something, if we were all the same it would be a pretty boring existence right Smile


.... with the soldering iron in your left hand and after downing a few guiness.. LOL... I like the simplicity of the sabertooths as well... Trade off is price, however...


Thanks for the advice there Techguru. I did originally play with the idea of differential steering before I started. I am making a full size K-9 (from Dr Who for those not in the know) but with a few differences, and I know the original prop had exactly that steering set up. But the reasons why I went for front wheel steering was

1.) I don't have a lot of room in my house so I wanted more of a "point & shoot)" set up and not have so much over swing from his head and rear of his body when turning.
2.) The current set up is R/C and I may incorporate that at a later stage so he has about 100 meter driving range if he is ever out and about.

So I don't really want to change the chassis, plus I put a lot of work in to it so it's balanced right, building the steering system, and under chassis lighting I've added but I appreciate where you and Rich are coming from.

I didn't know that the EZ builder had the feature to create your own "custom" control. That really is a neat feature and answers one of my questions, so if I have this right, controlling forward/backwards motion plus adjusting it's speed and steering left/right plus adjusting it's speed, all from one screen ect. So thanks for the info buddy.

Hi Rich. No mate, not to fast at all. I understood it, mostly. Thanks for feeding me the first little bit of script. I do like being spoon fed but I know it is not good for me, so I appreciate you "giving me the fishing rod instead of the fish". Grin I can't wait for my bits to arrive to give this ago but if I do get stuck I will give you a shout for some pointers. I've supplied a photo of how the chassis is set up if anyone's interested and hasn't seen it on the other thread.

Thanks for the offer Richard but I ready have 2 ordered from EZ Robots with free shipping. Someone else maybe interested. Anyone?

User-inserted image


See, up until 2 months ago I hadn't even heard of Sabertooth let alone know what it did. Just shows his much of a novice I am at this micro processor controlled robot malarkey. Tongue

I always played about with R/C and spare electronic bits and peaces, but I really want to learn about it all. The Sabertooth is something I may look at if I do another, bigger robot build (and have more beer tokens saved up). Winky but first things first.



The two L298's have been ordered and should be winging their way to me soon. I'll post an update when they arrive and when I have them installed. Thanks for the advice everyone.

One thing, how do I close the question and say "Congratulations" to a member for answering the question? There wasn't a link in the question update emails I received, and I wanted to close this by thanking Rich.

Steve Winky