speed control of a dc motor using pwm

5
Requirements: 1. AT89S52 microcontroller 2. ADC0804 ADC chip 3. Preset (10K) 4. 555 timer (ith !pt. resistor !n" c!p!citor #!l$es) 5. %805 &C '. 293D &C %. DC motor This pro ect in#ol#es ! com*in!tion o+ P,- (p$lse i"th mo"$l!tion) !n" ADC (An!lo /Di con#erter) to "ri#e ! DC motor !t #!rio$s spee"s !n" in *oth cloc !n" !nti "irections. P,- is ! concept ith hich one c!n mo"i+ the p$lse #olt! e #!r in it +rom 0 "$t c cle to 100 . represents the time +or hich p$lse is hi h hen comp!re" to the +$ll p$lse len th. or e This im! e *elo represents #!rio$s percent! e o+ "$t c cles +or ! 4ms !#e

Upload: swastik-epari

Post on 01-Nov-2015

223 views

Category:

Documents


0 download

DESCRIPTION

speed control of a DC motor using PWM

TRANSCRIPT

Requirements:1. AT89S52 microcontroller2. ADC0804 ADC chip3. Preset (10K)4. 555 timer (with apt. resistor and capacitor values)5. 7805 IC6. L293D IC7. DC motor

This project involves a combination of PWM (pulse width modulation) and ADC (Analog-Digital converter) to drive a DC motor at various speeds and in both clock and anti directions. PWM is a concept with which one can modify the pulse voltage varying it from 0% duty cycle to 100%. Duty cycle represents the time for which pulse is high when compared to the full pulse length.For eg:This image below represents various percentage of duty cycles for a 4ms wave

This means for a 25% one, youll we get 25% of the input voltage and the criterion is same for the rest of them.Now in the coding part I have made the changes in the duty cycle in accordance with the digital output I get from the ADC. The ADC is connected to my microcontroller at PORT1.The preset which I have used here to send the analog input can be replaced by a joystick with inbuilt preset to make it more realistic and interesting to operate.Now talking about the ADC, its an 8 bit analog to digital converter which means it converts all the analog values to 8 bit digital data i.e. (0-255).The ADC requires a reference voltage according to which it will generate digital values for changes in analog values. The resolution or step-up voltage is 19.531mV. This means that for every 19.531Mv rise in the analog input ADC will increase the digital value by 1 starting from 0 and ending at 255.

The resolution depends upon the reference voltage as well as the type of ADC youre using. Here the reference voltage is 5v while Im working on an 8 bit ADC therefore: Resolution =5(Reference voltage)/256(due to 8 bit i.e. 2^8=256)= 19.531mVADC also requires a clock frequency to work on. I have given it a 640 KHz using a 555 timer IC in a-stable mode.

L293D is connected to microcontroller via pin P2^1 and P2^6

CIRCUIT DIAGRAM

SOURCE CODE#include#includesbit R=P3^0;sbit WD=P3^1;sbit INT=P3^2;sbit n=P2^1;sbit p=P2^6;int read_ADC(){ int temp; R=1; WD=0; WD=1; while(INT==1); R=1; R=0; temp=P1; return temp;}void main(){ unsigned char value=128; INT=1; P1=0xff; value=read_ADC(); while(1) { if(value>125 && value