Requirements:
1.AT89S52 microcontroller
2.ADC0804 ADC chip
3.Preset (10K)
4.555 timer (with apt. resistor and capacitor values)
5.7805 IC
6.L293D IC
7.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 clockwise and anti-clockwise directions.
PWM is a concept with which one can modify the pulse voltage varying from 0% to 100% duty cycle.
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.
Fig. 1: Timing Diagram showing different duty cycles
This means for a 25% cycle, you’ll 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 changes in the duty cycle in accordance with the digital output obtained 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, it’s an 8 bit analog to digital converter that converts all the analog values to 8 bit digital data i.e. (0-255 for which it requires a reference voltage. 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 you’re using. Here the reference voltage is 5v, while I’m working on an 8 bit ADC therefore:
Resolution = 5(Reference voltage)/256(due to 8 bit i.e. 2^8=256) = 19.531mV
AADC also requires a clock frequency to work upon. I have given it a 640 KHz using a 555 timer IC in a-stable mode.
For further information about ADC, check out my project: ADC interfacing with 8051.
L293D is connected to microcontroller via pin P2^1 and P2^6
Fig. 2: Prototype of 8051 Microcontroller based DC Motor Speed Controller
Project Source Code
### #include<reg51.h> #include<delay.h> sbit 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<130) {n=0;p=0;} else if(value<=125) { n=0;p=1; delay_msec(6-(value/25)); n=0;p=0; delay_msec(value/25); } else if(value>=130) { value=255-value; n=1;p=0; delay_msec(6-(value/25)); n=0;p=0; delay_msec(value/25); } value=read_ADC(); } } ###
Circuit Diagrams
Project Video
Filed Under: Electronic Projects
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.