DC Motor Interfacing With PIC Microcontroller Using L293 Motor Driver IC

L293d is an H Bridge bidirectional motor driver IC used to interface DC motor and stepper motors to Microcontrollers.

CircuitsGallery.com already discussed about the working principle of L293 IC with an example of bidirectional motor driver circuit.

It is very easy to make a DC motor control using microcontroller. In this article I’m gonna show you the interfacing of DC motor with PIC16F877A microcontroller using L293D motor driver with the help of Mikro C coding and Proteus 8 simulation. Basically it is a bidirectional motor driver circuit with PIC MCU.

This is the most common circuit in robotics engineering. I’m sure this article will be helpful for PIC MCU beginners.

Must read: Build your own USB PIC burner

What is H Bridge?

H bridges are widely discussed topic in electronics. As we know, just changing the polarity of supply voltage causes rotating of DC motor in reverse direction.

But this method is not suitable for practical circuit. So, how to run DC motor in clockwise and anti-clockwise direction without changing the supply polarity?
H Bridge Motor driver

Here comes the importance of H Bridge. In a typical H Bridge circuit two pairs of transistors are connected in a bridge fashion and the motor is driven through the collector terminal.

Read more: H Bridge motor driver circuit using transistors

Why L293?

Obviously we know that ICs make life easy!
  • The transistor based H bridges are little complex and bulky and also time consuming while implementing practically.
  • L293 is basically an H bridge IC capable of driving two motors simultaneously, that means it has two embedded H bridges inside!
Interfacing of L293 to DC motor and microcontroller is very easy and simple process.
The specialty of L293 is that it has dedicated ‘Enable Pin’ to control the motor. By manipulating this pin it is possible to control the speed of dc motor with Pulse Width Modulation technology.

Read more: Bidirectional motor driver circuit using L293DC Motor

Schematic diagram

DC Motor interface with PIC using L293d
(Click on the image to enlarge)

Components required

  1. PIC16F877A
  2. L293d
  3. DC Motor 
Tools Required:
  1. Mikro C Pro 
  2. Proteus design suit

Mikro C code for DC motor interface

The Switch at PORTD.F2 is responsible for direction changing of motor. We have also used PWM speed controlling method here in order to use this program for further development for robotics.

Program Logic
  • We are applying 0x01 = 0000 0001 and 0x02 = 0000 0010 to the input pin of L293 driver IS using micro controller.
  • According to this inputs the direction of motor will change. (Refer below table to understand the basic configurations of L293 IC).
L293 input and direction configurations
Program



Further Help: Getting Started with Mikro C

Program Simulation in Proteus 8

Step 1:
Write the above C codes in Mikro C and build .Hex fie.

Help: How to build .Hex file

Step 2:
Run Proteus 8 and draw the schematic DC motor interface with PIC

Step 3:
Load .Hex file to PIC MCU by double clicking on the IC.
Proteus 8 Simulation
Step 4:
Now it’s time to simulate… Run
Proteus 8 Run Simulation

Step 5:
Change the switch positions at PORTD.F2 and observe the bidirectional rotation.
Proteus 8 Simulation

Downloads: DC Motor interface with PIC Microcontroller using L293 .hex file

Circuits Gallery Video Lab

Watch this video of Simulation, this video explains whatever you need to know about this PIC tutorial.

For more videos visit our CircuitsGallery Video Lab now...!
Please like our Facebook page to get connected. Cheers….!

1 comment:

  1. why my DC motor producing Jerks! not rotating! could you please help me from this.

    ReplyDelete