Introduction

When interfacing a microcontroller or computer with high-power devices (such as motors, lamps, solenoids, linear actuators, pumps) we need to provide more current and/or voltage than the microcontroller can directly provide. Generally, a microcontroller (such as an arduino) can sink less than 100mA per pin. If that pin is driving 5V, then we see that it can provide (at maximum) only 0.05W of power. In order to provide more power, we need some additional circuitry. Think of it like a light switch - the power required to press the switch is minimal, but the power output is much larger.

Transistors

A transistor (conceptually) is a switch. When you apply a certain voltage at the base, it allows current to flow from the collector to the emitter.

“A transistor is a semiconductor device used to amplify or switch electronic signals. A voltage or current applied to one pair of the transistor's terminals changes the current flowing through another pair of terminals. Because the controlled (output) power can be much more than the controlling (input) power, the transistor provides amplification of a signal. ”

Quoeth Wikipedia's page on Transistors

The Art of Electronics Second Edition, Page 64.

In this diagram, we see Transistor Man. His job is to look at the current flowing from B to E (Ib), and use that to set the current flowing from C to E (Ic), with the factor of Hfe.

There are many different types of transistors which are suited to different kinds of applications. The most common amongst hobbist electronics is the BJT, or bipolar junction transistor.

These devices are generally not designed to drive a high load, but can be used to do so but with reduced efficiency. Impedence of the BJT is low - current will flow from the base to the emitter.

FETs or Field Effect Transistor are more suited to driving a large load, as it can efficiently sink a large amount of current. The gate (or base) has a high impedance, which means little current will flow from base to emitter when voltage is applied to it. Specifically MOSFETs are well suited to this task.

What we are looking for is a device which we can switch on and off with as little power as possible, and can sink as much current efficiently as possible. And thus we come to the conclusion that MOSFETs are the best choice for most applications.

Types of Motor

There are lots of different kinds of motor, but we will look at the most common ones here. More specialised motors, such as DC Brushless motors and linear motors will not be discussed, as they would need an entire reference article dedicated to them alone.

DC Motor

This is the most common sort of motor you are likely to come across. They're cheap, simple to understand and can provide a good amount of torque.

A DC motor generally has stationary permanent magnets (called the stator) which create a magnetic field around a coil. When current is applied to the coil, it forms its own magnetic field, which is in the opposite direction to the field created by the permenant magnets. This causes a force to by exerted on both the magnet and the coil, causing the coil to rotate to align itself with the magnetic field. However, at the point where it is full aligned, a brush connects to a different contact reversing the magnetic field, causing the coil to continue rotating.

Other variations of this include motors with permanent magnets in the core and a coil(s) around the outside, for example a DC brushless motor.

The upshot of all this is, if you put +12V on one terminal and Ground on the other, the shaft spins in one direction. If you swap the wires around, it spins in the other direction.

Here's a useful link that demonstrates this: DC Motor Tutorial

We can control the speed by varying the voltage which is applied to the coil. The higher the voltage, the more force is produced when it rotates (or torque).

We can imagine that this motor is an inductive load (since it is in fact a coil), however once the shaft starts to spin the load becomes less, due to the inertia which is built up. Less extra force is required to make the coil align with the magnetic fields, and so less current is drawn. This means that the point at which the motor starts spinning is the point at which the most current is drawn, and the size and duration of the spike is dependant on the load which the motor is driving.

Stepper Motors

A stepper motor rotates a shaft in steps. The steps can be anything from 90 degrees to 0.01 degrees around the full revolution.

The motor is made up of a cog shaped magnetised core surrounded by several smaller electromagnetised teeth. By energising the different sections of teeth in a given sequence, the cog can be slowly shuffled around to make a full “step”. Microstepping is also possible, where only a part of the sequence is performed to get a higher resolution.

Servo Motors

A servo motor is a geared motor which, rather than rotating continuously, can be set at a given angle around the shaft. They are frequently used in Hobby RC projects to provide control on vehicles, such as rotating the steering column on a car or pulling the flaps up and down on a model aircraft. They are also used in cars to control accelerator cables.

Servos are frequently used in conjunction with cable or rod linkages to translate their circular motion into linear motion.

They are usually controlled using PWM signals, and have their own control circuitry. Servos can be modified to rotate continuously rather than going to a set position. In this mode they are essentially a geared motor with a built in speed controller - which is very handy.

Very cheap servos can be had from DealExtreme: DealExtreme Search Servo

DC Motor Driver circuits

Full H-bridge Drivers

A full H-bridge driver circuit has the following inputs:

  • Direction - 1 for forward 0 for backwards (or opposite)
  • Brake - 1 for braking 0 for coasting (or opposite)
  • Control - PWM signal to control speed.
  • Logic Vcc/Gnd - the logic levels of the input signals (typically 1.7-5.5V)
  • Output Vcc/Gnd - the “power” outputs (anything from up to 60V)

And the following outputs

  • Motor coil A
  • Motor coil B
  • Current sensing

It is classified as a “full” H-bridge since the inputs will control the entire bridge.

Half H-bridge Drivers

A half H-bridge will have the following inputs:

  • A
  • B
  • AB/Enable - enables or disables the transistors

It will have the following outputs:

  • Motor coil A
  • Motor coil B
  • Current sensing

It is a “half” H-bridge as the inputs control half of the bridge (i.e. one side of the bridge). In order to achieve bidirectional motor control, two channels must be used (to make a full bridge). The enable pins can be used to make the motor coast, whilst setting both A and B to 0 will cause the motor to brake. Diodes are used so that if both A and B are set to 1 (i.e. conducting) then this will not short the power supply (although we still do not want to do this intentionally).

From SN754410 QUADRUPLE HALF-H DRIVER Datasheet

A quadruple half bridge is the same as two full bridges, and is often cheaper as there is less supporting circuitry.

H-bridge

If we wanted to drive a motor with the minimum amount of components possible, this circuit would be the heart of the controller:

The N channel MOSFET (Q1) conducts when we apply a voltage to the gate. This causes current to flow from Vcc to Ground, making the DC motor turn. However, this isn't ideal because it will only turn in one direction. One terminal of the motor will always be connected to Ground, we cannot change the voltage of both the terminals.

And thus we need to use a H-bridge circuit.

Please note that this is (intentionally) incomplete, for clarity. There are 4 inputs, and we can create a “truth table” that describes what happens when we put different things on these inputs. If we say that putting 5V onto the gate is '1', and 0V is '0', then the truth table looks something like this:

A B C D Effect
0 1 1 0 Go CW
1 0 0 1 Go CCW
1 0 1 0 Brake
0 1 0 1 Brake
1 1 0 0 Explode
0 0 1 1 Explode

It is vitally important that there is never the possibility for A and B, or C and D, to be conducting, as this will cause the power supply to be shorted, (called “fly-through”, see dead-time). Of course, you could use this to test your fuses! ;)

All zeros will let the motor “coast”.

Since the motor acts as a generator (i.e. when you turn it, it creates a voltage between it's terminals), if you short the terminals it will try to force voltage back the other way through the motor, causing it to try to spin in the opposite direction, or, in other words, brake. We can achieve the same effect as shorting the terminals by making either A and C or B and D conduct.

Protection Diodes

When the motor is turned off, the magnetic field around the coil will rapidly collapse (as in an inductor) and cause a brief spike of high voltage over the motor terminals. This high voltage is very likely to damage the components attached to it.

The diodes pictured above will allow that high voltage to safely be conducted away to the power rails without affecting the other components. They are reverse biased, so that under normal conditions they will not conduct (by creating a depletion region), and as such will not interfere with the operation of the device. However, above the breakdown voltage (i.e. dangerously high) they will conduct.

Dead Time

When the motor driver is driving a load, current is flowing through two of the transistors to provide a voltage over the motor

A and D are conducting, B and C are not. This means that the voltage is applied over the motor and the load is driven.

However, when turning on B and C and turning off A and D, there is a finite “rise time” associated with the gates of the transistors. This means that for a very brief period, A and B will be conducting. This will cause “shoot-through”, which will in turn cause the power supply to be shorted. This is called the “dead time”

When the power is relatively low and the speed of the transistors is high (and as such the rise time is small), this isn't normally a problem. However at higher voltages and current levels, this can increasingly become a problem. This can cause damage to the power supply by over-current, and to the transistors. By damage, I mean burst into flames and/or explode.

In order to prevent this from occurring, supporting logic must be used to ensure that this dead-time is minimised. By delaying the rising edge signals going to the gates of the transistors, dead-time can be reduced. However if the delay is too large this will cause the motor to operate inefficiently if the motor is changing direction frequently (as the motor will coast for a small amount of time before changing direction). Also, the rise time is dependent on the load which the transistor is driving - for higher loads the rise time will be slower.

Often Motor driver ICs have dead-time compensation built in, and so this is less of a problem. However, choosing the right driver IC is important, since choosing an over-rated IC will mean that the dead-time compensation may affect the normal operation of the chip.

Parts

  • L298 Motor Driver IC - Has two full H-bridges so can drive two separate motors, and can output 2A and up to 46V.

Reference

reference/motordriver.txt · Last modified: 2010/02/03 21:49 by fish
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki