DC Motor interfacing with Microcontrollers tutorial: Introduction

Introduction
Whenever a robotics hobbyist talk about making a robot, the first thing comes to his mind is making the robot move on the ground. And there are always two options in front of the designer whether to use a DC motor or a stepper motor. When it comes to speed, weight, size, cost... DC motors are always preffered over stepper motors. There are many things which you can do with your DC motor when interfaced with a microcontroller. For example you can control the speed of motor, you can control the direction of rotation, you can also do encoding of the rotation made by DC motor i.e. keeping track of how many turns are made by your motors etc. So you can see DC motors are no less than a stepper motor. In this part of tutorial we will learn to interfacing a DC motor with a microcontroller. Usually Hbridge is preffered way of interfacing a DC motor. These days many IC manufacturers have Hbridge motor drivers available in the market like L293D is most used H-Bridge driver IC. Hbridge can also be made with the help of trasistors and MOSFETs etc. rather of being cheap, they only increase the size of the design board, which is somtimes not required so using a small 16 pin IC is preffered for this purpose.

Working Theory of H-Bridge
The name "H-Bridge" is derived from the actual shape of the switching circuit which control the motoion of the motor. It is also known as "Full Bridge". Basically there are four switching elements in the H-Bridge as shown in the figure below.
The image part with relationship ID rId4 was not found in the file.

As you can see in the figure above there are four switching elements named as "High side left", "High side right", "Low side right", "Low side left". When these switches are turned on in pairs

We can also make a small truth table according to the switching of H-Bridge explained above. the only thing is the power handling capacity of the circuit. This is the basic working of H-Bridge. when you switch on low side left and high side right. So head sinks are needed to cool the circuit. The image part with relationship ID rId5 was not found in the file. If motors are needed to run with high current then lot of dissipation is there. Now you might be thinkin why i did not discuss the cases like High side left on and Low side left on or high side right on and low side right on. or other . if we switch on High side left and Low side right then motor rotate in forward direction. Truth Table Low Left Low Right Off On On Off Off Off On On High Left On Off On Off High Right Off On On Off Description Motor runs clockwise Motor runs anti-clockwise Motor stops or decelerates Motor stops or decelerates As already said. Clearly seen in the diagra. as current flows from Power supply through the motor coil goes to ground via switch low side right. So that is why those combinations are not discussed in the truth table.motor changes its direction accordingly. This is shown in the figure below. the current flows in opposite direction and motor rotates in backward direction. Like. Similarly. So we have seen that using simple switching elements we can make our own H-Bridge. you don't want to burn your power supply by shorting them. H-bridge can be made with the help of trasistors as well as MOSFETs.

BJT H-Bridge Demo . BJT H-Bridge A simple H-bridge can be made with the help of Power BJTs like TIP31 and TIP32.option we have is using an IC based H-bridge driver. Both of them are discussed in the next section of the tutorial. An example and a working demo of this circuit is shown in the figure below.

Make positive of motor 0 .Enable to run the motor .Enable pin of IC .L293D E .Make Positive of motor 1 .Wait for some time .Rotate motor forward .Return from routine rotate_f delay break delay rotate_b delay break delay Main .Negative of Motor .Stop the motor .Do this in loop equ P2.L293D B .Let the motor rotate .Make negative of motor 0 .Enable to run the motor .Wait for some time .1 equ P2.Assembly programming CODE: L293D_A L293D_B L293D_E Main: acall acall acall acall acall acall acall acall sjmp rotate_f: setb clr setb ret rotate_b: clr setb setb ret L293D_A L293D_B L293D_E .0 equ P2.2 org 0H .L293D A .Let the motor rotate .Return from routine L293D_A L293D_B L293D_E .Make negative of motor 1 .Rotate motor backward .Positive of Motor .Stop the motor .

Disable the o/p .Return from routine .#20H r6.#FFH r5. here r6. back1 r7.Some Delay .Make negative of motor 0 . back L293D_A L293D_B L293D_E .Make Positive of motor 0 .#FFH r5.break: clr clr clr ret delay: back: back1: here: mov mov mov djnz djnz djnz ret r7.

Sign up to vote on this title
UsefulNot useful