PIC16F877A – DC Motor Interfacing

In this tutorial we are going to learn DC Motor Interfacing with PIC16F877A. Let’s run….

Prerequisites

Introduction

When we talk about controlling the robot, the first thing comes into the mind is controlling DC motors. Interfacing DC motor to the microcontroller is very important concept in Robotic applications. By interfacing DC motor to the microcontroller, we can do many things like controlling the direction of the motor, controlling the speed of the motor. This article describes you how to control the DC motor using PIC16F877A controller.

A DC motor in simple words is a device that converts electrical energy (direct current system) into mechanical energy. It is of vital importance for the industry today.

The maximum output current of microcontroller pin is 15mA at 3.3V. But the power requirements of most of DC motors is out of reach of the microcontroller and even the back emf (electro motive force) which is produced by the motor may damage the microcontroller. Hence it is not good to interface DC motor directly to the controller. So use motor driver circuit in between of DC motor and controller.

Here, we are using L293D motor driver IC to drive DC motors. Using this IC, we can drive 2 DC motors at a time. For this IC motor supply is variable 4.5 to 36V and it provides maximum current of 600mA. Just refer Here for the L293d Driver’s operation.

DC Motor Interfacing with PIC16F877A

Circuit Diagram

  • Input 1 – Port B.0 (RB0)
  • Input 2 – Port B.1 (RB1)
  • Enable 1 – Directly giving 5v
  • Button – Port B.2 (RB2)

Working Algorithm

Forward

  • EN Pin High  (En1 = 1 or En2 = 1)
  • Input 1 or Input 3 Pin High (In1 = 1 or In3=1)
  • Input 2 or Input 4 Pin Low (In2 = 0 or In4 = 0)

Reverse

  • EN Pin High  (En1 = 1 or En2 = 1)
  • Input 1 or Input 3 Pin Low (In1 = 0 or In3=0)
  • Input 2 or Input 4 Pin Low (In2 = 1 or In4 = 1)

Code

In this code motor will rotates in forward when we press the button. Here i’ve connected button’s one end into +5v. So in if function i’m checking with 1 if(sw==1). But if you connect that end into ground, you should check with 0 if(sw==0).

Output

DC Motor Interfacing with PIC16F877A[ Please find the output image Here ]

Notes:

  • The maximum current capacity of L293 is 600mA/channel. So do not use a motor that consumes more than that.
  • The supply voltage range of L293 is between 4.5 and 36V DC. So you can use a motor falling in that range.
  • Mostly in Robotic application we will use DC gear Motor. So same logic is used for that Gear motor also.
0 0 vote
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
chandra sekhar Sai
chandra sekhar Sai
November 7, 2019 8:58 AM

Hi sir I am trying to interface the motor with the help of l293d to interfaced 8051 microcontroller, now I used Texas-msp430 module can I connect the same L293d in this project to run motor please reply me

http://bigbelectronics.in/product.php?product=dc-gear-motor-500-rpm

EmbeTronicX
EmbeTronicX
Reply to  chandra sekhar Sai
November 8, 2019 10:45 AM

Hi Chandra Sekhar,

Yes you can use that and configure the correct GPIO.

chandra sekhar Sai
chandra sekhar Sai
November 7, 2019 8:58 AM

Hi sir I am trying to interface the motor with the help of l293d to interfaced 8051 microcontroller, now I used Texas-msp430 module can I connect the same L293d in this project to run motor please reply me

http://bigbelectronics.in/product.php?product=dc-gear-motor-500-rpm

3
0
Would love your thoughts, please comment.x
()
x
%d bloggers like this: