About me‎ > ‎

Closed loop speed control of DC motor using back emf sening

Working on motor control had always been my passion. For this project, I thought of working on something simpler in hardware. Hence it came out as a speed closed loop control of DC motor using back emf sensing.

Running a DC motor is as simple as glowing a LED. The schematic is mentioned below: -

Running a DC motor in one direction, just replace the LED with DC motor and remove the current limit resistor. Please note that motor - direction reversal is not possible with this configuration. The motor speed can be varied by varying the duty cycle of PWM.

But a common problem with this schematic for DC motor control is that if the motor is loaded (mechanical load), the motor speed reduces. In other words, the system is running in open loop. If we have to make a system as closed loop, we should have a mechanism to feedback the motor speed back into the controller (PIC18F4520). Only then, the controller will know the present speed of motor and vary the duty cycle of PWM to compensate for any change in mechanical load.

For sensing the motor speed and feeding it back to controller, usually, some transducer (sensor) is used such as: -

1. Tachogenerator (analog output).
2. Quadrature encoder (pulse output).
3. Resolver (Not used unless it is flight control or defense application).
4. Photo interrupter (common one, can be found in older ball type mouse).

These sensors are great, but all of them cost money. How do we make a closed loop control of normal DC motor, which does not come with any sensor?
Well, the technique does exist and it uses the back emf of motor to sense the speed of motor. Please refer to the diagram below: -

A DC motor when driven by external means, will generate a voltage. This voltage is also generated by the motor, when it is supplied by a DC source. This voltage is proportional to the speed of motor and is called the back emf. Best part is that the back emf is linearly proportional to the speed. To measure the back emf of motor, we stop the PWM driver for a brief period. During this brief period, the motor coasts for sometime when the current flows through the freewheeling diode. Once the energy stored in motor inductance is exhausted, the back emf build up. This back emf is scaled to suitable voltage using the potential divider. The back emf signal is then fed into the ADC input of controller.

Some advantage of using this control scheme: -

1. Cost effective (This is the most important and mostly sought after reason).
2. Easy on hardware design.
3. Can be retrofitted on systems where motor does not come along with the encoder.
4. Small motors with gear used for hobby robotics usually run at high speed (gear runs at low speed, gear reduction). Such motor can easily use this scheme.

Where this scheme cannot be used: -

1. Cannot be used to control the motor at extremely low speeds as motor does not generate sufficient back emf.
2. Cannot be used in system where torque ripple cannot be tolerated. Stopping the PWM for back emf measurement causes torque ripple.
3. If the motor is configured to run on both direction (using H bridge), then the back emf measurement circuit becomes complicated (differential measurement).

Hardware configuration for motor driver: -

The circuit given above has some limitation and hence cannot be used directly to drive a motor in real application. That is because, when PNP transistor is OFF, the +12V will appear at the port pin of microcontroller. Though for PIC, it might not be an issue (due to presence of clipping diodes), its not a good design.

The real circuit is as below: -

The transistor TIP127 was selected due to its higher current rating and large gain (less current required to drive the transistor).
BC547 was selected as it is readily available.
Freewheeling diode of 1N5819 selected as it has fast characteristics. But in real circuit, UF4007 was used.

Derivation for R3: -

Lets say, the DC motor takes a current of 2Amps (peak), hence, collector current of TIP127 = 2Amps. Also, hfe of TIP127 (from data sheet) = 1000.
Hence base current of TIP127, Ib = Ic/hfe => 2/1000 = 2mA = current through R3 resistor -------- (1)

Now, by Kirchhoff voltage law,
+12V = Voltage across BE of TIP127 + Voltage across R3 + Voltage across CE of BC547
=> +12V = 2.5V (from data sheet) + Voltage across R3 + 0.25V (from data sheet)
=> Voltage across R3 = (12 - 2.5 - 0.25) = 9.25V   ------- (2)

From (1) and (2), Value of R3 = 9.25V/2mA = 4625Ohms = 4.7K (practical value)
Power rating of R3 = (2mA)^2 * 4.7K = 0.0188W, so a 1/4W resistor would suffice.

Derivation of R1: -

hfe of BC547 = 100 and collector current of BC547 = 2mA
Hence, base current of BC547 = 2mA/100 = 0.02mA

R1 = 5V (from microcontroller) - Vbe (from data sheet)/0.02mA = (5 - 0.7)/0.02mA = 200K

R2 can be chosen as 10 times of R1. Also, another resistor is connected of value 47K across B and E of TIP127 (not shown in the circuit).

Picture of entire setup:-


Software Code: -
Revision - 1 consist of simple PWM generation by PIC based on command from UART. The PWM in turn controls the speed of DC motor. The UART also displays the set value of duty cycle.

Demos: -

YouTube Video

YouTube Video

YouTube Video

YouTube Video

YouTube Video

YouTube Video

YouTube Video

Debraj Deb,
Aug 30, 2011, 9:49 AM