Вы находитесь на странице: 1из 4

Project Final Report

On E
DC Motor Speed And Direction Control

Course Code: Semester: Program:


Dual Degree Program
VI

EEE342

Date:

20/06 /2013

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

Submitted To: Engr. Mr. Usman Rafique


1|Page

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.

2|Page

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 } } }

3|Page

Schematic:SW1
SW-SPDT

SW2 U1
13 14 OSC1/CLKIN OSC2/CLKOUT RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD 33 34 35 36 37 38 39 40 15 16 17 18 23 24 25 26 19 20 21 22 27 28 29 30 SW-SPDT 2 7 1

X1

16 IN1 IN2 EN1 VSS

8 VS OUT1 OUT2

U2
3 6
0.00

CRYSTAL

C2
22pF

C1
22pF

2 3 4 5 6 7 8 9 10 1 VDD

RA0/AN0 RA1/AN1 RA2/AN2/VREF-/CVREF RA3/AN3/VREF+ RA4/T0CKI/C1OUT RA5/AN4/SS/C2OUT RC0/T1OSO/T1CKI RE0/AN5/RD RC1/T1OSI/CCP2 RE1/AN6/WR RC2/CCP1 RE2/AN7/CS RC3/SCK/SCL RC4/SDI/SDA MCLR/Vpp/THV RC5/SDO RC6/TX/CK RC7/RX/DT RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7 PIC16F877A

R1
10k

R2
10k

9 10 15

EN2 IN3 IN4

GND

OUT3 GND OUT4

11 14

L293D

B1
5V

MOTOR SUPPLY
12V

UP

DOWN

VSS

4|Page