Unit Iii Ppi

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 70

UNIT – III PROGRAMMABLE PERIPHERAL

INTERFACE
Introduction – Architecture of 8255, Keyboard
Interfacing, LED display – Interfacing, ADC and
DAC Interface, Temperature Control – Stepper
Motor Control – Traffic Control Interface.
 Introduction.
 To communicate with the outside world,

microprocessor use peripherals (I/O devices)


 • Input devices – Keyboards, A/D converters

etc.,
 • Output devices – CRT, Printers, LEDs etc.,
 •Peripherals are connected to the
microprocessors through electronic circuit
known as interfacing circuits.
Some of the general purpose interfacing
devices
• I/O ports
• Programmable peripherals interface (PPI)
• DMA controllers
• Interrupt controller
Some of the special purpose interfacing
devices
• CRT controller
• Keyboard
• Display
• Floppy Disc controllers
Programmable peripheral
interface 8255
 PPI 8255 is a general purpose programmable I/O device
designed to interface the CPU with its outside world such as
ADC, DAC, keyboard etc.
 We can program it according to the given condition.
 It can be used with almost any microprocessor.
 It consists of three 8-bit bidirectional I/O ports i.e. PORT A,
PORT B and PORT C.
 We can assign different ports as input or output functions.
Programmable peripheral interface
8255
 The functions of the 8255 are classified according to 2 modes,
 (i) Bit Set/Reset (BSR) Mode.
 (ii) I/O Mode.

 (i) Bit Set/Reset Mode — The BSR Mode is used to set or reset
the bits in port C.
 ii) I/0 Mode — The I/O mode is further divided into three
modes:
 (i) Mode 0— Simple I/O ports.
 (i) Mode 1 - I/O ports with handshake.
 (iii) Mode 2 — Bi-directional I/O data transfer.
FEATURES OF 8255 .
 The 8255 is a widely used, programmable, parallel I/O
device.
 It can be programmed to transfer data under various
conditions from simple I/O to interrupt I/O.
 It is compatible, with all Intel and most other
microprocessors.
 Its bit set/reset mode allows setting and resetting of
individual bits of port C.
 The 8255 can operate in 3 I/O modes
 (i)Mode 0 (i) Mode 1 and (iii) Mode 2.
 It is completely TTL compatible.
Programmable peripheral
interface 8255
Programmable peripheral
interface 8255
 It consists of 40 pins and operates in +5V regulated power
supply.
 Port C is further divided into two 4-bit ports i.e. port C lower
and port C upper and port C can work in either BSR (bit set
rest) mode or in mode 0 of input-output mode of 8255.
 Port B can work in either mode 0 or in mode 1 of input-output
mode.
 Port A can work either in mode 0, mode 1 or mode 2 of input-
output mode.
Programmable peripheral
interface 8255
 It has two control groups, control group A and control group
B.
 Control group A consist of port A and port C upper.
 Control group B consists of port C lower and port B.
 Depending upon the value if CS’, A1 and A0 we can select
different ports in different modes as input-output function or
BSR.
 This is done by writing a suitable word in control register
(control word D0-D7).
Programmable peripheral
interface 8255
 Group A and Group B Controls
 The Group A and Group B Control Blocks receives control
words from the CPU and issues appropriate commands to the
ports associated with it.
 The Group A Control block controls port A and PC7 - PC4
while the Group B Control block controls Port B and PC3 –
PC0.
Programmable peripheral
interface 8255
 Port A: It has an 8-bit latched and buffered output and an 8-bit
input latch.
 It can be programmed in three modes; Mode 0, Mode 1 and
Mode 2.
 Port B: It has an 8-Bit data I/O latch/buffer and an 8-bit data
input buffer.
 It can be programmed in Mode 0 and Mode 1.
 Port C: It has one 8-Bit unlatched input buffer and an 8-bit
output latch/buffer.
 Port C can be separated into two ports and each can be used as
control signals for port A and B in the handshake mode.
 It can be programmed for bit set/reset operation.
Programmable peripheral
interface 8255
 Data Bus Buffer
 It is a tri-state bi-directional buffer used to interface the
internal data bus of 8255 to the system data bus.
 The instruction executed by the microprocessor can read the
data from the buffer or write the data into the buffer.
 Similarly, the control registers and the status registers all
passed through the buffer.
Programmable peripheral
interface 8255
 Control Logic
 The control logic block accepts control bus

signals as well as inputs from the address


bus and generates the commands to the
individual group control of Group A and
Group B.
Programmable peripheral
interface 8255
 The Control Logic has six lines. They are
 RD (Read): This control signal enables the Read operation.
When the signal is low, the CPU reads data from a selected
I/O port of the 8255.
 WR (Write): This control signal enables the Write operation.
When the signal is low, the CPU writes data or controls word
into 8255.
 A0 and A1: The selection of input port and control word
register is done by using A0 and A1.
 It specifies one of the I/O ports (or) the control register as
given below.
Programmable peripheral
interface 8255
CS’ A1 A0 Selection

0 0 0 PORT A

0 0 1 PORT B

0 1 0 PORT C

Control word
0 1 1
Register
Programmable peripheral
interface 8255
 RESET (Reset): This is an active high
signal; it clears the control register and sets
all ports in the input mode.
 CS (Chip Select): It is a Chip Select Signal.

The low status of this signal enables


communication between the CPU and the
8255. i.e.,
CS Selected
0 8255 is selected
1 8255 is not selected
8255 microprocessor operating
modes
 There are two different modes of 8255.
These modes are:
 Bit Set Reset (BSR) Mode
 Input/ Output Mode
Bit Set Reset (BSR) Mode
 This mode is used to set or reset the bits of the
Port-C only. For BSR mode always D7 will be 0.
The control register is looking like this:

 The (D3, D2, D1) will be 000 to 111.


 In this mode it affects only one bit of Port C at a
time.
 When user set the bit, it remains set until user
unset it.
 The user needs to load the bit pattern in control
register to change the bit.
Input/ Output Mode
 This mode is selected when the D7 bit of
the control register is 1.
 This mode has also three different modes.

These modes are Mode 0 and Mode 1 and


Mode 3.
 Mode 0 – Simple or basic I/O Mode
 In this mode all of the ports A, B and C can

be used as input or output mode. The


outputs are latched, but inputs are not
latched. This mode has interrupt handling
capability.
Mode 1 – Handshake or Strobed
I/O
 In this mode the Port A and Port B can be
used as input or output ports, the port C are
used for handshaking.
 In this mode the inputs and outputs are

latched.
 This mode also has the interrupt handling

capability, and signal control to match the


speed of CPU and IO devices.
Mode 3 – Bidirectional I/O
 In this mode only Port A can work, and port
B can either be in mode 0 or mode 1, and
the port C are used for handshaking.
 In this mode the inputs and outputs are

latched.
 The control register is looking like below in

this mode:
Bits Function
D7 1 for IO mode and 0 for BSR mode
These are used to set port A
mode. for 00, it is m0 mode, for
D6 & D5
01, it is m2 mode and 10 or 11, it
is m2 mode.
1 when port A is taking input, 0
D4
when port A is sending output.
1 when higher nibble of port C is
D3 taking input, and 0 when higher
nibble is sending output.
It tells the mode of Port B. For 0, it
D2 is m0 mode, and for 1, it is m1
mode.
1 when port B is taking input, 0
D1
when port B is sending output.
1 when lower nibble of port C is
D0 taking input, and 0 when lower
nibble is sending output.
Interfacing a Microprocessor To
Keyboard
 When we press a key on your computer, we are
activating a switch.
 There are many different ways of making these switches.
 Mechanical key switches:
 In mechanical-switch keys, two pieces of metal are

pushed together when you press the key.


 The actual switch elements are often made of a

phosphor-bronze alloy with gold platting on the contact


areas.
 The key switch usually contains a spring to return the

key to the non pressed position and perhaps a small piece


of foam to help damp out bouncing.
Interfacing a Microprocessor To
Keyboard
 In most keyboards, the key switches are connecting in a
matrix of rows and columns.
 Getting meaningful data from a keyboard, it requires

the following three major tasks:


 1. Detect a key press.
 2. Debounce the key press.
 3. Encode the key press
 Three tasks can be done with hardware, software, or a

combination of two, depending on the application.


Interfacing a Microprocessor To
Keyboard
Interfacing a Microprocessor To
Keyboard
Interfacing a Microprocessor To
Keyboard

1100 1101 1110 1111

1000 1001 1010 1011

0100 0101 0110 0111

0000 0001 0010 0011


Interfacing a Microprocessor To
Keyboard
 The rows of the matrix are connected to four output port lines.
 The column lines of matrix are connected to four input -port
lines.
 When no keys are pressed, the column lines are held high by
the pull-up resistor connected to +5V.
 Pressing a key connects a row to a column.
 If a low is output on a row and a key in that row is pressed,
then the low will appear on the column which contains that key
and can be detected on the input port.
Interfacing a Microprocessor To
Keyboard
 If we know the row and column of the pressed key, we
then know which key was pressed, and we can convert
this information into any code you want to represent
that key.
Interfacing a Microprocessor To
Keyboard
Interfacing a Microprocessor To
Keyboard
 The final task is to determine the row and column of the
pressed key and convert this row and column information to
the hex code for the pressed key.
 To get the row and column information, a low is output to one
row and the column are read.
 If none of the columns is low, the pressed key is not in that
row.
 So the low is rotated to the next row and the column are
checked again.
 The process is repeated until a low on a row produces a low on
one of the column.
 The pressed key then is in the row which is low at that time.
Interfacing Seven Segments
LED Display
 Seven segments LED display :
 A seven-segment LED is a kind of LED(Light

Emitting Diode) consisting of 7 small LEDs it


usually comes with the microprocessor’s as we
commonly need to interface them with
microprocessors like 8085.
Interfacing Seven Segments
LED Display
 Structure of Seven Segments LED :
 The LED in Seven Segment display are

arranged as below
Interfacing Seven Segments
LED Display
 It can be used to represent numbers from 0 to 8 with a
decimal point.
 It have eight segments in a Seven Segment LED

display consisting of 7 segments which include ‘.’.


 The seven segments are denoted as “a, b, c, d, e, f, g,

h” respectively, and ‘.’ is represented by “h”


Interfacing Seven Segments
LED Display
 Common Anode – 0 will make an LED glow.
 Common Cathode – 1 will make an LED glow.
Interfacing Seven Segments
LED Display
 Common Anode (CA) Configuration
 In an anode common configuration, the positive

terminals of the seven LEDs are connected together


to a common positive voltage.
 Typically, this is VCC. Individual segments are

turned on by grounding the respective cathode.


 A LOW, or logic 0, voltage at a cathode sends current

flowing from the CA, through the LED segment, to


ground and turns it on.
Interfacing Seven Segments
LED Display
 Common Anode Method :
 Here we are using a common anode display therefore

0 logic is needed to activate the segment.


 Suppose to display number 9 at the seven-segment

display, therefore the segments F, G, B, A, C, and D


have to be activated.
 i.e. 10010000
Interfacing Seven Segments
LED Display
 Common cathode:
 In the common cathode configuration, all the

cathodes (negative terminals) of the seven LEDs are


connected to a common ground.
 Display segments are controlled independently by

applying a HIGH (Logic 1) voltage to the anode of


the particular LED.
 On applying the HIGH signal to an anode, current

flows from the anode to the common cathode, and


accordingly, the respective segment lights up.
Interfacing Seven Segments
LED Display
 Common Cathode Method :
 Here we are using common cathode 1 logic is needed

to activate the signal.


 Suppose to display number 9 at the seven-segment

display, therefore the segments F, G, B, A, C, and D


have to be activated.
 i.e.01101111
Interfacing Seven Segments
LED Display
Interfacing Seven Segments
LED Display
Interfacing Seven Segments
LED Display
Interfacing Seven Segments
LED Display
Interfacing Seven Segments
LED Display
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING
 ADCs (Analog-to-Digital Converters) are among the most
widely used devices for data acquisition.
 A physical quantity, like temperature, pressure, humidity, and
velocity, etc., is converted to electrical (voltage, current)
signals using a device called a transducer or sensor
 We need an Analog-to-Digital Converter to translate the
analog signals to digital numbers, so microcontroller can read
and process them.
 An ADC has n-bit resolution where n can be 8, 10, 12, 16 or
even 24 bits.
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING
 The Analog to Digital Conversion is a quantizing process.
 Here the analog signal is represented by equivalent binary
states.
 The A/D converters can be classified into two groups based
on their conversion techniques.
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING
 In the first technique it compares given analog signal with the
initially generated equivalent signal.
 In this technique, it includes successive approximation,
counter and flash type converters.
 In another technique it determines the changing of analog
signals into time or frequency.
 This process includes integrator-converters and voltage-to-
frequency converters.
 The first process is faster but less accurate, the second one is
more accurate.
 As the first process uses flash type, so it is expensive and
difficult to design for high accuracy.
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING
 ADC 0808/0809 Chip
 The ADC 0808/0809 is an 8-bit analog to digital converter.
 It has 8 channel multiplexer to interface with the
microprocessor.
 This chip is popular and widely used ADC.
 ADC 0808/0809 is a monolithic CMOS device.
 This device uses successive approximation technique to
convert analog signal to digital form.
 One of the main advantage of this chip is that it does not
require any external zero and full scale adjustment, only +5V
DC supply is sufficient.
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING
 ADC 0808/0809 Chip
 ADC 0808/0809 has eight input channels, so to select desired
input channel, it is necessary to send 3-bit-address on A, B and
C inputs.
 The address of the desired channel is sent to the multiplexer
address inputs through port pins.
 After at least 50 ns, this address must be latched.
 This can be achieved by sending ALE signal.
 After another 2.5 microseconds, the Start of Conversion
(SOC) signal must be sent high and then low to start the
conversion process.
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING
 ADC 0808/0809 Chip
 To indicate the end of conversion ADC 0808/0809 actives End
of Conversion (EOC) Signal.
 The Microprocessor system can read converted digital word
through the data bus by enabling the output enable signal after
EOC is activated,
 It uses successive approximation as the conversion technique.
 It does not require external zero and full-scale adjustments.
 There is no terminal available for sample and hold between
the multiplexer and comparator.
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING
 ADC 0808/0809 Chip
 Some important characteristic of ADC 0808/0809 are
 Minimum Start Pulse Width - 100 ns
 Minimum ALE Pulse Width - 100 ns
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING

Features of ADC 0808/0809:


 The conversion speed is much higher.

 The accuracy is also high.

 It has minimal temperature dependence.

 Excellent long term accuracy and repeatability .

 Less power consumption.


ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING

Architecture of
ADC
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING
 Interfacing ADC with 8085 Microprocessor
 To interface the ADC with 8085, we need 8255 Programmable
Peripheral Interface chip with it.
 Let us see the circuit diagram of connecting 8085, 8255 and
the ADC converter.
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING

Interfacing ADC with 8085 Microprocessor


ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING
 An analog input is connected to IN 3 and 5V dc supply
applied to pin 12 ie., Ref (+).
 ADC 0808 has eight input channels, so to select desired input
channel, it is necessary to send three bit address on ADC.
 The address of the desired channel is sent to the multiplexer
address inputs to ADDA, ADDB and ADDC lines through
PC0, to PC2, lines.
 The digital input is sent to the microprocessor by the DB0, to
DB7 lines.
ANALOG-TO-DIGITAL
CONVERTER (ADC) INTERFACING
 The PortA of 8255 chip is used as the input port.
 The PC7 pin of Port Cupper is connected to the End of
Conversion (EOC) Pin of the analog to digital converter.
 This port is also used as input port.
 The Clower port is used as output port.
 The PC2-0 lines are connected to three address pins of this
chip to select input channels.
 The PC3 pin is connected to the Start of Conversion (SOC)
pin and ALE pin of ADC 0808/0809.
Temperature Control
INTERFACING
 Transducers convert physical data to electrical - signals.
 Physical data are temperature, light, intensity, flow and speed.
 Depending on the transducers can produce the output in various
formats such as
 1. Voltage :
 2. Current
 3. Resistance
 4. Capacitance

 For example, temperature is converted to electrical signals using a


transducer called a thermistor.
 A thermistor responds to temperature change by changing resistance
but its response is not linear.
Temperature Control
INTERFACING
 LM 34 AND LM 35 TEMPERATURE SENSORS
 The sensors of the LM34 series are precision integrated circuit
temperature sensors whose output voltage is linearly
Proportional to the Fahrenheit temperature.
 It does not require external calibration because it is internally
calibrated, It outputs 10 mV for each degree/ of Fahrenheit
Temperature.
 The LM35 series sensors are precision integrated circuit
temperature sensors whose output voltage is linearly
proportional to the Celsius temperature.
 It also, does not require any external and it outputs 10 mV for
each degree of centigrade temperature.
Temperature Control
INTERFACING
 SIGNAL CONDITIONING
 Signal conditioning is widely used in the data acquisition.
 The most common transducers produce an output in the form
of voltage, current, charge, capacitance and resistance.
 Because we need to convert these signals to voltage in order to
send input to an A to D converter.
 This conversion is commonly called signal conditioning.
 Signal conditioning is a current to voltage conversion or signal
amplification.
 For example, the thermistor changes resistance with
temperature. The change of resistance must be translated into
voltages in order to be of any use to an ADC.
Temperature Control
INTERFACING
Temperature Control
INTERFACING

You might also like