How to stop being controlled by your DC motor: reverse the roles!

PART 1 — Direction control

Simon BDY
luos
6 min readJan 15, 2018

--

This post is dedicated to anyone who is curious about the basics of DC motors in robotics, and precisely how to control them. You can begin with the previous post dealing with the different kinds of motors used for robotic applications. While some of them are not often used, some others, as the DC brushed motor, are more common.
Be aware that in this post, the word motor will be actually a short for DC brushed motor.

Today, I’m talking to you about the basics of how to control your motor.

One of the main features of these motors is the simplicity of use: if you plug each wire of a battery to the motor’s terminals, it is likely to turn one way. If you switch the wires, it will turn the other way.
(Of course, it’s a little bit more complicated, since the battery must not be too powerful for the motor. If not, the motor may be damaged.)

But this is the problem : it just turns. No speed control. No direction control, unless you manually inverse the wires. At this point your motor is a little bit impertinent. This is painful if you want to build a rover robot for Venus ground (Mars is so 2017)…

Now if we talk about priorities, we would find that direction control comes just before speed control. Why? Basically, because you’d rather have a rover that rolls way too fast with jerky turns, than a rover that moves smoothly in only one direction — and cannot turn. Yes, you get it.

So let’s put aside the speed control for a while, and let’s focus on the direction control.

Direction control

As I said earlier, if you plug the positive wire of your battery on one of the motor’s terminal, and the negative wire on the other motor’s terminal, the motor rotates in one direction. If you switch the wires, it rotates in the other direction. On the next images, U are batteries and M are motors.

U1 and U2 are turned upside down, reversing the polarity. M1 rotates in a direction, M2 in the other.

To make it more automatic, we could design a small circuit with a mechanical switch (S). Switching the switch (yes this is how it works) changes the polarity, hence the direction of rotation:

All these wires…

At this point, this sassy motor is no longer controlling you, but you are still far from having full control on your side.

You are still in manual mode. Your hand along with your fingers must press the toggle switch to invert the direction. And please, don’t build a robotic arm that does it instead of your hand.

To avoid using your hand, I want to introduce you to H-bridges.
H-bridges are simple electronic circuits (they have actually the size of a chip, but can easily be made with discrete components). They allow the voltage to be applied in a direction or in the other, by opening and closing 4 doors.

On the example below, the motor (M4) is situated at the center of the horizontal bar of the H.

Look! Is it a bird? Is it a plane? No, it’s an H!

Only two configurations can make the motor rotate, in one direction or the other:

Configuration 1: S2 and S5 are closed, S3 and S4 are opened
Configuration 2: S2 and S5 are opened, S3 and S4 are closed

There is no current flowing in the grey wires, because their “doors” are closed, i.e. no contact.

Ok now that’s too much schematic pictures. I don’t know about you, but I find this very exhausting, so please take a while and relax.

There. Take a deep breath.

Let’s go back to control.
Any other “doors” configuration would result either in nothing happening, either in a short circuit on the power supply (which is bad), or either in braking the motor.

Note: braking (or short-braking) a motor consists in connecting both its terminals together. It only works when the rotor is moving, resulting in shortly stopping. But you can easily try it at home with a disconnected motor: turn the axis with your hand, then do it again while connecting the terminals together; you’ll feel the rotor is a little bit harder to turn.

Ok, you’re telling me, but what you call “doors” looks quite like push-buttons to me. That means I’ll need my hands again, and two of them this time!

Right, this was only the simple way to explain it. These doors can be replaced by several components, called transistors. The most used is called the bipolar transistor. This three-legged component will take the role of an automated door; it means that connected to a microprocessor which sends commands, each door let automatically a certain amount of current flows through it, or block it. This results in a door, or a no-hands-needed push-button.

NPN transistor (symbol and drawing). C stands for Collector, E for Emitter and B for Base.

This kind of transistor works like a controlled door: the B side is the control side, from where you choose to open or close. If a small “signal” current is flowing through B to E, then the door is opened and let a bigger “power” current to flow from C to E. If no current flows from B to E, then the door is closed and no current is allowed from C and E.

Note: This explanation is for the case of a perfectly saturated transistor. The reality may be a little more complex.
Also, you can find PNP (this was a NPN), which is basically the opposed polarity.

Many electronic control boards (like L298N) carry one or several H-bridge chips in their design. The microprocessor you’re using (for example the one in an Arduino board) is connected to the input pins of the control board. High and low signals from the microprocessor will then command the H-bridge chip to make the motor rotate the way you want.

To summarize:

  • You write a program in a microprocessor (easier with the help of a developing board).
  • The microprocessor sends high or low signals to the H-bridge (again, easier with a controlling board).
  • The H-bridge orient the voltage so that the connected motor can rotate the way you politely asked it.
This picture is incomplete, because only direction signals are shown. We will complete it with speed signals later.

Of course, you will have to program your developing board so that it works properly. Many websites provide great help for dealing with Arduino or Raspberry Pi boards.

Note: H-bridges are used for other functions, like for example DC-to-AC converters. Also, the stepper motors are controlled by H-bridges, but it’s slightly more complicated.

Congratulations. Despite some pictures challenging to watch for too long, you now have half the control of your not-that-eager-now motor. On the next part, we will have a look on the speed control, still on DC brushed motors. One more step towards full control!

Thank you for reading.
— If you liked what you read, please clap the hell out of it and follow us on Medium!

I am an engineer in mechatronics, co-founder of Luos. We are developing new technologies in order to build and produce electronic devices easier and faster.

--

--

Simon BDY
luos
Editor for

Mechatronics, entrepreneurship, do-it-yourself and banana-rockets.