dc motor speed control with pic microcontroller

4
1 | Page Project Final Report On E Course Code: Semester: Date: Program: Dual Degree Program Submitted By: Jawad Ali REG ID : CIIT/DDP-FA10-BTE-022/LHR Submitted To: Engr. Mr. Usman Rafique DC Motor Speed And Direction Control VI 20/06 /2013 EEE342

Upload: jawad-ali

Post on 31-Dec-2015

63 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DC Motor Speed Control With PIC Microcontroller

1 | P a g e

Project Final Report On

E Course Code: Semester: Date: Program: Dual Degree Program

Submitted By: Jawad Ali REG ID : CIIT/DDP-FA10-BTE-022/LHR

Submitted To: Engr. Mr. Usman Rafique

DC Motor Speed And Direction Control

VI 20/06 /2013

EEE342

Page 2: DC Motor Speed Control With PIC Microcontroller

2 | P a g e

DC MOTOR SPEED AND DIRECTION CONTROL

Description:-

The project is about a DC motor speed as well as direction

control.

The circuit can be interfaced with microcontroller. So the speed of DC

motor can be controlled by microcontroller. PWM Technique is one to the

digital circuit that drives the component correspondingly to change the speed.

A pulse width modulator is a device that may be used as an efficient DC

motor speed controller. This project is versatile that can control DC devices

which draw up to few amps of current. This device may also be use in either less

volts systems.

Basically speed control means intentional change of drive speed to a value

required for performing the specific work process. This concept of speed control

or adjustment should not be taken to include the natural change in speed which

occurs due to change in the load.

And by its direction means rotation of rotor DC motor in clockwise and

anti-clockwise direction is controlled with the help of an IC L293D. L239D can

provide a maximum current of 600mA from 4.5V to 36V while L293 can

provide up to 1A under the same input conditions. All inputs of these ICs are

TTL compatible and clamp diodes are provided with all outputs. They are used

with inductive loads such as relays solenoids, motors etc.

The main aim of the DC motor speed control using PWM is after power

on the power supply generates +5v dc ,+12v dc ,the logic section works on +5v

dc and the motor driven sections are working on +12v dc.

The software part of the project works and verified with simulator as well,

but a speed control switches remains for being work on hardware.

Page 3: DC Motor Speed Control With PIC Microcontroller

3 | P a g e

Program Code:-

void main()

{

short duty = 0; //initial value for duty

TRISD = 0xFF; //PORTD as input

TRISC = 0x00; //PORTC as output

TRISB = 0x00; //PORTB as output

PORTB = 0x02; //Run motor

RB2_bit=1; //PB2=1

PWM1_Init(1000); //Initialize PWM1

PWM1_Start(); //start PWM1

PWM1_Set_Duty(duty); //Set current duty for PWM1

while (1) // endless loop

{

if (!RD0_bit && duty<256) //if button on RD0 pressed

{

Delay_ms(400);

duty = duty + 20; //increment current_duty

PWM1_Set_Duty(duty); //Change the duty cycle

}

if (!RD1_bit && duty >0) //button on RD1 pressed

{

Delay_ms(400);

duty = duty - 20; //decrement duty

PWM1_Set_Duty(duty);

}

Delay_ms(500); // slow down change pace a little

if(!RB2_bit) //if button on RB0 pressed

{

PORTB=~PORTB; //Toggle PORTB

}

}

}

Page 4: DC Motor Speed Control With PIC Microcontroller

4 | P a g e

Schematic:-

VSS

VDD

RA0/AN02

RA1/AN13

RA2/AN2/VREF-/CVREF4

RA4/T0CKI/C1OUT6

RA5/AN4/SS/C2OUT7

RE0/AN5/RD8

RE1/AN6/WR9

RE2/AN7/CS10

OSC1/CLKIN13

OSC2/CLKOUT14

RC1/T1OSI/CCP216

RC2/CCP117

RC3/SCK/SCL18

RD0/PSP019

RD1/PSP120

RB7/PGD40

RB6/PGC39

RB538

RB437

RB3/PGM36

RB235

RB134

RB0/INT33

RD7/PSP730

RD6/PSP629

RD5/PSP528

RD4/PSP427

RD3/PSP322

RD2/PSP221

RC7/RX/DT26

RC6/TX/CK25

RC5/SDO24

RC4/SDI/SDA23

RA3/AN3/VREF+5

RC0/T1OSO/T1CKI15

MCLR/Vpp/THV1

U1

PIC16F877A

IN12

OUT13

OUT26

OUT311

OUT414

IN27

IN310

IN415

EN11

EN29

VS

8

VSS

16

GND GND

U2

L293D

0.0

0

X1

CRYSTAL

C122pF

C222pF

B15V MOTOR SUPPLY

12V

R110k

UP

R210k

DOWN

SW2

SW-SPDT

SW1

SW-SPDT