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

R.M.K.

ENGINEERING COLLEGE
(AUTONOMOUS)
RSM Nagar, Kavaraipettai – 601206

DEPARTMENT OF MECHANICAL ENGINEERING


20ME 919 : MECHATRONICS
Professional Elective – III (Semester VII)

Google Class code: phmozqb


Glimpse of last session…………………
Syllabus

Unit III - PROGRAMMABLE PERIPHERAL INTERFACE 9

Introduction – Architecture of 8255, Keyboard interfacing, LED

display –interfacing, ADC and DAC interface, Temperature

Control – Stepper Motor Control – Traffic Control interface.

4
Introduction to 8255 PPI

 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.

5
Architecture of 8255

6
Architecture of 8255
The three ports are PORT A, PORT B & PORT C.
• Port A contains one 8-bit output latch/buffer and one 8-bit input
buffer.
• Port B is same as PORT A or PORT B.
• Port C can be split into two parts PORT C lower (PC0-PC3) and
PORT C upper (PC7-PC4) by the control word.
The three ports are divided in two groups
• Group A (PORT A and upper PORT C)
• Group B (PORT B and lower PORT C).

7
Architecture of 8255
The two groups can be programmed in three different modes.
• First mode (mode 0), each group may be programmed in either
input mode or output mode (PORT A, PORT B, PORT C lower,
PORT C upper).
• Second mode (mode 1) each group may be programmed to have
8-lines of input or output (PORT A or PORT B) of the remaining
4-lines (PORT C lower or PORT C upper) 3-lines are used for
hand shaking and interrupt control signals.
• Third mode of operation (mode 2) is a bidirectional bus mode
which uses 8-line (PORT A only for a bidirectional bus and five
lines PORT C upper 4 lines and borrowing one from other group)
for handshaking.
8
Pin diagram of 8255

PA0 – PA7 – Pins of port A


PB0 – PB7 – Pins of port B
PC0 – PC7 – Pins of port C
D0 – D7 – Data pins for the
transfer of data
RESET – Reset input
RD’ – Read input
WR’ – Write input
CS’ – Chip select
A1 and A0 – Address pins

9
Pin diagram of 8255
Data Bus Buffer
It is a tri-state 8-bit buffer, which is used to interface the microprocessor to
the system data bus. Data is transmitted or received by the buffer as per
the instructions by the CPU. Control words and status information is also
transferred using this bus.
Read/Write Control Logic
This block is responsible for controlling the internal/external transfer of
data/control/status word. It accepts the input from the CPU address and
control buses, and in turn issues command to both the control groups.
CS
It stands for Chip Select. A LOW on this input selects the chip and enables
the communication between the 8255A and the CPU. It is connected to the
decoded address, and A0 & A1 are connected to the microprocessor address
lines.
1
Pin diagram of 8255
CS A1 A0 Result
0 0 0 PORT A
0 0 1 PORT B
0 1 0 PORT C
0 1 1 Control Register
1 X X No Selection
WR
It stands for write. This control signal enables the write operation. When this
signal goes low, the microprocessor writes into a selected I/O port or control
register.
RESET
This is an active high signal. It clears the control register and sets all ports in the
input mode.
RD
It stands for Read. This control signal enables the Read operation. When the
signal is low, the microprocessor reads the data from the selected I/O port of the
8255.
11
Pin diagram of 8255
A0 and A1
These input signals work with RD, WR, and one of the control signal. Following is
the table showing their various signals with their result.
A1 A0 RD WR CS Result
Input Operation
0 0 0 1 0
PORT A → Data Bus
0 1 0 1 0 PORT B → Data Bus
1 0 0 1 0 PORT C → Data Bus

Output Operation
0 0 1 0 0
Data Bus → PORT A

0 1 1 0 0 Data Bus → PORT A

1 0 1 0 0 Data Bus → PORT B

1 1 1 0 0 Data Bus → PORT D


1
Keyboard interfacing
• Keyboard consists of number of key switches used for
entering data.
•The important part of the interface between the
keyboard and the micro processor is to find out whether
any key is pressed the location of the key should be
determined.
•A Key, when pressed, makes the contact till it is pressed
and the contact is broken when it is released.
• A Key closure can be determined easily by supplying a
voltage at one of the two points and finding out the
voltage at the other point.
Keyboard interfacing
• for interfacing to microprocessor, one point is connected to +5
V and the other point is connected to sense the voltage.
•The OUT point can be sensed as one bit of any port.
Two key Switches: The input points of the two keys can be
connected together and a high voltage applied.
•The OUT1 & OUT2 points can be connected to two separate
bits of a port.
Keyboard interfacing
•Four key Switches: The input points of the four keys can be
connected together and a high voltage applied.
•The OUT1,OUT2,OUT3 & OUT4 points can be connected to four
separate bits of a port.
•This approach cannot be adopted for more number of keys
•Keyboard is arranged as a matrix consisting of rows and
columns.
•For a 64 keyboard will require 8-bit ports of the output points.
Keyboard interfacing
•For a 4-key keyboard, 2x2 matrix is arranged for 2 IN & 2 OUT.
Keyboard
Interface

4 X 4 Matrix 4 X 3 Matrix
Keyboard
Interface

1
Keyboard
Interface
• Here we use port A as output port for selecting a row of keys while
port B is used as an input port for sensing a closed key.
• Hence the keyboard lines are selected one by one through Port A
and the Port B lines are polled continuously till a key closure is
sensed.
• The higher order lines of Port A and Port B are left unused. The
flow chart of the ALP is as shown below :

19
Keyboard
Interface
We suppose that we use simple mechanical switches. For keyboard, then
to get the meaningful data from a keyboard requires three steps :
(1) Detect a key press
(2) Debounce the key press
(3) Encode the key press
The three tasks can be done with a hardware, software or a combination
of the two.
The rows of the matrix are connected to four output port lines. The
column line of the matrix are connected to four input port lines

20
Keyboard
Interface
Keyboard
Interface
Key Debouncing
•For interfacing keyboard to the microprocessor based systems
usually push button keys are used .
• These push button keys when pressed bounces a few times
closing and opening the contacts before providing a steady
reading.
•The microprocessor must wait un till the key reach to a steady
state.
•This can be eliminated by key debounce technique, either
hardware or software.
Key Debouncing using Hardware

•Hardware debouncing technique uses an S-R latch to avoid


bounces in the circuit along with the pull up resistors.
Key Debouncing using Hardware
•The circuit uses two cross coupled NAND gates which form an S-
R latch, A SPDT (Single Pole Double Throw) switch, two pull up
resistors. The resistor generates a logic ‘one’ for the gates, Switch
pulls one of the inputs to ground.
•if the switch is in position as shown in figure the output of the
upper gate is ‘1’ irrespective of the input of the other gate and
the one created by the bottom pull up resistor which drives the
lower NAND gate to zero which in return races back to the other
gate.
• If the switch moves back and forth between the contacts and is
suspended for a while in neither region between the terminals,
the latch maintains its state because ‘0’ from the bottom NAND
gate is fed back.
Key Debouncing using software
Key board interfacing to 8085
using 8255 PPI
Key board interfacing to 8085
using 8255 PPI
•matrix keyboard with 64 keys connected to the 8085
microprocessor using 8255. A matrix keyboard reduces the number
of connections, thus the number of interfacing lines. In this example,
the keyboard with 64 keys, is arranged in 8 x 8 (8 rows and 8
columns) matrix.
•This requires sixteen lines from the microprocessor to make all the
connections instead of 64 lines if the keys are connected individually.
The interfacing of matrix keyboard requires two ports: one input
port and other output port. Rows are connected to the input port,
port A and columns are connected to the output port,port B.
•The codes for different keys are stored in the 8085 memory. The
microprocessor will read the corresponding code from memory and
initiate action as per requirement.
Source program for matrix

keyboard interface
MVI A, 90H : Initialize Port A as input and MVI D, 08H : Initialize row counter
OUT CR : Port B as Output IN PA : Read return line status
START: MVI A, 00 : Make all scan lines zero NEXTROW: RRC : Check for one row
OUT PB JNC DISPLAY : If zero, goto display else continue
BACK: IN PA INR L : Increment key counter
CPI FF : Check for key release DCR D : Decrement row counter
JNZ BACK : If not, wait for key release JNZ NEXTROW : Check for next row
CALL DELAY : Wait for key debounce MOV A, B
BACK 1: IN PA RLC : Select the next column
CPI FF : Check for key press MOV B, A
JZ BACK 1 : If not, wait for key press DCR C : Decrement column count
CALL DELAY : Wait for key debounce JNZ NEXTCOL : Check for last column if not repeat
MVI L, 00H : Initialize key counter JMP START : Go to start
MVI C, 08H
MVI B, FEH : Make one column low
NEXTCOL: MOV A, B
OUT PB
Keyboard
Interface

3
32
Keyboard Interface
Keyboard Interface
Keyboard Interface
LED Interface
•The Light Emitting Diodes (LEDs) are used to
display data, messages & texts. the total no
of characters that are displayed is fixed .
•The LEDs are commonly used on the front
panel of instruments, digital clocks etc
•The LED is a diode when conducts, emits
light energy, the conduction starts when the
anode is held at higher voltage than the
cathode.
LED interface
• LEDs can be directly interfaced with
microprocessor through 8255 PPI through an
output ports
•In common cathode configuration whenever a
bit is 1,the corresponding LED will glow.
LED interface
•In case of common anode configuration, 0 in
any bit position will make the corresponding
LED glow
•By loading a particular bit pattern in the
port, the desired LEDs may be lighted.
LED interface
•An output device which is very common is, especially in
the kit of 8085 microprocessor and it is the Light Emitting
Diode consisting of seven segments.
• Moreover, we have eight segments in a LED display
consisting of 7 segments which includes ‘.’, consisting of
character 8 and having a decimal point just next to it.
•We denote the segments as ‘a, b, c, d, e, f, g, and dp’
where dp signifies ‘.’ which is the decimal point.
•Moreover, these are LEDs or together a series of Light
Emitting Diodes. We have shown the internal circuit
comprising of a display of seven segment.
LED interface
LED interface
•There are two types of 7-segment LED: They are
the common anode type and the common
cathode type.
•In the LED which is common anode and is 7-
segmented, here all the eight LED anodes
together and the eight external pin is brought to
display is connected. And this pin gets connected
to a DC supply of +5 Volt.
• The cathode ends of the eight segments are
brought out on the pins of the display.
Parallel Interface
•The anodes of all LEDs are held permanently at
+5V,where as the cathodes are connected to the
port bits.
•The microprocessor through the PPI will load any
bit pattern in the out port.
Serial Interface
•The anodes of all LEDs are held permanently at
+5V,where as the cathodes are connected to the
port bits with the help of the shift registers
Serial Interface
•A shift register is a cascade of flip flops, sharing
the same clock, in which the output of each flip-
flop is connected to the "data" input of the next
flip-flop in the chain,
•This sequential device loads the data present on
its inputs and then moves or “shifts” it to its
output once every clock cycle,
Serial Interface flow chart
LED Display Interface to 8085
using 8255PPI
LED Interface

47
LED Interface

• The 8255 is to be interfaced with lower order data bus; i.e. D0-D7.
• The A0 and A1 pins of 8255 are connected to A1 and A2 pins of
the microprocessor respectively. We will use absolute decoding
scheme that uses all the 16 address lines.
• For deriving the device address pulse. Out of A0– A15 lines, two
address lines A2 and A1 are directly required by 8255 for three
port and CWR address decoding. Hence only A3 to A15 are used
for decoding addresses.
• Circuit diagram, the 8086 is assumed to be in the maximum mode
so that IORD and I OWR are readily available.
48
LED Interface

49
ADC Interface with 8085 μP using
8255
 The Analog to Digital Conversion is a quantizing process.
PPI
 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.
 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 second 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.
51
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.
 Let us see some good 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
52
Analog to Digital Converter(ADC)
•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.
ADC 0808/0809 Chip
Functional block diagram

54
ADC Interface with 8085 μP using
8255 PPI
 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.

55
Pin diagram of ADC 0808/0809
ADC Interface with 8085 μP using
8255 PPI

57
ADC Interface with 8085 μP using
8255 PPI - Program
MVI A 98H Set Port A and Cupper as input, CLower as output
OUT 03H Write control word 8255-I to control Word register
XRA A Clear the accumulator OUT 02H ; Send the content of
Acc to Port Clower to select IN0
MVI A, 08H Load the accumulator with 08H
OUT 02H ALE and SOC will be 0
XRA A Clear the accumulator
OUT 02H ALE and SOC will be low
READ: IN 02H Read from EOC (PC7)
RAL Rotate left to check C7 is 1
JNC READ If C7 is not 1, go to READ
IN 00H Read digital output of ADC
STA 8000H Save result at 8000H
HLT Stop the program
58
Digital to Analog Converter(DAC)
interface
•It is used to convert a digital quantity to Analog quantity. it produces
an output current or voltage proportional to digital quantity applied
to its input.
•A DAC accepts an n bit input word b1,b2,b3,…. B8 in binary and
produce an analog signal proportional to it.
• Each Digital input requires an electrical signal representing either a
logic 1 or logic 0.the bn is the least significant bit (LSB) where as b1 is
the most significant bit(MSB).
DAC Interfacing
• Digital to analog converters are used to get a proportional analog voltage or
current for the digital data given out by the microprocessor.
• The D-A converters are essential in a microprocessor based systems as the real
world applications are operating with analog data. Basically there are two types
of DAC.
• They are R-2R ladder network and weighted resistor network. Many DAC chips
are available in the market.
• The specifications of the DAC chips are the full scale output voltage, number of
binary input bits, resolution, linearity and settling time.
• The DAC chips come with choices in the maximum output voltage as 5V, 10V or
with a predefined maximum current output. The number of binary input bits
can be 4 bits or 8 bits or 10 bits or 12 bits.
• The number of bits and the full scale output voltage both will determine the
resolution. For example, an 8 bit DAC can have 256 input combinations and so
has a resolution of (1/256) or 0.39 percentage of the full scale output.
61
DAC Interfacing
• Similarly, the 10 bit DAC will have the resolution of (1/1024) or 0.0977
percentage of the full scale output.
• Linearity is a measure of how straight the output is when the output is changed
from minimum value to the maximum value.
• The settling time is defined as the time take for the output to settle within pre-
specified band after the input digital value is applied. Normally, pre-specified
band is [final value±(1/2)*Minimum possible output].
• The settling time is an important specification as the DAC output may overshoot
the correct value and may oscillate for some time before settling.
• The settling time for a DAC chip should be considered in applications where
high frequency operation is essential.
• Digital to analog converters are required to generate the variable analog voltage
essential for control applications Most of the speech synthesizers required a
DAC to convert the binary data in to the corresponding analog speech signal.
62
Pin Diagram of DAC 1408
DAC 1408
Interfacing DAC 0800 with 8085

65
DAC Interfacing
• DAC 0800 is a common digital to analog converter chip that can be easily
interfaced to 8085 through 8255. This section will describe the interfacing of
DAC 0800 with the 8085 processor.
• As the DAC chip can only be connected to an output port of a processor, the
8255 PPI is essential in the interface. Any one port is enough to interface an 8-bit
DAC with 8255.
• The other control signals are directly correspondingly connected to either logic 0
or logic 1. The DAC chip gives a proportional current output.
• This current output in most cases is difficult to measure and so a current to
voltage (I to V) converter is used at the output. DAC chips have an inbuilt latch.
• This latch stores the digital input given by the port A and gives out a
proportional voltage.
• Four common applications such as square wave generation, ramp wave
generation, staircase wave generation and sine wave generations are discussed.
66
Temperature control

67
Temperature control
 Industrial and control application/may require automation of the process such
as temperature, pressure, liquid flow, etc., in order to minimize manual
intervention. To automate any application an intelligent processor plays a
major role. One such processor proposed for the project is 8085, an 8-bit
microprocessor.
 The temperature controller can be used to control the temperature of any
plant. Typically it contains a Processor unit, Temperature input unit and
Control output unit. The 8085 based motherboard forms the processing unit.
 The Analog-to-Digital unit together with temperature sensor forms the
temperature input unit.
 The relay driver forms the control output unit. Electric power to the heating
element (coil) is supplied through relay contacts. The switching ON/OFF of the
relay controls the heat supplied to the plant
 Operationally, the system requires two set points-upper and lower, to be
entered by the user. Whenever the temperature of the plant exceeds the
upper limit or recede the lower limit relay is turned-off, so that a
temperature is maintained within limits. The software for the
temperature controller is developed in 8085assembly language programs
68
Temperature control
HARDWARE DESCRIPTION
• The hardware consists of 8085 microprocessor motherboard, ADC interface
board, and relay and driver unit.
• The motherboard consists of 8085 MPU, 8KB EPROM, 8KB RAM keyboard
and display controller 8279, programmable peripheral interface 8255, 21 key
hex-keypad and six numbers of seven segment LED’s.
• Ports Expansion connector parallel port connectors are provided for external
interfacing.
• The temperature input board or ADC interface board consists of ADC 0809,
which is an 8-bit converter with eight channels of input. It is interfaced with the
motherboard through 50-pin bus expansion connector.
• The temperature sensor ADC590 is used to sense the temperature of the plant
and its analog output is applied to the channel-0 of ADC.
• Relay is switched ON/OFF by driving the transistor to saturation/cut-off which
is connected to port A of 8255
69
Dr. M. MUDHU KRISHNAN

+91 9841557918 (W)

mmk.mech@rmkec.ac.in

You might also like