MCA Unit 4

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 55

Department of Electronics and

Telecommunications

8051 Microcontroller based


Real World Interfacing and
Programming – II
(Unit IV)
Instructor
Dr. Yogesh H. Dandawate , Prof. Pravin G.Gawande and
Prof.Rahul S.Pol
Department of Electronics and Telecommunications (C005)
Vishwakarma Institute of Information Technology,Pune
Email : yogesh.dandawate@viit.ac.in

Unit-IV-8051 based Real world Interfacing and


1
Programming Part II
Unit IV :
Department of Electronics
8051 Microcontroller based and Telecommunications
Real World Interfacing and programming – II
• Basics of serial communication protocol: Synchronous
and Asynchronous Communication, RS232, RS485, SPI,
I2C.
• Interfacing of devices using protocols: Interfacing of
peripherals using UART Interfacing RTC DS1307using
I2C protocol, Interfacing of memory using SPI protocol.
programs in C.

Unit-IV-8051 based Real world Interfacing and


2
Programming Part II
Department of Electronics

Basics of Serial and Telecommunications

Communication
• Serial Vs Parallel data transfer.
• Simplex, Half and full duplex transmission
• Synchronous serial communication.
• Asynchronous serial communication
• Concept of Framing
• Baud rate

Unit-IV-8051 based Real world Interfacing and


3
Programming Part II
Department of Electronics and
Telecommunications

RS -232
Standard

Unit-IV-8051 based Real world Interfacing and


4
Programming Part II
Department of Electronics
and Telecommunications

Why Standards ?
• To allow compatibility among various data
communication equipment's made by different
manufacturers.

• What is RS ?
RS is Recommended Standard.
Set by Electronics Industries Association (EIA) in 1960.

Unit-IV-8051 based Real world Interfacing and


5
Programming Part II
Department of Electronics
and Telecommunications

RS 232
• Widely used Serial I/O interfacing standard.
• RS 232 A -1963
• RS 232 B – 1965
• RS 232 C – 1969
• Logic 1 is represented as -3V to -25 V
• Logic 0 is represented as + 3 V to +25V.
• Typically -9V and + 9V.
• Distance upto 50 feet.
• Speed upto 20K baud.
Unit-IV-8051 based Real world Interfacing and
6
Programming Part II
Department of Electronics
and Telecommunications

RS 232 Configuration
RS 232 Cable

1488 1489
DTE DCE
Data Data
Terminal Communication
Equipment 1489 1488 Equipment

GND TxD , RxD connections ?


1488 – Line Drivers and 1489 – Line Recievers

Unit-IV-8051 based Real world Interfacing and


7
Programming Part II
Department of Electronics

Connectors ( D type – 9 Pin)


and Telecommunications

Courtesy
Unit-IV-8051 based Real :http://en.wikipedia.org/wiki/RS-232
world Interfacing and
8
Programming Part II
Department of Electronics
and Telecommunications

Courtesy : http://www.arcelect.com/rs232.htm
Unit-IV-8051 based Real world Interfacing and
9
Programming Part II
Department of Electronics
and Telecommunications

Signals
• Transmitted Data (TxD)
• Data sent from DTE to DCE.
• Received Data (RxD)
• Data sent from DCE to DTE.
• Request To Send (RTS)
• Asserted (set to 0) by DTE to prepare DCE to receive data. This
may require action on the part of the DCE, e.g. transmitting a
carrier or reversing the direction of a half-duplex channel.

Unit-IV-8051 based Real world Interfacing and


10
Programming Part II
Department of Electronics
and Telecommunications

• Ready To Receive (RTR)


• Asserted by DTE to indicate to DCE that DTE is ready to receive
data.
• Clear To Send (CTS)
• Asserted by DCE to acknowledge RTS and allow DTE to
transmit.
• Data Terminal Ready (DTR)
• Asserted by DTE to indicate that it is ready to be connected. If
the DCE is a modem, this may "wake up" the modem, bringing it
out of a power saving mode

Unit-IV-8051 based Real world Interfacing and


11
Programming Part II
Department of Electronics
and Telecommunications

• Data Set Ready (DSR)


• Asserted by DCE to indicate the DCE is powered on and is ready
to receive commands or data for transmission from the DTE.
• Data Carrier Detect (DCD)
• Asserted by DCE when a connection has been established with
remote equipment.
• Ring Indicator (RI)
• Asserted by DCE when it detects a ring signal from the
telephone line.
H.W : 25 pin Connector http://www.arcelect.com/rs232.htm
Serial Port Complete by Alexson
Unit-IV-8051 based Real world Interfacing and
12
Programming Part II
Department of Electronics

Communication between Computer and and Telecommunications

Modem
• DTR by DTE
• DSR by DCE
• RTS by DTE
• CTS by DCE
• DCD
• RI

What is NULL Modem ?

Unit-IV-8051 based Real world Interfacing and


13
Programming Part II
Department of Electronics
and Telecommunications

MAX 232
• Operate from Single +5V Power Supply
• (+5V and +12V—MAX231/MAX239)
• Low-Power Receive Mode in Shutdown
• Meet All EIA/TIA-232E and V.28 Specifications
• Multiple Drivers and Receivers (Two)

Unit-IV-8051 based Real world Interfacing and


14
Programming Part II
Department of Electronics
and Telecommunications

Applications
• Portable Computers
• Low-Power Modems
• Interface Translation
• Battery-Powered RS-232 Systems
• Multidrop RS-232 Networks

Unit-IV-8051 based Real world Interfacing and


15
Programming Part II
Department of Electronics
and Telecommunications

H.W. Interfacing with 8051 / 8951/PIC/AVR


Unit-IV-8051 based Real world Interfacing and
16
Programming Part II
RS 485

Unit-IV-8051 based Real world Interfacing and


17
Programming Part II
Department of Electronics
and Telecommunications

Introduction
• Very much common in data acquisition.
• It is also called as EIA 485.
• RS485 supports 32 drivers and 32 receivers .
• Differential Voltage transmission mode.
• Distance 4000 Feet.
• Maximum data rate 10 Mbps.
• It’s a typical half duplex,2 wire multidrop system. 4 wire
with full duplex is also possible.

Unit-IV-8051 based Real world Interfacing and


18
Programming Part II
Department of Electronics
and Telecommunications

• Maximum driver output voltage is -7V to +12V.


• While selecting the cable characteristic impedence,shunt
capacitance (pFFt), propogation velocity (% of c) is taken into
consideration.
• Plenum cable which is fire resistance, less toxic ,but little costly due
to sheathing material used is recommended. Twisting is also used.

Unit-IV-8051 based Real world Interfacing and


19
Programming Part II
Department of Electronics
and Telecommunications

Network Topology.

Unit-IV-8051 based Real world Interfacing and


20
Programming Part II
Department of Electronics
and Telecommunications

Unit-IV-8051 based Real world Interfacing and


21
Programming Part II
Comparison of RS232 & RS 485
SPECIFICATIONS RS 232 RS 485
Mode of Operation SINGLE DIFFERENTIAL
-ENDED
Total Number of Drivers and Receivers on One Line 1 DRIVER 32 DRIVER
1 RECVR 32 RECVR
Maximum Cable Length 50 FT. 4000 FT.

Maximum Data Rate (40ft. - 4000ft). 20kb/s 10Mb/s-100Kb/s

Maximum Driver Output Voltage +/-25V -7V to +12V

Receiver Input Resistance (Ohms 3k to 7k >=12k

Receiver Input Sensitivity +/-3V +/-200mV


Unit-IV-8051 based Real world Interfacing and
22
Programming Part II
Department of Electronics
and Telecommunications

I C
2
Bus
Unit-IV-8051 based Real world Interfacing and
23
Programming Part II
Department of Electronics
and Telecommunications

What is I2C ?
• Developed by Philips Semiconductors in early 1980 for
providing a simple way to talk between IC’s by using a
minimum number of pins.

• It’s a Inter-Integrated Circuit Bus.

• It’s a simple bi-directional 2-wire bus for efficient inter-IC


control. No specific wiring or connectors but just PCB
tracks. (It’s a two wire serial interface)

Unit-IV-8051 based Real world Interfacing and


24
Programming Part II
Department of Electronics
and Telecommunications

I2C Continued…
• Since a serial Interface it reduces cost of manufacturing
of electronic product.

• Has become a recognized standard throughout our


industry and is used now by ALL major IC
manufacturers.

Unit-IV-8051 based Real world Interfacing and


25
Programming Part II
Department of Electronics
and Telecommunications

I2C Features
• Only two bus lines are required: a serial data line (SDA) and a
serial clock line (SCL).

• Each device connected to the bus is software addressable by


a unique address and simple master/slave relationships exist
at all times; masters can operate as master-transmitters or as
master-receivers.

• It’s a true multi-master bus including collision detection and


arbitration to prevent data corruption if two or more masters
simultaneously initiate data transfer.

Unit-IV-8051 based Real world Interfacing and


26
Programming Part II
Department of Electronics
and Telecommunications

I2C Features Contd…


• Serial, 8-bit oriented, bi-directional data transfers can be
made at up to 100 kbit/s in the Standard-mode, up to 400
kbit/s in the Fast-mode, or up to 3.4 Mbit/s in the High-
speed mode.

• On-chip filtering (50 ns) rejects spikes on the bus data line to
preserve data integrity.

• The number of ICs that can be connected to the same bus


segment is limited only by the maximum bus capacitive
loading of 400 pF.

Unit-IV-8051 based Real world Interfacing and


27
Programming Part II
Department of Electronics
and Telecommunications

Basic I2C arrangement

Unit-IV-8051 based Real world Interfacing and


28
Programming Part II
Department of Electronics

I2C Communication and Telecommunications

Procedure
One IC that wants to talk to another must: (Protocol)
1) Wait until it sees no activity on the I2C bus. SDA and
SCL are both high. The bus is 'free'.

2) Put a message on the bus that says 'its mine' - I have


STARTED to use the bus. All other ICs then LISTEN to
the bus data to see whether they might be the one who
will be called up (addressed).

Unit-IV-8051 based Real world Interfacing and


29
Programming Part II
Department of Electronics
and Telecommunications
Communication Contd..
3) Provide on the CLOCK (SCL) wire a clock signal. It will be used by
all the ICs as the reference time at which each bit of DATA on the
data (SDA) wire will be correct (valid) and can be used. The data on
the data wire (SDA) must be valid at the time the clock wire (SCL)
switches from 'low' to 'high' voltage.

4) Put out in serial form the unique binary 'address' (name) of the IC
that it wants to communicate with.

5) Put a message (one bit) on the bus telling whether it wants to


SEND or RECEIVE data from the other chip. (The read/write wire
is gone!)

Unit-IV-8051 based Real world Interfacing and


30
Programming Part II
Department of Electronics
and Telecommunications

Communication Contd..
6) Ask the other IC to ACKNOWLEDGE (using one bit) that it recognized its
address and is ready to communicate.

7) After the other IC acknowledges all is OK, data can be transferred.

8) The first IC sends or receives as many 8-bit words of data as it wants. After
every 8-bit data word the sending IC expects the receiving IC to acknowledge the
transfer is going OK.

9) When all the data is finished the first chip must free up the bus and it does
that by a special message called 'STOP'. It is just one bit of information
transferred by a special 'wiggling' of the SDA/SCL wires of the bus.

Unit-IV-8051 based Real world Interfacing and


31
Programming Part II
Unit-IV-8051 based Real world Interfacing and
32
Programming Part II
Start and Stop Conditions
Unit-IV-8051 based Real world Interfacing and
33
Programming Part II
Unit-IV-8051 based Real world Interfacing and
34
Programming Part II
Department of Electronics
and Telecommunications

I2C Benefits
• Well known bus, over 20 years of existence, has become world
standard.

• Standard adopted by industries like telecom, networking,


consumer, automotive etc.

• Used in many applications like cellphones, PDA’s, DVD, set


top boxes etc.
• Designed to stay in market for several years.

• Used by giants like HP, Compaq, IBM,Cisco,Intel,Nokia etc.

Unit-IV-8051 based Real world Interfacing and


35
Programming Part II
Department of Electronics
and Telecommunications

Benefits contd…
• Functional blocks on the block diagram correspond with the actual
ICs; designs proceed rapidly from block diagram to final schematic.

• No need to design bus interfaces because the I2C bus interface is


already integrated on-chip.

• Integrated addressing and data-transfer protocol allow systems to


be completely software-defined.

• The same IC types can often be used in many different


applications.

Unit-IV-8051 based Real world Interfacing and


36
Programming Part II
Department of Electronics
and Telecommunications

Benefits contd…
• Design-time reduces as designers quickly become familiar with
the frequently used functional blocks represented by I2C bus
compatible ICs.

• ICs can be added to or removed from a system without affecting


any other circuits on the bus.

• Fault diagnosis and debugging are simple; malfunctions can be


immediately traced.

• Assembling a library of reusable software modules can reduce


software development time.

Unit-IV-8051 based Real world Interfacing and


37
Programming Part II
Department of Electronics

I2C manufactures and Telecommunications

benefits
• The simple 2-wire serial I2C bus minimizes interconnections
so ICs have fewer pins and there are not so many PCB tracks;
result - smaller and less expensive PCBs

• The completely integrated I2C bus protocol eliminates the


need for address decoders and other ‘glue logic’

• The multi-master capability of the I2C bus allows rapid


testing/alignment of end-user equipment via external
connections to an assembly-line
Unit-IV-8051 based Real world Interfacing and
38
Programming Part II
Department of Electronics

Manufactures benefits and Telecommunications

Contd..
• Increases system design flexibility by allowing simple
construction of equipment variants and easy upgrading to
keep design up-to-date

• I2C bus is a de facto world standard that is implemented


in over 1000 different ICs (Philips has > 400) and licensed
to more than 70 companies

Unit-IV-8051 based Real world Interfacing and


39
Programming Part II
Department of Electronics

PCF 8591 and Telecommunications

(8-bit A/D and D/A converter)


• Features
• Single power supply
• Operating supply voltage 2.5 V to 6 V
• Low standby current
• Serial input/output via I2C-bus
• Address by 3 hardware address pins
• Sampling rate given by I2C-bus speed
• 4 analog inputs programmable as single-ended or
differential inputs

Unit-IV-8051 based Real world Interfacing and


40
Programming Part II
Department of Electronics
and Telecommunications

• Auto-incremented channel selection


• Analog voltage range from VSS to VDD
• On-chip track and hold circuit
• 8-bit successive approximation A/D conversion
• Multiplying DAC with one analog output.

Unit-IV-8051 based Real world Interfacing and


41
Programming Part II
Department of Electronics
and Telecommunications

Applications
• Closed loop control systems
• Low power converter for remote data acquisition
• Battery operated equipment
• Acquisition of analog values in automotive, audio and TV
applications.

Unit-IV-8051 based Real world Interfacing and


42
Programming Part II
Department of Electronics
and Telecommunications

Block Diagram

Unit-IV-8051 based Real world Interfacing and


43
Programming Part II
Department of Electronics
and Telecommunications

Pin Diagram and Address byte

Unit-IV-8051 based Real world Interfacing and


44
Programming Part II
Department of Electronics
and Telecommunications

Control byte
Unit-IV-8051 based Real world Interfacing and
45
Programming Part II
SERIAL PERIPHERAL INTERFACE
(SPI)

Unit-IV-8051 based Real world Interfacing and


46
Programming Part II
Department of Electronics
and Telecommunications

What it is ?
• It’s a Synchronous Serial Bus Standard.
• Developed by Motorola and Supported by various
microprocessor and controller manufacturers.
• Devices communicate using Master / Slave relationship
in which master initiates the data frame.
• Data is transferred in both directions.
• Speed between 1-3 Mbps and 8 bit data is transferred.

Unit-IV-8051 based Real world Interfacing and


47
Programming Part II
Department of Electronics
and Telecommunications

SCLK

MOSI
Master MISO Slave

SS

• MISO = Master In Slave Out


• MOSI = Master Out Slave In
• SS = Slave Select

Unit-IV-8051 based Real world Interfacing and


48
Programming Part II
Department of Electronics
and Telecommunications

Contd..
• It is up to the Master and Slave devices to know whether a
received byte is meaningful or not.
• Drawbacks :
• This do not have acknowledge mechanism.
• No flow control.
• It is suitable whenever only raw data are exchanged.
• Will be trouble some with more no.of slaves.
• Motorola , PIC, AVR supports SPI.
• H.W Comparison of I2C and SPI.
Unit-IV-8051 based Real world Interfacing and
49
Programming Part II
Department of Electronics
and Telecommunications

DS 1306 RTC
• Features
• Real-Time Clock (RTC) Counts Seconds, Minutes, Hours, Date
of the Month, Month, Day of the Week, and Year with
• Leap-Year Compensation
• Valid Up to 2100
• 96-Byte, Battery-Backed NV RAM for Data Storage
• Two Time-Of-Day Alarms,
• Programmable on Combination of Seconds, Minutes, Hours,
and Day of the Week
• 1Hz and 32.768kHz Clock Outputs
Unit-IV-8051 based Real world Interfacing and
50
Programming Part II
Department of Electronics
and Telecommunications

• Standard Serial Port Interfaces with Most


Microcontrollers (SPI)
• Multiple Power Supply Pins
• Battery for Backup
• Dual-Power Supply Pins for Primary and Backup Power
Supplies
• Optional Trickle Charge Output to Backup Supply
• 2.0V to 5.5V Operation
• Optional Industrial Temperature Range: -40°C to +85°C
Supports Operation in a Wide Range of Applications
Unit-IV-8051 based Real world Interfacing and
51
Programming Part II
Department of Electronics
and Telecommunications

Pin and Block Diagram

Source : DS 1306 Data sheet


Unit-IV-8051 based Real world Interfacing and
52
Programming Part II
Department of Electronics
and Telecommunications

Source : DS 1306 Data sheet


Unit-IV-8051 based Real world Interfacing and
53
Programming Part II
Department of Electronics
and Telecommunications

• Programming of 8951 for DS 1306

Unit-IV-8051 based Real world Interfacing and


54
Programming Part II
Department of Electronics
and Telecommunications

THANK - YOU

Unit-IV-8051 based Real world Interfacing and


55
Programming Part II

You might also like