Which DC motor has an approximately constant speed?

Control DC motors

Many do-it-yourself projects are particularly appealing because something moves remotely or under computer control. Vehicles are controlled, flowers are poured with pumps or cocktails are mixed and machines are speed-regulated. In most cases, simple brushed DC motors are used.

Small power consumers such as LEDs or buzzers can be switched directly from the output pins of a microcontroller, which can usually deliver between 10 and 20 mA, without additional wiring. But that's not nearly enough for electric motors. In addition, electric motors have a few other properties that you have to consider when building a motor controller yourself.

Ready-made shields that can control DC motors are already available for Arduino and compatible boards. However, these shields are not suitable for high currents and it is also fun to understand what exactly is going on electrically.

In the basic article about electric motors in Make 4/16, the various mechanical and electrical properties of the different electric motors have already been described in great detail. This article is primarily about brush DC motors with permanent magnets, such as those used in toys, small pumps, most cordless screwdrivers, hair dryers and the like. The electrical properties are of particular interest for control.

Electrical Properties

The simple equivalent circuit diagram above describes the electrical behavior of the motor with electronic components that behave in an equivalent manner. Since the most prominent feature of a motor is the winding made of copper wire, it probably immediately makes sense that it shows the behavior of a coil (represented in the equivalent circuit by the coil symbol L). Since the real electric motor has losses that are generated by contact resistance and the resistance of the winding, this is taken into account in the equivalent circuit by the resistor R. R is usually small (between 1 and 50 ohms).

As soon as the motor turns, it also acts as a generator and thus creates a voltage. This is taken into account by the voltage source on the right in the circuit diagram. It depends on the speed, the strength of the stator field and the so-called motor constant. For our consideration it is sufficient to understand that UEMK is proportional to the speed and is therefore 0 volts at standstill. When idling (maximum speed), UEMK is approximately the same as the applied voltage U.

The idling speed is reached when the engine is mechanically free running (bottom right in the diagram). Theoretically, no current flows because no torque is required. In real life, however, there is friction that requires a small flow of electricity to overcome.

If the motor is at a standstill when the supply voltage is applied, the maximum current flows and the maximum torque is generated (top left in the diagram). Since the generated voltage UEMK = 0, the current is only limited by the loss resistance R. This condition is quickly overcome when the motor starts up, as the motor accelerates.

Usually, a speed is set during operation that depends on the mechanical load and the supply voltage. Higher supply voltage means higher speed. For example, a very high idle speed can be achieved. In extreme cases, however, the motor winding can burn up during start-up. This can be prevented by a controlled soft start (see below). If the motor is operated with its nominal voltage, which is specified in the data sheet, then it can simply be switched on without overloading.

Motor on - motor off

The main purpose of this is to describe cases in which a logic circuit or a microcontroller switches the motor. This means that the control signal typically changes between 0 V and 5 V. Some newer microcontrollers also use 3.3 V.

The various basic transistor circuits were already described in detail in Make 2/2014. Here we limit ourselves to emitter switching in switching mode. This means that the transistor is either switched to high resistance or completely into saturation, so that it works almost like a closed switch. A residual voltage on the transistor would cause a power loss dependent on the current through the motor, which only heats up the transistor and is not available to the motor.

The NPN bipolar transistor amplifies the current that flows into the base and makes it available at the collector. If the microcontroller switches to 0 V, no current flows through the series resistor R.B. into the base of the transistor so that the collector current through the motor is also zero. The transistor acts like an open switch - the motor is switched off.

If the motor is to be switched on by applying 5 V to the base resistor, the series resistor RB. be chosen so that the transistor is fully controlled. R.B. = (5V - 0.7V) / IB.. In the case of power transistors, as they are used here, the current gain is hfe often quite small. For a BD169 that can withstand 1 A maximum collector current, it is around 100. The base current must therefore be at least 10 mA, which is what a base series resistor RB. = 430 ohms. Since the current gain can vary and the control voltage can also be lower, the resistance should be chosen one size smaller to be on the safe side. 330 ohms, the next lower value in the E6 series, is recommended here.

ignition coil

As already described above, however, we also have to deal with the other electrical properties of the motor. The relevant components of the equivalent circuit diagram: The inductance L acts like an energy store (these and other properties of the coil have already been described in detail in a basic article in Make 2/16). When switched on, this property means that the current only increases slowly because the magnetic field has to be built up first.

If the motor current is switched off, the coil tries to maintain the previously flowing current, which happens because the voltage on the coil increases sharply in the opposite direction. The voltage depends on the current I through the coil, the inductance L of the coil and the time dt in which the current is changed from the original value to zero. In the simple case that the current falls linearly to zero, this relationship results: Uind = L * I / dt. This is also the principle that ignition coils use in internal combustion engines. In this way, several thousand volts can be induced briefly, which generate an ignition spark.

However, transistors have a much lower allowable maximum voltage between collector and emitter. With the BD169, for example, it is 80 V. The rapid switch-off creates a voltage at the collector that is around Uind higher than the supply voltage. It would therefore be destroyed with a high degree of probability when switching quickly.

The countermeasure can already be seen in the circuit diagram: A diode connected in parallel in the reverse direction enables the current to continue to flow through the diode. Due to the losses in this circuit, the current dies down quite quickly. The voltage between collector and emitter can only rise up to a maximum of the operating voltage plus the threshold voltage at the diode - i.e. with a 12 V supply up to about 12.7 V.

Often this diode is called "protection diode", which describes the purpose well. Alternatively, they are also known as “free-wheeling diodes” according to what they enable the current to do: to continue running freely. The maximum voltage can also be limited with a Zener diode or a varistor, which are connected in parallel between the collector and emitter. Here the current dies away faster, which is desirable, for example, with switched relays (which also contain coils). With the high motor currents, the diode circuit is better because there is less power loss in the semiconductor.

Extreme example

In the project “model winch with car starter”, a motor was to be switched with transistors, which draws up to 200 A from the car battery when it starts up. Although these motors in particular have a very small inductance, this very high current wants to continue to flow and generates very high induction voltages according to the formula above. The first experiments with 1N4007 diodes, which can withstand 1 A, ended with smoke signals. Not on the transistor, for example - we hadn't taken into account that the diodes have to withstand currents of the same order of magnitude as the switching transistors.

Several measures were necessary to get the problem under control: Shottky diodes replaced the common Si diodes. These Si-metal diode sections have a significantly lower threshold voltage, which means that the power (P = U x I) in the diode is reduced. The switching frequency was reduced (see next section) and the switching time was extended with an RC element at the input. Although this also led to slightly higher losses in the switching transistor, it reduced the induction voltage.

If you want to switch very high currents, first of all use transistors that can switch 20 A or higher currents. If the current - as in the winch example - is to be much higher, transistors can be connected in parallel.

Unfortunately, bipolar transistors have the unpleasant property that the base-emitter voltage decreases when heated. This leads to an increase in the base current and thus to an increase in the current at the collector. It can therefore happen that one transistor in the parallel circuit has to perform significantly more than the others. This can be prevented with a small resistance between the emitter and GND, which creates a voltage drop due to the higher current flow and thus counteracts this effect. But especially with large currents one would like to avoid these losses.

Metal oxide field effect transistors (MOSFETs) solve these problems: They are not switched by a control current, but with a control voltage. So you can get by here with very small currents. With a negative tempreature coefficient, they can easily be connected in parallel in order to deal with very high currents. Many logic-compatible types reach their full saturation already at 5 V, so that they can be connected directly to the outputs of a microcontroller. The basic series resistor can be omitted, but the freewheeling diode cannot be done without.

Take it slow

Many applications require speed control or even regulation. The voltage on the motor must therefore be reduced in order to lower the speed (see diagram). The obvious thing would be to simply not turn on the transistor completely, so that a voltage remains between the collector and emitter or drain and source that is not available to the motor. At 50 percent partial load, however, this would mean that the same power that the motor needs would have to be converted into heat in the transistor - an unacceptable solution.

With pulse width modulation - the fast switching on and off - the voltage can be set much more efficiently. Here the transistor functions again as a switch that only experiences the states “open” and “switched through” and thus remains cool. If the pulses are wide and the pauses between them are short, a high average voltage and thus a high speed are set; with narrow pulses, the average voltage on the motor and the speed are reduced.

Microcontrollers like Atmel's ATMega series (used on the Arduino boards) have PWM outputs that are ideal for this application. If you just want to set the motor speed with a potentiometer, a very simple analog circuit is sufficient. An example is shown here based on the NE555 analog timer IC.

Only four signals of the IC are required for this: The output pin (pin 3) controls the base of the driver transistor and charges the capacitor C via the potentiometer R through the diode D1. Via pin 6 the IC compares the voltage on the capacitor with an internal reference voltage. As soon as C is charged to this point, output 3 switches to 0 V. Now the capacitor is discharged via D2 and the potentiometer. Depending on the wiper position of the potentiometer, either the charging or discharging process takes longer. The frequency always remains the same. It is roughly calculated from f = 1 / R * C. The circuit can easily be built on a breadboard.

Loud or hot

If the frequency of the pulse-width-modulated signal is within the audible range, unpleasant noises can occur because the motor winding vibrates acoustically. A frequency beyond 20 kHz avoids this problem, but creates another: switching losses.

In the previous considerations, we have assumed that the transistor changes infinitely quickly from the open to the closed switching state. However, since in reality this takes a finite time depending on the transistor and the wiring, the transistor is briefly in a not fully switched state, which we want to avoid. The voltage applied to the transistor between collector and emitter multiplied by the collector current describes the power loss on the transistor during the switching process. This is released into the air in the form of heat. This means that a higher switching frequency causes the transistor to get hot. A heat sink is required.

Speed ​​control without sensor

The speed of an electric motor can be controlled by means of pulse width modulation. However, if you want to keep the speed at a certain value regardless of the load, it must be regulated. To do this, you have to measure it and adjust the supply voltage accordingly using feedback. The obvious thing to do is of course to measure the speed with an optical or magnetic sensor on the motor shaft. Much simpler - albeit a little less precise - is the evaluation of the generator effect. Since the field through the permanent magnets is constant, the generated voltage is UEMK proportional to the speed. So you can regulate the engine speed if you know this voltage. However, it cannot be measured directly because only the voltage at the motor terminals is known. The current I through the motor can also be measured.

A look at the equivalent circuit diagram of the motor shows that knowing these two parameters can be used to calculate the generator voltage, even if the loss resistance R.V known: UEMK = U - I x RV. The value of RV can be measured with an ohmmeter (see picture): Here it is around 20 ohms.

The control measures the current continuously and calculates the generator voltage U from itEMK. If U is reduced in sizeEMK, this means that the speed has decreased due to an increase in load - consequently, the control increases the terminal voltage U until the same generator voltage is obtained again. Since the current also changes here, it has to be measured further and included in the calculation. If the load is reduced, the speed and thus U increasesEMK - the control process is reversed.

If you want to set up this control with a microcontroller, the current can be measured by a voltage drop across a (low-resistance) resistor. The voltage drop should only be a few 100 mV so that this resistor does not suffer too much loss. Depending on the voltage range and resolution of the analog controller input, it may be necessary to increase the voltage. In our setup with a very small toy motor, we were able to use a relatively high measuring resistor.

Since the motor is pulsed via PWM, the voltage at the measuring resistor still has to be smoothed by a low-pass filter. With CTP = 100 nF and RTP = 15 kOhm a limit frequency of 100 Hz is reached, which suppresses a large part of the PWM cycle.

The control algorithm can of course calculate out the voltage drop Um at the measuring resistor. So UEMK = U - RV x I - UM., where I = UM./ RM. is. Thus U is calculatedEMK = U - UM. x (RV/ RM. - 1). In the simple example structure with the small motor with RV = 20 Ohm and a measuring resistor RM. from 10 ohms the generated voltage U is calculatedEMK = U - UM..

The control process can be monitored by outputting the controlled variables via the serial interface. However, the slowing down of the control loop has an effect on the control behavior. This can lead to vibrations. The respective speed at a certain voltage UEMK must be determined experimentally while idling.

Right - left

To reverse the direction of rotation of the motor, reverse the polarity of the voltage at the motor terminals. This is particularly easy when you have a positive and a negative power supply available. Then one motor terminal remains connected to ground (Ground / GND, 0 volts), while the other is connected to either the positive or negative supply voltage. Using switching transistors results in a type of push-pull circuit that is similar to audio output stages.

In the early years of remote control technology for model making, this circuit variant was used by Graupner / Grundig remote controls in order to save the transistors, which were expensive at the time, and above all space. Since the batteries consisted of four NiCd cells connected in series, each 1.2 V, GND was connected to the center tap of the battery.This results in +2.4 V or –2.4 V at the other terminals. However, the savings in semiconductors were bought at the expense of poor motor torque, since only half the supply voltage was available for each direction of rotation.

H-bridge

The motor control becomes more efficient with an H-bridge, in which the full operating voltage is available for both directions of rotation. A negative operating voltage or a battery center tap is therefore not required. Instead of a bridge with PNP and NPN transistors, two such bridges are now used, so that each of the two motor terminals can be connected to U + or GND. The name "H-Bridge" is also evident from the circuit diagram.

If the motor is to run clockwise, the transistors T1 and T4 are switched on by connecting the base of T1 to GND via the series resistor, while the base of T4 receives positive voltage. The current now flows through the motor from left to right in the circuit diagram (blue arrow). If T1 and T4 are now blocked and T2 and T3 are switched through instead, the current flows in the opposite direction and the direction of rotation of the motor is reversed.

Here, too, there must be free-wheeling diodes, because when switching off, as in the simple examples above, voltage peaks are induced that can destroy the semiconductors. This circuit principle is used today in practically every DC motor control from the electric sunroof in the car to the servo in model making.

It becomes clear that you absolutely have to avoid switching through both transistors on one side at the same time. With rapid switching, this "shoot through" state can occur during the switching time, which leads to increased losses and heating of the transistors. If the circuit is controlled by a microcontroller, it can be achieved through clever programming that one transistor of the H-half is always opened before the other switches through after a short break.

The H-bridge can also be used to control the speed using PWM. If, for example, the speed is to be reduced in the above case, T1 can remain switched on permanently and the PWM signal is applied to T4.

In the basic circuit diagram, we have omitted the control of the transistors by a microcontroller. The picture above shows the expansion of the circuit for control with TTL-compatible signals (0 V / 5 V). The drivers T5 and T6 switch the PNP output stage transistors regardless of how high the operating voltage of the H-bridge is. The NPN transistors are controlled in the same way as in the simple circuits at the beginning of the article.

This circuit variant prevents the forbidden states: T1 and T2 or T3 and T4 cannot conduct at the same time. A cross current can only occur briefly when switching over.

Stop, stop!

With the appropriate control, the H-bridge circuit can also quickly brake a motor, for example in a cordless screwdriver or an electric vehicle. Here you take advantage of the fact that a DC motor can always work as a generator. If the voltage generated during coasting is short-circuited via a small resistor, the kinetic energy is converted into heat and the motor quickly comes to a standstill. For this purpose, either the upper or the lower two transistors are switched on.

H-bridges also benefit from the use of MOSFET power transistors. Here the NPN transistors are replaced by N-MOS types and the PNP transistors by P-MOS FETs. You can do without basic series resistors.

So that the power loss remains small, the resistor RDSON be as close as possible to zero ohms between drain and source in the active state. For technological reasons, N-MOSFETs have a lower R.DSON than the complementary P-MOSFETs. Therefore, in professional circuits, all four switches of the H-bridge are often equipped with N-MOSFETs, but special circuit measures are then required to control the transistors on top (additional operating voltage or a so-called bootstrap circuit).

Integrated H-bridges

As long as only small motors are to be controlled, the task is simplified by the use of integrated H-bridge ICs. The L293 has established itself for motor currents below 1 A and supply voltages below 36 V. The IC contains two H-bridges so that either two DC motors can be controlled at the same time or a two-phase motor (for example stepper motor, see also page 18). It is even possible to control each branch of the bridge individually; this means that four motors can be connected if the only thing you need to do is to switch them on and off.

The triangular drivers in the block diagram of the module symbolize the complementary transistor output stages. There are two types of this module, which differ slightly in the structure of the driver: The L293 supplies up to 1 A motor current, free-wheeling diodes must be added externally. The L293D only has a motor current of 600 mA, but the free-wheeling diodes are already integrated in the IC.

To operate a DC motor with L293 and a microcontroller - here an Arduino for the sake of simplicity - two or three signal outputs are required: Two outputs are connected to driver inputs 2 and 7 (see picture) of the L293. This is used to control the direction of the motor. If you always want to run the motor at maximum speed, it is sufficient to permanently connect enable pin 1 to +5 V. However, if you connect it to a PWM output of the microcontroller, you can use pulse width modulation to control the speed in addition to the direction of rotation.

The L293 requires two separate power supplies. The logic voltage VCC1 at pin 16 can be connected directly to the 5 V line of the Arduino. The motor voltage can be up to 36 V and therefore comes from another source (battery, own power supply unit). Don't forget the ground connection of the four GND pins (4, 5, 12, 13) to the Arduino.

The many ground pins have another task: They are supposed to dissipate the heat loss from the chip to the circuit board, which is why a circuit board design in practice provides for a larger ground area in the immediate vicinity of the IC.

In our simple example, the motor rotates depending on the wiper position of the potentiometer, which is connected between 5 V and GND. The analog-digital converter of the Arduino measures the voltage on the slider and translates the slider position into the value range from 0 to 1024. With values ​​smaller than 512 (left of the middle position of the potentiometer) the motor turns clockwise - with values ​​above this threshold it runs he in the opposite direction. The value of the PWM output (and thus the speed) increases towards the end positions and is equal to zero in the middle position of the potentiometer.

If you want a little more power, you can switch to the L298, for example. This integrated H-bridge is specified up to a maximum voltage of 46 V and a maximum total current of 4 A. The housing has a large cooling surface, which is usually mounted on a heat sink. In this way, greater power loss can also be dissipated. The wiring of the L298 is essentially identical to that of the L293, so that it should be sufficient to only show the circuit diagram of the L298 here. Data sheets can be found under the links below. -cm

make-magazin.de/xmk6

make-magazin.de/xmk6