SlideShare a Scribd company logo
1 of 24
Project Report
E 222: MicroProcessor Systems
Group Members:
Taimoor Tahir (4628)
Hassan Saeed (5718)
Hafiz Saad Abdul Majid (5223)
Submitted To: Ma’am Hira Taqdees
Date: 8 June 2015
Hardware Components.
 8052 Micro Controller.
 Pull up Resistors (10k*10Ω).
 Resistors (10kΩ).
 Oscillator.
 Numeric Keypad.
 LCD Display.
 Capacitors (104uF*2,10uF).
 DC Motor.
 L293D IC.
 ChipMAX.
 Potentiometer
 Breadboard*3
 Wire
 Trainer
Code:
Code:
#include<reg51.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
//Keypad Connections
sbit R1 = P0^0;
sbit R2 = P0^1;
sbit R3 = P0^2;
sbit R4 = P0^3;
sbit C1 = P0^4;
sbit C2 = P0^5;
sbit C3 = P0^6;
sbit C4 = P0^7;
//End Keypad Connections
//LCD Connections
sbit rs = P2^0; // declare P2.0 as rs pin
sbit en = P2^2; // declare p2.2 as enable pin
sbit rw = P2^1; // declare p2.1 as read/write pin
sbit b = P1^7; // busy flag port 1.7
//End Lcd Connections
//Outputs
sbit enable = P2^4;
sbit motor = P2^3;
//Outputs
float time = 0;
unsigned char count = 0;
unsigned int speed = 4;
unsigned int weight = 0;
float calories = 0;
void busy() // function to check LCD is busy or not
{
en = 0; // disable display
P1 = 0xFF; // configur P1 as input
rs = 0; // clear rs pin for command
rw = 1; // set rw pin to read
while(b==1)
{
en=0; // strob LCD till P1.7 is 1
en=1;
}
en=0;
}
void writecmd(unsigned char a) // function to send command to LCD
{
busy(); // check for LCD is busy or not
rs = 0; // clear rs pin for command
rw = 0; // clear rw pin to write
P1 = a; // send command character
en = 1; // strob LCD
en = 0;
}
void writedat(unsigned char b) // function to send data to LCD
{
busy(); // check for LCD is busy or not
rs = 1; // set rs pin for data
rw = 0; // clear rw pin to write
P1 = b; // send data character
en = 1; // strob LCD
en = 0;
}
void writestr(unsigned char *s) // function to write string on LCD
{
unsigned char l,i;
l = strlen(s); // get the length of string
for(i=1;i<=l;i++)
{
writedat(*s); // write every char one by one
s++;
}
}
void delay(unsigned int msec) //Function to provide time delay in msec.
{
unsigned int i,j;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}
char Read_Keypad()
{
C1=1;
C2=1;
C3=1;
C4=1;
R1=0;
R2=1;
R3=1;
R4=1;
if(C1==0){delay(50);while(C1==0);return '7';}
if(C2==0){delay(50);while(C2==0);return '8';}
if(C3==0){delay(50);while(C3==0);return '9';}
if(C4==0){delay(50);while(C4==0);return '/';}
R1=1;
R2=0;
R3=1;
R4=1;
if(C1==0){delay(50);while(C1==0);return '4';}
if(C2==0){delay(50);while(C2==0);return '5';}
if(C3==0){delay(50);while(C3==0);return '6';}
if(C4==0){delay(50);while(C4==0);return '*';}
R1=1;
R2=1;
R3=0;
R4=1;
if(C1==0){delay(50);while(C1==0);return '1';}
if(C2==0){delay(50);while(C2==0);return '2';}
if(C3==0){delay(50);while(C3==0);return '3';}
if(C4==0){delay(50);while(C4==0);return '-';}
R1=1;
R2=1;
R3=1;
R4=0;
if(C1==0){delay(50);while(C1==0);return 'C';}
if(C2==0){delay(50);while(C2==0);return '0';}
if(C3==0){delay(50);while(C3==0);return '=';}
if(C4==0){delay(50);while(C4==0);return '+';}
return 0;
}
void calculate()
{
calories = calories + ((0.0215 * speed * speed * speed - 0.1765 * speed * speed + 0.8710 *
speed + 1.4577) * weight * time);
}
void duration()
{
time = ((TH0*16*16 + TL0 + 65535*count)*1.085*0.000001)/3600;
}
void timer0() interrupt 1
{
count++;
}
void timer1() interrupt 3
{
motor =~ motor;
}
void main()
{
unsigned char c,s[8],p[3]={' '},i = 0;
speed = 4;
time = 0;
calories = 0;
count = 0;
P1=0x00; // P1 and P2 as output ports
P2=0x00;
IE = 0x8A;
writecmd(0x38); // initialize LCD
writecmd(0x0E);
writecmd(0x01); // clear memory and home cursor
writestr("**Treadmill**"); // write message in first line
writecmd(0xC0); // move cursor to second line
delay(200);
//Taking Gender input
writecmd(0x01);
writestr("Enter Gender:");
writecmd(0xC0);
writestr("Male 1,Female 0");
writecmd(0xCD);
while(!(c = Read_Keypad()));
while(1)
{
if(c == '1')
{
writecmd(0x01);
writestr("Gender:");
writecmd(0xC0);
writestr("Male");
writecmd(0xC5);
break;
}
else if(c == '0')
{
writecmd(0x01);
writestr("Gender:");
writecmd(0xC0);
writestr("Female");
writecmd(0xC7);
break;
}
c = Read_Keypad();
}
while(!(c = Read_Keypad()));
//Taking Weight input
writecmd(0x01);
writestr("Enter Weight:");
writecmd(0xC0);
writestr("Exit /,3-digit");
writecmd(0xCF);
while(!(c = Read_Keypad()));
writecmd(0x01);
while(1)
{
while(!(c = Read_Keypad()));
if(c == '/' || i == 3 )
{
writecmd(0x01);
writestr("Weight:");
writecmd(0xC0);
writestr(p);
writecmd(0xC5);
break;
}
else if(c == 'C' || c == '=' || c == '+' || c == '-' || c == '*')
{
continue;
}
writedat(c);
p[i] = c;
i++;
}
weight = atoi(p);
while(!(c = Read_Keypad()));
//Taking input to start
writecmd(0x01);
writestr("Press 1 to start:");
writecmd(0xC0);
while(!(c = Read_Keypad()));
while(1)
{
if(c == '1')
{
break;
}
c = Read_Keypad();
}
//Starting timer
TMOD = 0x11;
TL0 = 0;
TH0 = 0;
TR0 = 1;
TR1 = 1;
while(1)
{
if(speed <= 5)
{
TH1 = 0;
TL1 = 0;
}
else if(speed > 5 && speed <=10)
{
TH1 = 0x19;
TL1 = 0xCE;
}
else if(speed > 11 && speed <=15)
{
TH1 = 0x33;
TL1 = 0xDF;
}
else if(speed > 15 && speed <=20)
{
TH1 = 0x4C;
TL1 = 0xFF;
}
else if(speed > 20 && speed <=25)
{
TH1 = 0X6A;
TL1 = 0XFF;
}
else if(speed > 25 && speed <=30)
{
TH1 = 0x8F;
TL1 = 0xFD;
}
else if(speed > 30 && speed <=35)
{
TH1 = 0xAF;
TL1 = 0xFF;
}
else if(speed > 35 && speed <=40)
{
TH1 = 0xDF;
TL1 = 0xFD;
}
else
{
TR1 = 0;
motor = 0;
}
enable = 1;
writecmd(0x01);
writestr("Speed(km/h):");
writecmd(0xC0);
sprintf(s,"%d",speed);
writestr(s);
writecmd(0xC3);
while(!(c = Read_Keypad()));
writecmd(0x01);
writestr("Speed 1,Exit 2:");
writecmd(0xC0);
while (1)
{
c = Read_Keypad();
if(c == '1' || c =='2')
{
break;
}
}
if(c == '2')
{
break;
}
if(c == '1')
{
writecmd(0x01);
writestr("Enter Speed: ");
writecmd(0xC0);
writestr("Exit /,2-digit");
writecmd(0xCF);
while(!(c = Read_Keypad()));
writecmd(0x01);
i = 0;
p[0] = ' ';
p[1] = ' ';
p[2] = ' ';
while(1)
{
while(!(c = Read_Keypad()));
if(c == '/' || i == 2 )
{
break;
}
else if(c == 'C' || c == '=' || c == '+' || c == '-' || c == '*')
{
continue;
}
writedat(c);
p[i] = c;
i++;
}
duration();
calculate();
speed = atoi(p);
TL0 = 0;
TH0 = 0;
count = 0;
time = 0;
}
}
duration();
TR0 = 0;
TR1 = 0;
enable = 0;
calculate();
sprintf(s,"%f",calories);
writecmd(0x01);
writestr("Calories Burnt:");
writecmd(0xC0);
writestr(s);
writecmd(0xCA);
while(!(c = Read_Keypad()));
writecmd(0x01);
}
Proteus Results
Components
89C51 Micro Controller
LCD Display
L293D IC + DC Motor
Numeric Keypad
SimulationResults
1) Before simulation:
2) Main screen:
3) Genderoption:
4) Genderdisplay:
5) Weightinput:
6) Weightdisplay:
7) Waitingto start:
8) Runningat defaultspeed:
9) Inter-runningoption(itis available,wheneveruserisrunning):
10) Askingforuser’sinput(whenuserwantstochange the speed):
11) Runningat user’sinputtedspeed:
12) Displayingcalories,whenuserexits:
Software Used:
 Keil
 Proteus
 MaxLoader

More Related Content

What's hot

CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINOS Ayub
 
Micro Assignment 2
Micro Assignment 2Micro Assignment 2
Micro Assignment 2babak danyal
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorDaniel Roggen
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prognikhil dixit
 
Using ARM Dev.Board in physical experimental instruments
Using ARM Dev.Board in physical experimental instrumentsUsing ARM Dev.Board in physical experimental instruments
Using ARM Dev.Board in physical experimental instrumentsa_n0v
 
VHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESVHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESkarthik kadava
 
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)Omkar Rane
 
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23DefconRussia
 
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9Irfan Qadoos
 
Practical Differential Fault Attack on AES
Practical Differential Fault Attack on AESPractical Differential Fault Attack on AES
Practical Differential Fault Attack on AESRiscure
 
PWM based motor speed control using LPC 1768
PWM based motor speed control using LPC 1768PWM based motor speed control using LPC 1768
PWM based motor speed control using LPC 1768Omkar Rane
 
Temperature sensor with a led matrix display (arduino controlled)
Temperature sensor with a led matrix display (arduino controlled)Temperature sensor with a led matrix display (arduino controlled)
Temperature sensor with a led matrix display (arduino controlled)TechLeap
 
ADC (Analog to Digital conversion) using LPC 1768
ADC (Analog to Digital conversion) using LPC 1768ADC (Analog to Digital conversion) using LPC 1768
ADC (Analog to Digital conversion) using LPC 1768Omkar Rane
 
Micro Assignment 1
Micro Assignment 1Micro Assignment 1
Micro Assignment 1babak danyal
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuatorsEueung Mulyana
 
Connectivity for Local Sensors and Actuators Using nRF24L01+
Connectivity for Local Sensors and Actuators Using nRF24L01+Connectivity for Local Sensors and Actuators Using nRF24L01+
Connectivity for Local Sensors and Actuators Using nRF24L01+Eueung Mulyana
 
HSA Kernel Code (KFD v0.6)
HSA Kernel Code (KFD v0.6)HSA Kernel Code (KFD v0.6)
HSA Kernel Code (KFD v0.6)Hann Yu-Ju Huang
 

What's hot (20)

CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINO
 
Uart
UartUart
Uart
 
Micro Assignment 2
Micro Assignment 2Micro Assignment 2
Micro Assignment 2
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational Processor
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prog
 
FINISHED_CODE
FINISHED_CODEFINISHED_CODE
FINISHED_CODE
 
Using ARM Dev.Board in physical experimental instruments
Using ARM Dev.Board in physical experimental instrumentsUsing ARM Dev.Board in physical experimental instruments
Using ARM Dev.Board in physical experimental instruments
 
VHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESVHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLES
 
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)
 
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23
 
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
 
Practical Differential Fault Attack on AES
Practical Differential Fault Attack on AESPractical Differential Fault Attack on AES
Practical Differential Fault Attack on AES
 
PWM based motor speed control using LPC 1768
PWM based motor speed control using LPC 1768PWM based motor speed control using LPC 1768
PWM based motor speed control using LPC 1768
 
Temperature sensor with a led matrix display (arduino controlled)
Temperature sensor with a led matrix display (arduino controlled)Temperature sensor with a led matrix display (arduino controlled)
Temperature sensor with a led matrix display (arduino controlled)
 
گزارش کار
گزارش کارگزارش کار
گزارش کار
 
ADC (Analog to Digital conversion) using LPC 1768
ADC (Analog to Digital conversion) using LPC 1768ADC (Analog to Digital conversion) using LPC 1768
ADC (Analog to Digital conversion) using LPC 1768
 
Micro Assignment 1
Micro Assignment 1Micro Assignment 1
Micro Assignment 1
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuators
 
Connectivity for Local Sensors and Actuators Using nRF24L01+
Connectivity for Local Sensors and Actuators Using nRF24L01+Connectivity for Local Sensors and Actuators Using nRF24L01+
Connectivity for Local Sensors and Actuators Using nRF24L01+
 
HSA Kernel Code (KFD v0.6)
HSA Kernel Code (KFD v0.6)HSA Kernel Code (KFD v0.6)
HSA Kernel Code (KFD v0.6)
 

Viewers also liked

Microprocessor-Compatible Quadrature Decoder/Counter Design
Microprocessor-Compatible Quadrature Decoder/Counter DesignMicroprocessor-Compatible Quadrature Decoder/Counter Design
Microprocessor-Compatible Quadrature Decoder/Counter DesignRohit Singh
 
What is In side a Television Broadcasting Station
What is In side a Television Broadcasting StationWhat is In side a Television Broadcasting Station
What is In side a Television Broadcasting StationAnvar sha S
 
Final Report of Project A Low
Final Report of Project A LowFinal Report of Project A Low
Final Report of Project A LowJan Salomon
 
automation of street light using 8085 microprocessor
automation of street light using 8085 microprocessorautomation of street light using 8085 microprocessor
automation of street light using 8085 microprocessorshubham9929
 
Mini project-report
Mini project-reportMini project-report
Mini project-reportAshu0711
 
Laser ignition system (3) (1)
Laser ignition system (3) (1)Laser ignition system (3) (1)
Laser ignition system (3) (1)gajellitejas
 
Project report on gsm based borewell water level monitor
Project report on gsm based borewell water level monitorProject report on gsm based borewell water level monitor
Project report on gsm based borewell water level monitorTarun Arora
 
B.Tech Project Report
B.Tech Project ReportB.Tech Project Report
B.Tech Project ReportRohit Singh
 
seminar report on smart glasses
seminar report on smart glasses seminar report on smart glasses
seminar report on smart glasses Nipun Agrawal
 
Cach go tieng viet co dau tren HTKK
Cach go tieng viet co dau tren HTKKCach go tieng viet co dau tren HTKK
Cach go tieng viet co dau tren HTKKUnikey
 

Viewers also liked (13)

Microprocessor-Compatible Quadrature Decoder/Counter Design
Microprocessor-Compatible Quadrature Decoder/Counter DesignMicroprocessor-Compatible Quadrature Decoder/Counter Design
Microprocessor-Compatible Quadrature Decoder/Counter Design
 
What is In side a Television Broadcasting Station
What is In side a Television Broadcasting StationWhat is In side a Television Broadcasting Station
What is In side a Television Broadcasting Station
 
Final Report of Project A Low
Final Report of Project A LowFinal Report of Project A Low
Final Report of Project A Low
 
automation of street light using 8085 microprocessor
automation of street light using 8085 microprocessorautomation of street light using 8085 microprocessor
automation of street light using 8085 microprocessor
 
Mini project-report
Mini project-reportMini project-report
Mini project-report
 
Laser ignition system (3) (1)
Laser ignition system (3) (1)Laser ignition system (3) (1)
Laser ignition system (3) (1)
 
Project report on gsm based borewell water level monitor
Project report on gsm based borewell water level monitorProject report on gsm based borewell water level monitor
Project report on gsm based borewell water level monitor
 
B.Tech Project Report
B.Tech Project ReportB.Tech Project Report
B.Tech Project Report
 
seminar report on smart glasses
seminar report on smart glasses seminar report on smart glasses
seminar report on smart glasses
 
ENTRY TEST
ENTRY TESTENTRY TEST
ENTRY TEST
 
Doyal justin 3.3
Doyal justin 3.3Doyal justin 3.3
Doyal justin 3.3
 
Cach go tieng viet co dau tren HTKK
Cach go tieng viet co dau tren HTKKCach go tieng viet co dau tren HTKK
Cach go tieng viet co dau tren HTKK
 
Pantallazo mau
Pantallazo mauPantallazo mau
Pantallazo mau
 

Similar to REPORT

codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controllerSyed Ghufran Hassan
 
Senior design project code for PPG
Senior design project code for PPGSenior design project code for PPG
Senior design project code for PPGFrankDin1
 
New text document
New text documentNew text document
New text documentRoja Patro
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxSANTIAGO PABLO ALBERTO
 
Vechicle accident prevention using eye bilnk sensor ppt
Vechicle accident prevention using eye bilnk sensor pptVechicle accident prevention using eye bilnk sensor ppt
Vechicle accident prevention using eye bilnk sensor pptsatish 486
 
Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfforwardcom41
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdffootstatus
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver艾鍗科技
 
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docxajoy21
 
Udp socket programming(Florian)
Udp socket programming(Florian)Udp socket programming(Florian)
Udp socket programming(Florian)Flor Ian
 
m.tech esd lab manual for record
m.tech esd lab manual for recordm.tech esd lab manual for record
m.tech esd lab manual for recordG Lemuel George
 
Tai lieu ky thuat lap trinh
Tai lieu ky thuat lap trinhTai lieu ky thuat lap trinh
Tai lieu ky thuat lap trinhHồ Trường
 

Similar to REPORT (20)

codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controller
 
Senior design project code for PPG
Senior design project code for PPGSenior design project code for PPG
Senior design project code for PPG
 
New text document
New text documentNew text document
New text document
 
8051 -5
8051 -58051 -5
8051 -5
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
 
Vechicle accident prevention using eye bilnk sensor ppt
Vechicle accident prevention using eye bilnk sensor pptVechicle accident prevention using eye bilnk sensor ppt
Vechicle accident prevention using eye bilnk sensor ppt
 
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdf
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
 
C# Assignmet Help
C# Assignmet HelpC# Assignmet Help
C# Assignmet Help
 
Direct analog
Direct analogDirect analog
Direct analog
 
Udp socket programming(Florian)
Udp socket programming(Florian)Udp socket programming(Florian)
Udp socket programming(Florian)
 
Uart
UartUart
Uart
 
m.tech esd lab manual for record
m.tech esd lab manual for recordm.tech esd lab manual for record
m.tech esd lab manual for record
 
Tai lieu ky thuat lap trinh
Tai lieu ky thuat lap trinhTai lieu ky thuat lap trinh
Tai lieu ky thuat lap trinh
 
Lập trình C
Lập trình CLập trình C
Lập trình C
 
Basic standard calculator
Basic standard calculatorBasic standard calculator
Basic standard calculator
 

REPORT

  • 1. Project Report E 222: MicroProcessor Systems Group Members: Taimoor Tahir (4628) Hassan Saeed (5718) Hafiz Saad Abdul Majid (5223) Submitted To: Ma’am Hira Taqdees Date: 8 June 2015
  • 2. Hardware Components.  8052 Micro Controller.  Pull up Resistors (10k*10Ω).  Resistors (10kΩ).  Oscillator.  Numeric Keypad.  LCD Display.  Capacitors (104uF*2,10uF).  DC Motor.  L293D IC.  ChipMAX.  Potentiometer  Breadboard*3  Wire  Trainer Code: Code: #include<reg51.h> #include<stdio.h> #include<string.h> #include<stdlib.h> //Keypad Connections sbit R1 = P0^0; sbit R2 = P0^1; sbit R3 = P0^2; sbit R4 = P0^3; sbit C1 = P0^4; sbit C2 = P0^5; sbit C3 = P0^6;
  • 3. sbit C4 = P0^7; //End Keypad Connections //LCD Connections sbit rs = P2^0; // declare P2.0 as rs pin sbit en = P2^2; // declare p2.2 as enable pin sbit rw = P2^1; // declare p2.1 as read/write pin sbit b = P1^7; // busy flag port 1.7 //End Lcd Connections //Outputs sbit enable = P2^4; sbit motor = P2^3; //Outputs float time = 0; unsigned char count = 0; unsigned int speed = 4; unsigned int weight = 0; float calories = 0; void busy() // function to check LCD is busy or not { en = 0; // disable display P1 = 0xFF; // configur P1 as input rs = 0; // clear rs pin for command rw = 1; // set rw pin to read
  • 4. while(b==1) { en=0; // strob LCD till P1.7 is 1 en=1; } en=0; } void writecmd(unsigned char a) // function to send command to LCD { busy(); // check for LCD is busy or not rs = 0; // clear rs pin for command rw = 0; // clear rw pin to write P1 = a; // send command character en = 1; // strob LCD en = 0; } void writedat(unsigned char b) // function to send data to LCD { busy(); // check for LCD is busy or not rs = 1; // set rs pin for data rw = 0; // clear rw pin to write P1 = b; // send data character en = 1; // strob LCD en = 0; } void writestr(unsigned char *s) // function to write string on LCD {
  • 5. unsigned char l,i; l = strlen(s); // get the length of string for(i=1;i<=l;i++) { writedat(*s); // write every char one by one s++; } } void delay(unsigned int msec) //Function to provide time delay in msec. { unsigned int i,j; for(i=0;i<msec;i++) for(j=0;j<1275;j++); } char Read_Keypad() { C1=1; C2=1; C3=1; C4=1; R1=0; R2=1; R3=1; R4=1; if(C1==0){delay(50);while(C1==0);return '7';}
  • 6. if(C2==0){delay(50);while(C2==0);return '8';} if(C3==0){delay(50);while(C3==0);return '9';} if(C4==0){delay(50);while(C4==0);return '/';} R1=1; R2=0; R3=1; R4=1; if(C1==0){delay(50);while(C1==0);return '4';} if(C2==0){delay(50);while(C2==0);return '5';} if(C3==0){delay(50);while(C3==0);return '6';} if(C4==0){delay(50);while(C4==0);return '*';} R1=1; R2=1; R3=0; R4=1; if(C1==0){delay(50);while(C1==0);return '1';} if(C2==0){delay(50);while(C2==0);return '2';} if(C3==0){delay(50);while(C3==0);return '3';} if(C4==0){delay(50);while(C4==0);return '-';} R1=1; R2=1; R3=1; R4=0; if(C1==0){delay(50);while(C1==0);return 'C';} if(C2==0){delay(50);while(C2==0);return '0';} if(C3==0){delay(50);while(C3==0);return '=';} if(C4==0){delay(50);while(C4==0);return '+';}
  • 7. return 0; } void calculate() { calories = calories + ((0.0215 * speed * speed * speed - 0.1765 * speed * speed + 0.8710 * speed + 1.4577) * weight * time); } void duration() { time = ((TH0*16*16 + TL0 + 65535*count)*1.085*0.000001)/3600; } void timer0() interrupt 1 { count++; } void timer1() interrupt 3 { motor =~ motor; } void main() { unsigned char c,s[8],p[3]={' '},i = 0;
  • 8. speed = 4; time = 0; calories = 0; count = 0; P1=0x00; // P1 and P2 as output ports P2=0x00; IE = 0x8A; writecmd(0x38); // initialize LCD writecmd(0x0E); writecmd(0x01); // clear memory and home cursor writestr("**Treadmill**"); // write message in first line writecmd(0xC0); // move cursor to second line delay(200); //Taking Gender input writecmd(0x01); writestr("Enter Gender:"); writecmd(0xC0); writestr("Male 1,Female 0"); writecmd(0xCD); while(!(c = Read_Keypad())); while(1) { if(c == '1') { writecmd(0x01); writestr("Gender:");
  • 9. writecmd(0xC0); writestr("Male"); writecmd(0xC5); break; } else if(c == '0') { writecmd(0x01); writestr("Gender:"); writecmd(0xC0); writestr("Female"); writecmd(0xC7); break; } c = Read_Keypad(); } while(!(c = Read_Keypad())); //Taking Weight input writecmd(0x01); writestr("Enter Weight:"); writecmd(0xC0); writestr("Exit /,3-digit"); writecmd(0xCF); while(!(c = Read_Keypad())); writecmd(0x01);
  • 10. while(1) { while(!(c = Read_Keypad())); if(c == '/' || i == 3 ) { writecmd(0x01); writestr("Weight:"); writecmd(0xC0); writestr(p); writecmd(0xC5); break; } else if(c == 'C' || c == '=' || c == '+' || c == '-' || c == '*') { continue; } writedat(c); p[i] = c; i++; } weight = atoi(p); while(!(c = Read_Keypad())); //Taking input to start writecmd(0x01); writestr("Press 1 to start:");
  • 11. writecmd(0xC0); while(!(c = Read_Keypad())); while(1) { if(c == '1') { break; } c = Read_Keypad(); } //Starting timer TMOD = 0x11; TL0 = 0; TH0 = 0; TR0 = 1; TR1 = 1; while(1) { if(speed <= 5) { TH1 = 0; TL1 = 0; } else if(speed > 5 && speed <=10) { TH1 = 0x19;
  • 12. TL1 = 0xCE; } else if(speed > 11 && speed <=15) { TH1 = 0x33; TL1 = 0xDF; } else if(speed > 15 && speed <=20) { TH1 = 0x4C; TL1 = 0xFF; } else if(speed > 20 && speed <=25) { TH1 = 0X6A; TL1 = 0XFF; } else if(speed > 25 && speed <=30) { TH1 = 0x8F; TL1 = 0xFD; } else if(speed > 30 && speed <=35) { TH1 = 0xAF; TL1 = 0xFF; }
  • 13. else if(speed > 35 && speed <=40) { TH1 = 0xDF; TL1 = 0xFD; } else { TR1 = 0; motor = 0; } enable = 1; writecmd(0x01); writestr("Speed(km/h):"); writecmd(0xC0); sprintf(s,"%d",speed); writestr(s); writecmd(0xC3); while(!(c = Read_Keypad())); writecmd(0x01); writestr("Speed 1,Exit 2:"); writecmd(0xC0); while (1) { c = Read_Keypad(); if(c == '1' || c =='2') { break;
  • 14. } } if(c == '2') { break; } if(c == '1') { writecmd(0x01); writestr("Enter Speed: "); writecmd(0xC0); writestr("Exit /,2-digit"); writecmd(0xCF); while(!(c = Read_Keypad())); writecmd(0x01); i = 0; p[0] = ' '; p[1] = ' '; p[2] = ' '; while(1) { while(!(c = Read_Keypad())); if(c == '/' || i == 2 ) { break; }
  • 15. else if(c == 'C' || c == '=' || c == '+' || c == '-' || c == '*') { continue; } writedat(c); p[i] = c; i++; } duration(); calculate(); speed = atoi(p); TL0 = 0; TH0 = 0; count = 0; time = 0; } } duration(); TR0 = 0; TR1 = 0; enable = 0; calculate(); sprintf(s,"%f",calories); writecmd(0x01); writestr("Calories Burnt:"); writecmd(0xC0); writestr(s);
  • 17. LCD Display L293D IC + DC Motor
  • 19. 2) Main screen: 3) Genderoption:
  • 22. 8) Runningat defaultspeed: 9) Inter-runningoption(itis available,wheneveruserisrunning):
  • 23. 10) Askingforuser’sinput(whenuserwantstochange the speed): 11) Runningat user’sinputtedspeed: