DC Motor Controlling System using PIC

Now a days DC motors plays a vital role in most of the industrial areas, it can be seen in most of the electronic devices. They are mainly used for the mechanical movements of physical applications such as rolling the bundle of sheets or CD drives, lifts etc.

Many methods evolved to control the revolution of a motor. DC motors can be controlled either by software or directly by hardware. Software controlling needs computers which are bulky and common man cannot afford for it, so hardware controls are in use. Even in hardware if it is programmable device then it is preferred because it can be modeled according to the requirements of the user.

Advantages of using PIC over other controlling devices for controlling the DC motor are given below:

  1. SPEED: The execution of an instruction in PIC IC is very fast (in micro seconds) and can be changed by changing the oscillator frequency. One instruction generally takes 0.2 microseconds.
  2. COMPACT: The PIC IC will make the hardware circuitry compact.
  3. RISC PROCESSOR: The instruction set consists only 35 instructions.
  4. EPROM PROGRAM MEMORY: Program can be modified and rewritten very easily.
  5. INBUILT HARDWARE SUPPORT: Since PIC IC has inbuilt programmable timers, ports and interrupts, no extra hardware is needed.
  6. POWERFUL OUTPUT PIN CONTROL: Output pins can be driven to high state, using a single instruction. The output pin can drive a load up to 25mA.
  7. INBUILT I/O PORTS EXPANSIONS: This reduces the extra IC’s which are needed for port expansion and port can be expanded very easily.
  8. INTEGRATION OF OPERATIONAL FEATURES: Power on reset and brown/out protection ensures that the chip operates only when the supply voltage is within specification. A watchdog timer resets PIC if the chip ever malfunctions and deviates from its normal operation.

Basic Idea:

There are two types of DC motors, unidirectional and bidirectional. Unidirectional rotates in only one direction and it is specially meant for some specific applications while the bidirectional can be rotated in the clock-wise or the anti-clockwise direction. This the most widely used for industrial applications.  There are two parameters to be considered in controlling the movements of a DC motor.

  1. DIRECTION
  2. SPEED

The first thing that can be controlled in a motor is its direction of rotation. Direction of the motor can be controlled by controlling the polarity of the current flowing through it.  Usually a DC motors are driven by famous H-Bridge circuits made up of either transistors or the buffers or any other suitable methods.

Controlling the speed of the motor is another important area to be considered. The speed of motor is directly proportional to the DC voltage applied across its terminals. Hence, if we control the voltage applied across its terminal we actually control its speed.

A PWM (Pulse Width Modulation) wave can be used to control the speed of the motor. Here the average voltage given or the average current flowing through the motor will change depending on the ON and OFF time of the pulses controlling the speed of the motor i.e.. The duty cycle of the wave controls its speed.

This project is developed with a PIC IC 61F84A, which is programmable. The word PIC stands for PERIPHERAL INTERFACE CONTROLLER, a single chip microcontroller is developed by Microchip technology.

Hardware description:

Block diagram of the DC Motor Controlling System
Block diagram of the DC Motor Controlling System

The block diagram of the circuit is shown above. This circuit controls the speed and direction of the motor. The PWM (Pulse Width modulation) output from the four port pins is given to the H-Bridge circuit which drives the motor. On changing the duty cycle (ON time), we can change the speed. By interchanging output ports, it will effectively change direction of the motor.

The PIC microcontroller is the brain of the circuit controlling all actions to be done. Inputs are given to control the speed and direction of the motor. The PIC output controls the DC motor.

The circuit consists three parts:

1. INPUT:

There are two inputs. One for direction control and the other for speed control. These generates interrupts for the PIC which are used for controlling the speed and direction.

There are 2 interrupts used as control signals for the PIC.

a. External interrupt.
b. PORTB input (interrupt on change).

Interrupts deviates the main program execution to interrupt subroutines (ISR) and return to the main program. The global enable bit in the INTCON register will allow all interrupts to occur. This will reset on going to ISR and set when coming out of it.

An interrupt on external interrupt pin will set  flag INTF in the INTCON SFR(Special Function Register). At the same time the program execution is deviated to the ISR where there is a register used to controls the movement of direction (clockwise or anti-clockwise). An interrupt on portB 4 (4/5/6/7)  pin will set  flag RBIF in the INTCON SFR(Special Function Register). Meantime the program execution is deviated to the ISR, where there is a register used to control the speed of the motor (maximum or minimum).

Want to build your own robot? Check out these robotics products and kits that you can use to get started on building a bot, either totally from scratch or by using a kit.


17 Responses to “DC Motor Controlling System using PIC”

  1. i am interested in doin this project…..can u share with me the schemtics and proram code

    Reply
  2. Vinoth kumar.G

    I am interested to do project on bidirectional 12V dc motor with clock and anti-clockwise Directional rotation.kindly help me by providing source code using PIC16f84A and schematic of the same.

    Thanks & Regards
    Vinoth kumar.G

    Reply
  3. your website very impressive.so please send more articles on electronics

    Reply
  4. The solutions to my inquiries have been very easy to take in thanks to this blog. It is certainly worth reading to aid relieve the stress I have been encountering. I suggest this for an award.

    Reply
  5. WILLIAM BRINK

    thanks for the article

    where do i get the schematic and source

    thanks

    Reply
  6. hello.i would like to know what is the best pic which can go bidirectional.tq

    Reply
  7. Ciao.This and ‘right on track I used to drive a wiper motor 12 V I will use it ‘for a rotisserie.
    Would you be so ‘kind enough to provide the wiring diagram?.
    Many thanks (IK1CFJ)

    Reply
  8. Jeeva balan

    Hi Ranjith, how are you. i’m jeeva.
    I’m doing final year project for my course. i’m using PIC 16F877A to control a 12V DC motor driven pump. I’m having difficulty in controlling the pump speed.
    I just need the pump to increase the speed in time delay.
    For ex: initial 30% speed, aft 2 sec= 50%, aft 5 sec= 100%. In unidirection.

    The PIC get input from sensor, when sensor on, pump operation should start in speed variation. I understand this chip have two PWM output at RC1 & RC2.
    i’m totaly black out how to use this & do the program or this.

    Brother can you please help me…

    Reply
  9. Mvs.Krishnateja

    hey i want to do a project on remote controlled cars…Using PIC its very good one…In my project Time of operation of motor will be changed according to the interest of the operator…so my problem is how to program that without depending on the time of operation….hope u will help me….

    Reply
  10. I WANT TO DO THIS PROJECT,PLZ SEND THE CIRCUIT DIAGRAM ,BLOCK DIAGRAM,ABSTRACT & ALL DETAILS RELATED ON THE DC MOTOR SPEED CONTROL USING PIC 89C51 &PIC 16F84 ,HOPE YOU WILL HELP MEE

    Reply
  11. shael

    and nisha me bhi ye project kar raha …yaar galat baat he….concept churaya tune mera

    Reply
  12. Irfan ali babar

    Dear salam:
    i’m doing computer engineering & working on this project
    (speed/direction control of DC motor),i don’t have any idea about this.that how to interface it with pic16f877a & how to write programme(code) for this.I request you that please send me the schmetic diagram and source code in C (using MPLAB).
    for this favour i will be great thankful to you dear……..

    Reply
  13. PASCHAL

    csn i get the C’ source code for
    dc motor control by using PIC

    Reply
  14. ndimila

    i have been workin on the project same project by using PIC16F877A
    but it hapened that the PIC was not responding to the instructions.
    so please can i get the source code of this project?

    Reply

Leave a Reply