SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Scientech Learning Center
project
I2C protocol of Serial programming using AT24c04
with AT89c251
Submitted To
Mr. AdityaDubey
Submitted By
Mr. SHUBHAM SHIVHARE
B.E. SEVENTH SEMESTER
ELECTRONICS & COMMUNICATION
ENG.
SAGARINSTITUTEOF RESEARCH AND
TECHNOLOGYEXCELENCE.
ACKNOWLEDGEMENT
I take this opportunity to express my deep sense of gratitude to all those who have contributed
significantly by sharing their knowledge and experience in the completion of this project and
greatly obliged to Mr. AdityaDubey for his step by step guidance throughout the project.
I am also thankful to Mr. BrejeshChoudhary, Mr. VijaykumarSatpute, Mr. ShivamYadavand all
the staff members for knowledge sharing and support during the training.
Mr. SHUBHAM SHIVHARE
CERTIFICATE
This is to certify that SHUBHAM SHIVHARE, B.E. Seventh Semester, SAGAR INSTITUTE OF
RESEARCH AND TECHNOLOGY EXCELLENCE BHOPAL. has completed his project regarding “I2C
protocol of serial communication using AT24c04 with AT89c51” in Scientech Learning Center,
Indore from 07/07/14 to 02/08/14.
During the project, his work was found satisfactorily and I wish him all the best for his future.
Mr. AdityaDubey
INTRODUCTION
Today, electronics is used in home appliances for wide purposes including the motor regulation
of a washing machine, the control of a vacuum cleaner, the light dimming of a lamp or the
heating in a coffee machine etc. This pervasion increases rapidly because appliances require
enhanced features, easy to build and modify as electronics based solutions become cheaper
and more sophisticated. Within this evolution, the microcontrollers (MCU) progressively
replace analog controllers and discrete solutions even in low cost applications.
They are more flexible, often need less components and provide faster time to market. With an
analog IC, the designer is limited to a fixed function frozen inside the device. Remote control
facilitates variety of operation around the home or office from a distance such as fan regulators
and mains power supply. It provides a system that is easy to understand and also to operate, a
system that would be cheap and affordable, reliable and easy to maintain the system of remote
control and offers long durability. It adds more comfort to everyday living by removing the
inconvenience of having to move around to operate a fan regulator.
AT89C2051 Microcontroller
The AT89C2051 is a low-voltage, high-performance CMOS 8-bit microcomputer with 2K bytes of
Flash programmable and erasable read-only memory (PEROM). The device is manufactured
using Atmel’s high-density nonvolatile memory technology and is compatible with the industry-
standard MCS-51 instruction set. By combining a versatile 8-bit CPU with Flash on a monolithic
chip, the Atmel AT89C2051 is a powerful microcomputer which provides a highly-flexible and
cost-effective solution to many embedded control applications.
1. Pin Configuration
2. Pin Description
1. VCC
Supply voltage.
2. GND
Ground.
3. Port 1
The Port 1 is an 8-bit bi-directional I/O port. Port pins P1.2 to P1.7 provide internal
pull-ups. P1.0 and P1.1 require external pull-ups. P1.0 and P1.1 also serve as the
positive input (AIN0) and the negative input (AIN1), respectively, of the on-chip
precision analog comparator. The Port 1 output buffers can sink 20 mA and can drive
LED displays directly. When 1s are written to Port 1 pins, they can be used as inputs.
When pins P1.2 to P1.7 are used as inputs and are externally pulled low, they will
source current because of the internal pull-ups.
4. Port 3
Port 3 pins P3.0 to P3.5, P3.7 are seven bi-directional I/O pins with internal pull-ups.
P3.6 is hard-wired as an input to the output of the on-chip comparator and is not
accessible as a general purpose I/O pin. The Port 3 output buffers can sink 20 mA.
When 1s are written to Port 3 pins they are pulled high by the internal pull-ups and
can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will
source current (IIL) because of the pull-ups.Port 3 also serves the functions of
various special features of the AT89C2051 as listed below:
Port Pin Alternate Functions
P3.0 RXD (serial input port)
P3.1 TXD (serial output port)
P3.2 INT0(external interrupt 0)
P3.3 INT1(external interrupt 1)
P3.4 T0 (timer 0 external input)
P3.5 T1 (timer 1 external input)
Port 3 also receives some control signals for Flash programming and verification.
5. RST
Reset input. All I/O pins are reset to 1s as soonas RST goes high. Holding the RST pin
high for two machine cycles while the oscillator is running resets the device. Each
machine cycle takes 12 oscillator or clock cycles.
6. XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
7. XTAL2
Output from the inverting oscillator amplifier.
3. Features
1. 2.7V to 6V Operating Range
2. Fully Static Operation: 0 Hz to 24 MHz
3. 128 x 8-bit Internal RAM
4. 15 Programmable I/O Lines
5. Two 16-bit Timer/Counters
6. Six Interrupt Sources
7. Direct LED Drive Outputs
I2c protocol
The I²C (Inter-Integrated Circuit) protocol, referred to as I-squared-C, I-two-C, or IIC) is two
wire serial communication protocol for connecting low speed peripherals to a micrcontroller or
computer motherboard.
A sample schematic with one master and three slaves
The I²C simply require only two wires for communication. One is called the Serial Data (SDA)
and the other is Serial Clock (SCL) as shown.
There are various modes and configurations in which it can be used. Let us start simply with a
single master and a single slave.
The Master generates the clock for serial communication(SCL). A stream of data bits(B1 to BN)
is transferred between the start and the stop bits.
I2C Timings and Conditions.
Figure below shows the timing diagram for I²C.
Fig: I2C data transfer
Start Condition(S)
As seen from the timing diagram, a data transfer is initiated with the Start(S) condition. The start
occurs when SCL is high and SDA goes from high to low.
Data bits transfer(B1...Bn)
A bit is transmitted at every high level of the clock (SCL) after the start condition. As shown in
the image bits B1 to Bn are transmitted at high level of every successive clock cycles.
Stop bit (P)
To stop the data transfer, the clock(SCL) is held high, while data(SDA) goes from low to high.
Interfacing Microcontroller to I2C devices
Usually, following procedure is used to communicate with the peripherals.
 Master initializes the communication by sending the slave address on the bus.
 Master reads or writes data or commands from and to the slaves depending on the
interfaced devices.
Communication in I2C:
Figure 2 shows the communication in I2C.
The I2C signaling protocol provides device addressing, a read/write flag, and a simple
acknowledgement mechanism. Other elements of I2C protocol are general call (broadcast) and 10-bit
extended addressing. Standard I2C devices operate up to 100Kbps, while fast-mode devices operate
at up to 400Kbps. Most often, the I2C master is the CPU or microcontroller in the system. Some
microcontrollers even feature hardware to implement the I2C protocol. You can also build an all-
software implementation using a pair of general-purpose I/O pins. Since the I2C master controls
transaction timing, the bus protocol doesn't impose any real-time constraints on the CPU beyond
those of the application. For a fixed I2C, the high and low logics are defined at 3.0 V and 1.5 V. For
dependant I2C, these are defined at 0.7*Vdd and 0.3*Vdd respectively. The pull-up resistor values
required for I2C are typically at 1K for 3.0V of Vdd and 1.6K for 5V of Vdd. Typical operating
temperatures are between -40 degrees and +85 degrees Centigrade.
Addressing in I2C:
 Figure 3 shows the SDA and SCL for I2C
 Figure 3: I2C addressing
The following table shows I2C addresses
reserved for special purposes: 10 bit
addresses, binary noted, MSB is left
Purpose
0000000 0 General Call
0000000 1 Start Byte
0000001 X CBUS Addresses
0000010 X Reserved for Different Bus Formats
0000011 X Reserved for future purposes
00001XX X High-Speed Master Code
11110XX X 10-bit Slave Addressing
11111XX X Reserved for future purposes
Code for Programming
#include<reg51.h>
#include<intrins.h>
sbit sda=P1^0;
sbit scl=P1^1;
sbit led=P0^3;
bit ack;
sbit led1=P0^1;
sfr lcd_data_pin=0xA0;
sfr output=0x80;
sbit rs=P3^0;
sbit rw=P3^1;
sbit en=P3^6;
unsigned char read,write,write2,i,j;
unsigned int temp;
void delay(unsigned int count)
{
int i,j;
for(i=0;i<count;i++)
for(j=0;j<1275;j++);
}
void lcd_command(unsigned char comm)
{
lcd_data_pin=comm;
en=1;
rs=0;
rw=0;
delay(1);
en=0;
}
void lcd_data(unsigned char disp)
{
lcd_data_pin=disp;
en=1;
rs=1;
rw=0;
delay(1);
en=0;
}
lcd_dataa(unsigned char *disp)
{
int x;
for(x=0;disp[x]!=0;x++)
{
lcd_data(disp[x]);
}
}
void lcd_ini()
{
lcd_command(0x38);
delay(5);
lcd_command(0x0F);
delay(5);
lcd_command(0x80);
delay(5);
}
void aknowledge()
{
scl=1;
_nop_();
_nop_();
scl=0;
}
void start()
{
sda=1;
scl=1;
_nop_();
_nop_();
sda=0;
scl=0;
}
void stop()
{
sda=0;
scl=1;
_nop_();
_nop_();
sda=1;
scl=0;
}
void send_byte(unsigned char value)
{
unsigned int i;
unsigned char send;
send=value;
for(i=0;i<8;i++)
{
sda=send/128;
send=send<<1;
scl=1;
_nop_();
_nop_();
scl=0;
}
ack=sda;
sda=0;
}
unsigned char read_byte()
{
unsigned int i;
sda=1;
read=0;
for(i=0;i<8;i++)
{
read=read<<1;
scl=1;
_nop_();
_nop_();
if(sda==1)
read++;
scl=0;
}
sda=0;
return read;
}
void save()
{
start();
send_byte(0xA0);
acknowledge();
send_byte(0x00);
acknowledge();
send_byte(5);
acknowledge();
send_byte(65);
acknowledge();
stop();
if(ack==0)
{
led1=1;
delay(100);
led1=0;
delay(100);
lcd_command(0x86);
lcd_data('5');
lcd_command(0x87);
lcd_data('A');
}
else
led1=1;
acknowledge();
}
void Read()
{
start();
send_byte(0xA0);
acknowledge();
send_byte(0x00);
acknowledge();
start();
send_byte(0xA1);
acknowledge();
i=read_byte();
acknowledge();
j=read_byte();
acknowledge();
stop();
if(i==5)
{
led=0;
delay(100);
led=1;
delay(100);
write=i+48;
lcd_command(0xC6);
lcd_data(write);
}
else
led=1;
if(j==65)
{
lcd_command(0xC7);
lcd_data(j);
}
acknowledge();
}
void main()
{
lcd_ini();
lcd_dataa("Sent :");
lcd_command(0xC0);
lcd_dataa("Read :");
temp=0;
while(1)
{
save();
Read();
}
}

Weitere ähnliche Inhalte

Was ist angesagt?

4 bit lcd_interfacing_with_arm7_primer
4 bit lcd_interfacing_with_arm7_primer4 bit lcd_interfacing_with_arm7_primer
4 bit lcd_interfacing_with_arm7_primerpvmistary
 
7 segment led interfacing with 8051
7 segment led interfacing with 80517 segment led interfacing with 8051
7 segment led interfacing with 8051Sam Patel
 
DIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLERDIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLERChirag Lakhani
 
I2c interfacing raspberry pi to arduino
I2c interfacing raspberry pi to arduinoI2c interfacing raspberry pi to arduino
I2c interfacing raspberry pi to arduinoMike Ochtman
 
Embedded systems and its ports
Embedded systems and its portsEmbedded systems and its ports
Embedded systems and its portsnitin kumar
 
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...IOSR Journals
 
Digital clock presentation
Digital clock presentationDigital clock presentation
Digital clock presentationAditya Jha ✅
 
Auto dial-er Home security
Auto dial-er Home securityAuto dial-er Home security
Auto dial-er Home securityvaibhav jindal
 
Arm7 Interfacing examples
Arm7   Interfacing examples Arm7   Interfacing examples
Arm7 Interfacing examples Dr.YNM
 
Digital clock workshop
Digital clock workshopDigital clock workshop
Digital clock workshopKedarv
 

Was ist angesagt? (17)

Badal sharma
Badal sharmaBadal sharma
Badal sharma
 
4 bit lcd_interfacing_with_arm7_primer
4 bit lcd_interfacing_with_arm7_primer4 bit lcd_interfacing_with_arm7_primer
4 bit lcd_interfacing_with_arm7_primer
 
An hemmanur
An hemmanurAn hemmanur
An hemmanur
 
Ju2416921695
Ju2416921695Ju2416921695
Ju2416921695
 
7 segment led interfacing with 8051
7 segment led interfacing with 80517 segment led interfacing with 8051
7 segment led interfacing with 8051
 
DIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLERDIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLER
 
PIC Microcontrollers
PIC MicrocontrollersPIC Microcontrollers
PIC Microcontrollers
 
I2c interfacing raspberry pi to arduino
I2c interfacing raspberry pi to arduinoI2c interfacing raspberry pi to arduino
I2c interfacing raspberry pi to arduino
 
Embedded systems and its ports
Embedded systems and its portsEmbedded systems and its ports
Embedded systems and its ports
 
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
 
Project ppt
Project pptProject ppt
Project ppt
 
digital clock atmega16
digital clock atmega16digital clock atmega16
digital clock atmega16
 
Digital clock presentation
Digital clock presentationDigital clock presentation
Digital clock presentation
 
Auto dial-er Home security
Auto dial-er Home securityAuto dial-er Home security
Auto dial-er Home security
 
Arm7 Interfacing examples
Arm7   Interfacing examples Arm7   Interfacing examples
Arm7 Interfacing examples
 
Digital clock workshop
Digital clock workshopDigital clock workshop
Digital clock workshop
 
8 bit microcontroller
8 bit microcontroller8 bit microcontroller
8 bit microcontroller
 

Andere mochten auch

Dual axis tracker_final_report
Dual axis tracker_final_reportDual axis tracker_final_report
Dual axis tracker_final_reportSai Ram
 
Solar tracker
Solar trackerSolar tracker
Solar trackertonwen
 
Business plan yang menarik
Business plan yang menarikBusiness plan yang menarik
Business plan yang menarikNabil Basthomy
 
(Contoh) Bisnis Plan
(Contoh) Bisnis Plan(Contoh) Bisnis Plan
(Contoh) Bisnis PlanAs Faizin
 
lab manual (pata ni)
lab manual (pata ni)lab manual (pata ni)
lab manual (pata ni)shubham509
 
Contoh business plan
Contoh business planContoh business plan
Contoh business planUraura Ura
 
4 stroke petrol engine working principal
4 stroke petrol engine working principal 4 stroke petrol engine working principal
4 stroke petrol engine working principal Nur E Alam Siddike
 
Contoh Proposal usaha
Contoh Proposal usahaContoh Proposal usaha
Contoh Proposal usahaGaluh Musa
 
Contoh proposal-business-plan
Contoh proposal-business-planContoh proposal-business-plan
Contoh proposal-business-planNuaimi Mamla
 
PROPOSAL USAHA
PROPOSAL USAHAPROPOSAL USAHA
PROPOSAL USAHARinisutopo
 
2 stroke & 4 stroke engine
2 stroke & 4 stroke engine2 stroke & 4 stroke engine
2 stroke & 4 stroke engineHarshal Shah
 
ppt on 2 stroke and 4 stroke petrol engine
ppt on 2 stroke and 4 stroke petrol engineppt on 2 stroke and 4 stroke petrol engine
ppt on 2 stroke and 4 stroke petrol engineharshid panchal
 
FOUR STROKE ENGINE
FOUR STROKE ENGINEFOUR STROKE ENGINE
FOUR STROKE ENGINEshaffu786
 
Proposal Kewirausahaan Usaha "Tempat Pensil Flanel"
Proposal Kewirausahaan Usaha "Tempat Pensil Flanel"Proposal Kewirausahaan Usaha "Tempat Pensil Flanel"
Proposal Kewirausahaan Usaha "Tempat Pensil Flanel"Shofi Asriani
 

Andere mochten auch (20)

Ab45
Ab45Ab45
Ab45
 
Arduino Labs
Arduino LabsArduino Labs
Arduino Labs
 
The Internet of Things
The Internet of ThingsThe Internet of Things
The Internet of Things
 
solar tracker
solar trackersolar tracker
solar tracker
 
Dual axis tracker_final_report
Dual axis tracker_final_reportDual axis tracker_final_report
Dual axis tracker_final_report
 
Solar tracker
Solar trackerSolar tracker
Solar tracker
 
Business plan yang menarik
Business plan yang menarikBusiness plan yang menarik
Business plan yang menarik
 
(Contoh) Bisnis Plan
(Contoh) Bisnis Plan(Contoh) Bisnis Plan
(Contoh) Bisnis Plan
 
lab manual (pata ni)
lab manual (pata ni)lab manual (pata ni)
lab manual (pata ni)
 
Contoh business plan
Contoh business planContoh business plan
Contoh business plan
 
4 stroke petrol engine working principal
4 stroke petrol engine working principal 4 stroke petrol engine working principal
4 stroke petrol engine working principal
 
Contoh Proposal usaha
Contoh Proposal usahaContoh Proposal usaha
Contoh Proposal usaha
 
Solar tracker
Solar trackerSolar tracker
Solar tracker
 
Contoh proposal-business-plan
Contoh proposal-business-planContoh proposal-business-plan
Contoh proposal-business-plan
 
PROPOSAL USAHA
PROPOSAL USAHAPROPOSAL USAHA
PROPOSAL USAHA
 
2 stroke & 4 stroke engine
2 stroke & 4 stroke engine2 stroke & 4 stroke engine
2 stroke & 4 stroke engine
 
ppt on 2 stroke and 4 stroke petrol engine
ppt on 2 stroke and 4 stroke petrol engineppt on 2 stroke and 4 stroke petrol engine
ppt on 2 stroke and 4 stroke petrol engine
 
DUAL AXIS SOLAR TRACKER USING ARDUINO
DUAL AXIS SOLAR TRACKER USING ARDUINODUAL AXIS SOLAR TRACKER USING ARDUINO
DUAL AXIS SOLAR TRACKER USING ARDUINO
 
FOUR STROKE ENGINE
FOUR STROKE ENGINEFOUR STROKE ENGINE
FOUR STROKE ENGINE
 
Proposal Kewirausahaan Usaha "Tempat Pensil Flanel"
Proposal Kewirausahaan Usaha "Tempat Pensil Flanel"Proposal Kewirausahaan Usaha "Tempat Pensil Flanel"
Proposal Kewirausahaan Usaha "Tempat Pensil Flanel"
 

Ähnlich wie project 3 full report

Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and RoboticsNIT Raipur
 
Industrial training report of embedded system and robotics
Industrial training report of embedded system and roboticsIndustrial training report of embedded system and robotics
Industrial training report of embedded system and roboticsPallavi Bharti
 
IEEE Paper A SystemC AMS Model of an I2C Bus Controller
IEEE Paper A SystemC AMS Model  of an I2C Bus ControllerIEEE Paper A SystemC AMS Model  of an I2C Bus Controller
IEEE Paper A SystemC AMS Model of an I2C Bus ControllerDweapons Art
 
IRJET- IoT based Industrial Automation
IRJET-  	  IoT based Industrial AutomationIRJET-  	  IoT based Industrial Automation
IRJET- IoT based Industrial AutomationIRJET Journal
 
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C ProtocolInterfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C ProtocolIJERA Editor
 
An Implementation of I2C Slave Interface using Verilog HDL
An Implementation of I2C Slave Interface using Verilog HDLAn Implementation of I2C Slave Interface using Verilog HDL
An Implementation of I2C Slave Interface using Verilog HDLIJMER
 
Bluetooth based home appliances control
Bluetooth based home appliances controlBluetooth based home appliances control
Bluetooth based home appliances controlPROJECTRONICS
 
IRJET- Android based Home Automation System with Power Optimization Modes
IRJET-  	  Android based Home Automation System with Power Optimization ModesIRJET-  	  Android based Home Automation System with Power Optimization Modes
IRJET- Android based Home Automation System with Power Optimization ModesIRJET Journal
 
Contactless digital tachometer using microcontroller
Contactless digital tachometer using microcontroller Contactless digital tachometer using microcontroller
Contactless digital tachometer using microcontroller IJECEIAES
 
Coin based mobile charger project report
Coin based mobile charger project reportCoin based mobile charger project report
Coin based mobile charger project reportkaushal chaubey
 
Mobile robotic platform to gathering real time sensory data in wireless perso...
Mobile robotic platform to gathering real time sensory data in wireless perso...Mobile robotic platform to gathering real time sensory data in wireless perso...
Mobile robotic platform to gathering real time sensory data in wireless perso...Alexander Decker
 
INTERRUPT DRIVEN MULTIPLEXED 7 SEGMENT DIGITAL CLOCK
INTERRUPT DRIVEN MULTIPLEXED 7 SEGMENT DIGITAL CLOCKINTERRUPT DRIVEN MULTIPLEXED 7 SEGMENT DIGITAL CLOCK
INTERRUPT DRIVEN MULTIPLEXED 7 SEGMENT DIGITAL CLOCKSantanu Chatterjee
 

Ähnlich wie project 3 full report (20)

Smart home
Smart homeSmart home
Smart home
 
Smart home copy
Smart home   copySmart home   copy
Smart home copy
 
Smart home
Smart homeSmart home
Smart home
 
Final Presentation
Final PresentationFinal Presentation
Final Presentation
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and Robotics
 
Industrial training report of embedded system and robotics
Industrial training report of embedded system and roboticsIndustrial training report of embedded system and robotics
Industrial training report of embedded system and robotics
 
IEEE Paper A SystemC AMS Model of an I2C Bus Controller
IEEE Paper A SystemC AMS Model  of an I2C Bus ControllerIEEE Paper A SystemC AMS Model  of an I2C Bus Controller
IEEE Paper A SystemC AMS Model of an I2C Bus Controller
 
Home automation
Home automationHome automation
Home automation
 
IRJET- IoT based Industrial Automation
IRJET-  	  IoT based Industrial AutomationIRJET-  	  IoT based Industrial Automation
IRJET- IoT based Industrial Automation
 
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C ProtocolInterfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
 
5 FINAL PROJECT REPORT
5 FINAL PROJECT REPORT5 FINAL PROJECT REPORT
5 FINAL PROJECT REPORT
 
An Implementation of I2C Slave Interface using Verilog HDL
An Implementation of I2C Slave Interface using Verilog HDLAn Implementation of I2C Slave Interface using Verilog HDL
An Implementation of I2C Slave Interface using Verilog HDL
 
Bluetooth based home appliances control
Bluetooth based home appliances controlBluetooth based home appliances control
Bluetooth based home appliances control
 
IRJET- Android based Home Automation System with Power Optimization Modes
IRJET-  	  Android based Home Automation System with Power Optimization ModesIRJET-  	  Android based Home Automation System with Power Optimization Modes
IRJET- Android based Home Automation System with Power Optimization Modes
 
Contactless digital tachometer using microcontroller
Contactless digital tachometer using microcontroller Contactless digital tachometer using microcontroller
Contactless digital tachometer using microcontroller
 
embedded system
embedded systemembedded system
embedded system
 
Coin based mobile charger project report
Coin based mobile charger project reportCoin based mobile charger project report
Coin based mobile charger project report
 
Mobile robotic platform to gathering real time sensory data in wireless perso...
Mobile robotic platform to gathering real time sensory data in wireless perso...Mobile robotic platform to gathering real time sensory data in wireless perso...
Mobile robotic platform to gathering real time sensory data in wireless perso...
 
INTERRUPT DRIVEN MULTIPLEXED 7 SEGMENT DIGITAL CLOCK
INTERRUPT DRIVEN MULTIPLEXED 7 SEGMENT DIGITAL CLOCKINTERRUPT DRIVEN MULTIPLEXED 7 SEGMENT DIGITAL CLOCK
INTERRUPT DRIVEN MULTIPLEXED 7 SEGMENT DIGITAL CLOCK
 
Bidirect visitor counter
Bidirect visitor counterBidirect visitor counter
Bidirect visitor counter
 

project 3 full report

  • 1. Scientech Learning Center project I2C protocol of Serial programming using AT24c04 with AT89c251 Submitted To Mr. AdityaDubey Submitted By Mr. SHUBHAM SHIVHARE B.E. SEVENTH SEMESTER ELECTRONICS & COMMUNICATION ENG. SAGARINSTITUTEOF RESEARCH AND TECHNOLOGYEXCELENCE.
  • 2. ACKNOWLEDGEMENT I take this opportunity to express my deep sense of gratitude to all those who have contributed significantly by sharing their knowledge and experience in the completion of this project and greatly obliged to Mr. AdityaDubey for his step by step guidance throughout the project. I am also thankful to Mr. BrejeshChoudhary, Mr. VijaykumarSatpute, Mr. ShivamYadavand all the staff members for knowledge sharing and support during the training. Mr. SHUBHAM SHIVHARE
  • 3. CERTIFICATE This is to certify that SHUBHAM SHIVHARE, B.E. Seventh Semester, SAGAR INSTITUTE OF RESEARCH AND TECHNOLOGY EXCELLENCE BHOPAL. has completed his project regarding “I2C protocol of serial communication using AT24c04 with AT89c51” in Scientech Learning Center, Indore from 07/07/14 to 02/08/14. During the project, his work was found satisfactorily and I wish him all the best for his future. Mr. AdityaDubey
  • 4. INTRODUCTION Today, electronics is used in home appliances for wide purposes including the motor regulation of a washing machine, the control of a vacuum cleaner, the light dimming of a lamp or the heating in a coffee machine etc. This pervasion increases rapidly because appliances require enhanced features, easy to build and modify as electronics based solutions become cheaper and more sophisticated. Within this evolution, the microcontrollers (MCU) progressively replace analog controllers and discrete solutions even in low cost applications. They are more flexible, often need less components and provide faster time to market. With an analog IC, the designer is limited to a fixed function frozen inside the device. Remote control facilitates variety of operation around the home or office from a distance such as fan regulators and mains power supply. It provides a system that is easy to understand and also to operate, a system that would be cheap and affordable, reliable and easy to maintain the system of remote control and offers long durability. It adds more comfort to everyday living by removing the inconvenience of having to move around to operate a fan regulator.
  • 5. AT89C2051 Microcontroller The AT89C2051 is a low-voltage, high-performance CMOS 8-bit microcomputer with 2K bytes of Flash programmable and erasable read-only memory (PEROM). The device is manufactured using Atmel’s high-density nonvolatile memory technology and is compatible with the industry- standard MCS-51 instruction set. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C2051 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications. 1. Pin Configuration 2. Pin Description 1. VCC Supply voltage. 2. GND Ground. 3. Port 1 The Port 1 is an 8-bit bi-directional I/O port. Port pins P1.2 to P1.7 provide internal pull-ups. P1.0 and P1.1 require external pull-ups. P1.0 and P1.1 also serve as the positive input (AIN0) and the negative input (AIN1), respectively, of the on-chip precision analog comparator. The Port 1 output buffers can sink 20 mA and can drive LED displays directly. When 1s are written to Port 1 pins, they can be used as inputs. When pins P1.2 to P1.7 are used as inputs and are externally pulled low, they will source current because of the internal pull-ups. 4. Port 3 Port 3 pins P3.0 to P3.5, P3.7 are seven bi-directional I/O pins with internal pull-ups. P3.6 is hard-wired as an input to the output of the on-chip comparator and is not accessible as a general purpose I/O pin. The Port 3 output buffers can sink 20 mA.
  • 6. When 1s are written to Port 3 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups.Port 3 also serves the functions of various special features of the AT89C2051 as listed below: Port Pin Alternate Functions P3.0 RXD (serial input port) P3.1 TXD (serial output port) P3.2 INT0(external interrupt 0) P3.3 INT1(external interrupt 1) P3.4 T0 (timer 0 external input) P3.5 T1 (timer 1 external input) Port 3 also receives some control signals for Flash programming and verification. 5. RST Reset input. All I/O pins are reset to 1s as soonas RST goes high. Holding the RST pin high for two machine cycles while the oscillator is running resets the device. Each machine cycle takes 12 oscillator or clock cycles. 6. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. 7. XTAL2 Output from the inverting oscillator amplifier. 3. Features 1. 2.7V to 6V Operating Range 2. Fully Static Operation: 0 Hz to 24 MHz 3. 128 x 8-bit Internal RAM 4. 15 Programmable I/O Lines 5. Two 16-bit Timer/Counters 6. Six Interrupt Sources 7. Direct LED Drive Outputs
  • 7. I2c protocol The I²C (Inter-Integrated Circuit) protocol, referred to as I-squared-C, I-two-C, or IIC) is two wire serial communication protocol for connecting low speed peripherals to a micrcontroller or computer motherboard. A sample schematic with one master and three slaves The I²C simply require only two wires for communication. One is called the Serial Data (SDA) and the other is Serial Clock (SCL) as shown. There are various modes and configurations in which it can be used. Let us start simply with a single master and a single slave. The Master generates the clock for serial communication(SCL). A stream of data bits(B1 to BN) is transferred between the start and the stop bits. I2C Timings and Conditions. Figure below shows the timing diagram for I²C. Fig: I2C data transfer Start Condition(S) As seen from the timing diagram, a data transfer is initiated with the Start(S) condition. The start occurs when SCL is high and SDA goes from high to low.
  • 8. Data bits transfer(B1...Bn) A bit is transmitted at every high level of the clock (SCL) after the start condition. As shown in the image bits B1 to Bn are transmitted at high level of every successive clock cycles. Stop bit (P) To stop the data transfer, the clock(SCL) is held high, while data(SDA) goes from low to high. Interfacing Microcontroller to I2C devices Usually, following procedure is used to communicate with the peripherals.  Master initializes the communication by sending the slave address on the bus.  Master reads or writes data or commands from and to the slaves depending on the interfaced devices. Communication in I2C: Figure 2 shows the communication in I2C. The I2C signaling protocol provides device addressing, a read/write flag, and a simple acknowledgement mechanism. Other elements of I2C protocol are general call (broadcast) and 10-bit extended addressing. Standard I2C devices operate up to 100Kbps, while fast-mode devices operate at up to 400Kbps. Most often, the I2C master is the CPU or microcontroller in the system. Some microcontrollers even feature hardware to implement the I2C protocol. You can also build an all- software implementation using a pair of general-purpose I/O pins. Since the I2C master controls transaction timing, the bus protocol doesn't impose any real-time constraints on the CPU beyond those of the application. For a fixed I2C, the high and low logics are defined at 3.0 V and 1.5 V. For dependant I2C, these are defined at 0.7*Vdd and 0.3*Vdd respectively. The pull-up resistor values required for I2C are typically at 1K for 3.0V of Vdd and 1.6K for 5V of Vdd. Typical operating temperatures are between -40 degrees and +85 degrees Centigrade.
  • 9. Addressing in I2C:  Figure 3 shows the SDA and SCL for I2C  Figure 3: I2C addressing The following table shows I2C addresses reserved for special purposes: 10 bit addresses, binary noted, MSB is left Purpose 0000000 0 General Call 0000000 1 Start Byte 0000001 X CBUS Addresses 0000010 X Reserved for Different Bus Formats 0000011 X Reserved for future purposes 00001XX X High-Speed Master Code 11110XX X 10-bit Slave Addressing 11111XX X Reserved for future purposes
  • 10. Code for Programming #include<reg51.h> #include<intrins.h> sbit sda=P1^0; sbit scl=P1^1; sbit led=P0^3; bit ack; sbit led1=P0^1; sfr lcd_data_pin=0xA0; sfr output=0x80; sbit rs=P3^0; sbit rw=P3^1; sbit en=P3^6; unsigned char read,write,write2,i,j; unsigned int temp; void delay(unsigned int count) { int i,j; for(i=0;i<count;i++) for(j=0;j<1275;j++); } void lcd_command(unsigned char comm) { lcd_data_pin=comm; en=1;
  • 11. rs=0; rw=0; delay(1); en=0; } void lcd_data(unsigned char disp) { lcd_data_pin=disp; en=1; rs=1; rw=0; delay(1); en=0; } lcd_dataa(unsigned char *disp) { int x; for(x=0;disp[x]!=0;x++) { lcd_data(disp[x]); } } void lcd_ini() { lcd_command(0x38); delay(5); lcd_command(0x0F);
  • 13. scl=0; } void send_byte(unsigned char value) { unsigned int i; unsigned char send; send=value; for(i=0;i<8;i++) { sda=send/128; send=send<<1; scl=1; _nop_(); _nop_(); scl=0; } ack=sda; sda=0; } unsigned char read_byte() { unsigned int i; sda=1; read=0; for(i=0;i<8;i++) { read=read<<1;