Unit 3

You might also like

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

UNIT 3

PROGRAMMABLE PERIPHERAL
INTERFACE
(8255)
Modes of Operation
1. I/O Mode
2. Bit Set – Reset mode (BSR)

In I/O Mode, 8255 ports work as programmable I/O


ports.
In BSR Mode, only port C (PC0 – PC7) can be used to
set or reset its individual port bits.
Two modes – selected on the basis of values present at
the D7 bit of CWR.
D7 = 1 → 8255 operates in I/O Mode
D7 = 0 → 8255 operates in BSR Mode
BIT SET/RESET MODE (BSR)
• The Bit Set/Reset (BSR) mode is available on port C only.
• Each line of port C (PC7 - PC0) can be set or reset by writing a suitable value to the control word register.
• BSR and I/O mode are independent and selection of BSR mode does not affect the operation of other ports in I/O mode.
❖ D7 bit is always 0 for BSR mode.
❖ Bits D6, D5 and D4 are don't care bits.
❖ Bits D3, D2 and D1 are used to select the pin of Port C.
❖ Bit D0 is used to set/reset the selected pin of Port C.
• Selection of port C pin is determined as follows:
As an example, if it is needed that PC5 be set, then in the control word,
D3 D2 D1 Bit/pin of port C selected
0 0 0 PC0 1.Since it is BSR mode, D7 = '0'.
0 0 1 PC1
2.Since D4, D5, D6 are not used, assume them to be '0'.
0 1 0 PC2
0 1 1 PC3 3.PC5 has to be selected, hence, D3 = '1', D2 = '0', D1 = '1'.
1 0 0 PC4
4.PC5 has to be set, hence, D0 = '1'. Thus, as per the above values, 0B (Hex) will be
1 0 1 PC5
1 1 0 PC6 loaded into the Control Word Register (CWR).
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 1 0 1 1
I/O MODE
• This mode is selected when D7 bit of the Control Word Register is 1.
• There are three I/O modes
• Mode 0 - Simple I/O
• Mode 1 - Strobed I/O with handshaking
• Mode 2 - Strobed Bi-directional I/O

0
1
2
Control Word Format
• D0, D1, D3, D4 are assigned for port C lower, port B, port C upper and port A respectively.
• When these bits are 1, the corresponding port acts as an input port. For e.g., if D0 = D4 = 1, then lower port C and port A act
as input ports.
• If these bits are 0, then the corresponding port acts as an output port. For e.g., if D1 = D3 = 0, then port B and upper port C
act as output ports.
• D2 is used for mode selection of Group B (port B and lower port C). When D2 = 0, mode 0 is selected and when D2 = 1,
mode 1 is selected.
• D5 & D6 are used for mode selection of Group A ( port A and upper port C).
For example, if port B and upper port C have to be initialized as input ports and lower port C and port A as output ports
(all in mode 0):
Since it is an I/O mode, D7 = 1.
Mode selection bits, D2, D5, D6 are all 0 for mode 0 operation.
Port B and upper port C should operate as Input ports, hence, D1 = D3 = 1.
Port A and lower port C should operate as Output ports, hence, D4 = D0 = 0.
Hence, for the desired operation, the control word register will have to be loaded with "10001010" = 8A (hex).
Mode 0 - Simple I/O
• The ports can be used for simple I/O operations without handshaking signals.
• Port A, Port B, {Port C – either 8 bit or two 4 bit}.
• The input/output features in mode 0 are as follows:
Output ports are latched.
Input ports are buffered, not latched.
Ports do not have handshake or interrupt capability.
With 4 ports, 16 different combinations of I/O are possible.

❖ 'Latched' means the bits are put into a storage register (array of flip-flops) which holds its output constant even if the
inputs change after being latched.
❖ The 8255's outputs are latched to hold the last data written to them. This is required because the data only stays on the bus
for one cycle. So, without latching, the outputs would become invalid as soon as the write cycle finishes.
❖ The inputs are not latched because the CPU only has to read their current values, then store the data in a CPU register or
memory if it needs to be referenced at a later time. If an input changes while the port is being read then the result may be
indeterminate.
Mode 0 – input mode
• In the input mode, the 8255 gets data from the external peripheral ports and the CPU reads the received data via its
data bus.
• The CPU first selects the 8255 chip by making CS low. Then it selects the desired port using A0 and A1 lines.
• The CPU then issues an RD signal to read the data from the external peripheral device via the system data bus.

Mode 0 – output mode


• In the output mode, the CPU sends data to 8255 via system data bus and then the external peripheral ports receive this
data via 8255 port.

• CPU first selects the 8255 chip by making CS low. It then selects the desired port using A0 and A1 lines.

• CPU then issues a WR signal to write data to the selected port via the system data bus. This data is then received by
the external peripheral device connected to the selected port.
Mode 1 - Strobed I/O
• When we wish to use port A or port B for handshake (strobed) input or output operation, we initialize that port in mode 1
(port A and port B can be initialized to operate in different modes, i.e., for e.g., port A can operate in mode 0 and port B in
mode 1).
• Some of the pins of port C function as handshake lines.
• For port B in this mode (irrespective of whether is acting as an input port or output port), PC0, PC1 and PC2 pins function
as handshake lines.
• If port A is initialised as mode 1 input port, then, PC3, PC4 and PC5 function as handshake signals. Pins PC6 and PC7 are
available for use as input/output lines.
• The mode 1 which supports handshaking has following features:
Two ports i.e. port A and B can be used as 8-bit i/o ports.
Each port uses three lines of port c as handshake signal and remaining two signals can be used as i/o ports.
Interrupt logic is supported.
Input and Output data are latched.
MODE1 INPUT CONTROL SIGNAL
MODE 1 OUTPUT CONTROL SIGNAL
Mode 2 - Strobed Bidirectional I/O
• Only port A can be initialized in this mode.
• Port A can be used for bidirectional handshake data transfer.
• This means that data can be input or output on the same eight lines (PA0 - PA7).
• Pins PC3 - PC7 are used as handshake lines for port A and the remaining pins of port C (PC0 - PC2) can be used as
input/output lines if group B is initialized in mode 0 or as handshaking for port B if group B is initialized in mode 1.
• In this mode, the 8255 may be used to extend the system bus to a slave microprocessor or to transfer data bytes to and
from a floppy disk controller.
• Acknowledgement and handshaking signals are provided to maintain proper data flow and synchronization between the
data transmitter and receiver.
MODE 2 I/O CONTROL SIGNALS
Mode 2 : Control signals

Input Control Signals:


STB (Strobe Input):
► This is an active low input signal which enables Port A to latch the data
available at its input.
IBF (Input Buffer Full Flip-Flop):
► This is an active high output which indicates that data has been loaded into the
input latch of Port A.
INTE 2:
► This is an Interrupt enable flip-flop associated with Input Buffer Full. It can be
controlled by setting or resetting PC4 in the BSR Mode.
Mode 2 : Control signals

Output Control Signals :


OBFA (Output Buffer Full):
► This is an active low output which indicates that the CPU has written data into
Port A.
ACKA (Acknowledge):
► This is an active low input signal (generated by the peripheral) which enables
the tri-state output buffer of Port A and makes Port A data available to the
peripheral. In Mode 2, Port A outputs are in tri-state until enabled.
INTE 1:
► This is the flip-flop associated with Output Buffer Full. INTE 1 can be used to
enable or disable the interrupt by setting or resetting PC6 in the BSR Mode.
THANK YOU
LED INTERFACE AND
KEYBOARD INTERFACING
Light Emitting Diode(LED) interface
► Used to display limited data, results, events or messages
► Total no of character are fixed
► Used on front panel of instruments, digital clocks etc.,
► LED is diode when current passes emits light energy
► Anode held at higher voltage than cathode
Seven Segment LED

► LED s can be arranged in the format shown below


► a to g for numeric and alphanumeric
► h for decimal point

Seven segmental LED


DISPLAY INTERFACING
Types of Seven Segment Displays

► The following are the types of seven segments


Configurations.
(i) Common Anode (CA)
(ii) Common Cathode (CC)
Common Cathode Seven Segment Display

► In the common cathode display, all the cathode connections of the LED segments
are joined together to logic “0” or ground. The individual segments are illuminated
by application of a “HIGH”, or logic “1” signal via a current limiting resistor to
forward bias the individual Anode terminals (a-g).
Truth table of Cathode seven segment
display

Above truth table shows the data to be applied to the seven segments to display the digits. In
order to display digit‘0’ on seven segment , segments a , b , c , d , e and f are applied with logic
high and segment g is applied with logic low.
Microprocessor Interface to LED
(Common Cathode)
► LED can be directly interfaced with microprocessor through an output port as
shown below
Common Anode Seven Segment Display

► In the common anode display, all the anode connections of the LED segments are
joined together to logic “1”. The individual segments are illuminated by applying a
ground, logic “0” or “LOW” signal via a suitable current limiting resistor to the
Cathode of the particular segment (a-g).
Truth table of Anode seven segment
display

In order to display zero on this segment one should enable logic low on a, b, c, d,
e and f segments and logic high on segment ‘g’. Thus, the above table provides
data on seven segments for displaying numerals from 0-9.
Microprocessor Interface to LED
(Common Anode)

In common cathode configuration, when ever a bit is 1, the corresponding LED


will glow. In the case of common anode configuration, a 0 in any bit position
will make the corresponding LED glow.
Control byte for Seven segmental LEDs

► The ON/OFF info for eight segments can be arranged in one byte such as
► 76 5 4 3210
► for 0.
0 1 0 0 0 0 0 0
► h g f e dc ba
► for 3.
0 0 1 1 0 0 0 0
► for 5.

0 0 0 1 0 0 1 0

0 – glow
1 – not glow Control byte for Seven segmental LEDs
Microprocessor interface to Seven segmental
LEDs (parallel interface)

► Parallel interface Shown in fig


► All LEDs are held permanently at +5 V, and cathodes are connected to the
port bits.
► Microprocessor will load any bit pattern in the out port

Microprocessor interface to Seven segmental LEDs (parallel interface)


Disadvantages of parallel interface

► Disadvantages of parallel interface


► It requires extra hardware for interfacing
► Software is very simple
► Fast speed interface is not required because human eye due to its limitation cannot
perceive such fast changes.
► It requires extra ports.
Microprocessor interface to Seven segmental
LEDs (serial interface)
► Serial interface
► Over comes the disadvantages of the complex hardware

Microprocessor interface to Seven segmental LEDs (serial interface)


Seven segmental LEDs display interface to 8085 using 8255PPI
BCD to 7 Segment Decoder
Digit drive pattern

► Digit drive pattern of a seven segment LED


display is simply the different logic
combinations of its terminals “a to h” in
order to display different digits and
characters. The common digit drive
patterns (0 to 9) of a seven segment display
are shown in the table below.
Applications of Seven Segment Displays

• The applications of seven segments are mostly in


digital calculators, electronic meters, digital
clocks, odometers, digital clocks, clock radios,
etc.
• Today most of the 7 segment applications are
using LCDs, because of low current
consumption.
KEYBOARD INTERFACING
• Organized in a matrix of rows and columns. CPU access both rows and columns.
• With two 8 bit port, an 8 X 8 matrix of keys can be connected to a microprocessor.
• When key pressed – a row and a column make a contact.
• Rows – connected to output port and Columns – connected to input port.
• Getting meaningful data from a keyboard requires three major tasks:
Detect a Keypress
Debounce the Keypress
Encode the keypress – standard code for pressed key.
Logic 0 – read by microprocessor when the key is pressed.
1. Initially when no key is pressed,

(Column) Input Port = Connected to Vcc

P2.3 P2.2 P2.1 P2.0 P1.3 P1.2 P1.1 P1.0


Input port (Column) Output Port (Row)
1 1 1 1 0 0 0 0
2. When any key is pressed, Let us say red circled key.

P2.3 P2.2 P2.1 P2.0 P1.3 P1.2 P1.1 P1.0


Input port (Column) Output Port (Row)
0 1 1 1 0 0 0 0
Pressed key, Vcc connected to ground.
From the input result, Processor will find that some
column key is pressed, to find in which the key is pressed,
Microprocessor will make all rows to ‘1’ except one row and
make it as ‘0’, i.e. P1.3 P1.2 P1.1 P1.0
Output Port (Row)
1 1 1 0
P2.3 P2.2 P2.1 P2.0 P1.3 P1.2 P1.1 P1.0
Output zero to all rows
Input port (Column) Output Port (Row)
0 1 1 1 1 1 1 0 Is any
No key
Read Column
Pressed
P2.3 P2.2 P2.1 P2.0 P1.3 P1.2 P1.1 P1.0 ?
No
Input port (Column) Output Port (Row) All Ye
key
s
0 1 1 1 1 1 0 1 open? Output zero to 1 rows
Ye & 1 to other rows
P2.3 P2.2 P2.1 P2.0 P1.3 P1.2 P1.1 P1.0 s
Read Column
Input port (Column) Output Port (Row) Read Column
No
0 1 1 1 1 0 1 1 Is any
key No Key
P2.3 P2.2 P2.1 P2.0 P1.3 P1.2 P1.1 P1.0 Pressed found
? ?
Input port (Column) Output Port (Row) Ye
Ye Convert
0 1 1 1 0 1 1 1 s to
s
Wait for Hex
20ms
From the result, microprocessor will find that, the
zeroth row and third column is pressed. Return

Read Column
Basic Keyboard Operation –Single Key
Basic Keyboard Operation –Two Keys
Basic Keyboard Operation –Four Keys
2x2 Keyboard Operation
2x2 Keyboard Operation
Keyboard debouncing
Bouncing is the tendency of any two metal contacts in an electronic device to generate multiple signals as the
contacts close or open; debouncing is any kind of hardware device or software that ensures that only a single
signal will be acted upon for a single opening or closing of a contact.
1. Hardware debouncing
2. Software debouncing

Hardware debouncing circuit


THANK YOU
ADC and DAC INTERFACE
ADC INTERFACING

ADC- Convert analog signal into digital signal


Specifications of ADC
ADC Circuit of 8- bit length
ADC0808 Pin Diagram

Pin Number Pin Name Description


1 to 5, 27, 28 Analog Channel 1 to 5 These 7 pins are the input pins for Analog
voltage(sensor)
6 START This is an input pin which is made high to start
conversion
7 End of Conversion (EOC) This is an output pin which goes high once the
conversion is over
8,14,15,18,19,20,21 Output (2-1 to 2-7) Output digital pins which gives the result of the ADC
conversion
9 OUT EN Has to be made high to get output on output pins
10 CLOCK Has to be given clock signals (0V-5V) 20Mhz approx.
11 Vcc Powers the IC typically with 5V
12 V ref(+) Reference voltage pin, typically +5V is used normally
13 Ground Connect to ground of the circuit
16 Vref(-) Vref is connected to ground normally
22 Address Latch This pin is should be temporarily made high to select
Enable(ALE) ADC channel
23,24,25 ADD A, ADD B, ADD C These three pins are used to select the channel
Block Diagram of ADC 0808/0809
Interfacing ADC 0808 with 8085
Interfacing ADC 0808 with 8085

► ADC 0808 has eight input channels, so to select desired input channel, it is
necessary to send 3-bit address on ADC, ADB and ADA inputs. The address of
the desired channel is sent to the multiplexer address inputs through PB0 to
PB2 lines.
► After at least 50 ns, this address must be latched. This is achieved by sending
ALE signal using port line PB3. After another 2.5 μs the start of
conversion signal (SOC) must be sent high and then low. Port line PB4 is used
for this purpose.
► The end of conversion (EOC) is detected by port line PC0. It shows timing
wave forms for the ADC 0808. Schmitt-trigger inverter circuitry generates 300
kHz clock which is required to operate ADC 0808. The zener diode and LM 308
amplifier circuitry is used to produce a VCC and +VREF of 5.12 V for the A/D
converter. With this reference voltage the A/D converter will have 256 steps of
20 mV each.
Introduction to Digital to Analog
Converters (DAC)

► A Digital to Analog Converter commonly referred


as DAC, D/A or D2A is a device that converts binary
values (0s and 1s) to a set of continuous analog voltages.
► Types of DACs
(i) Summing Amplifier
(ii) R-2R Ladder
(iii) PWM DAC
DAC Circuit of 8- bit length
IC 1408 DAC Pin Diagram
Pin configuration
Pin Name Description
1 NC No connection
2 GND Ground
3 VEE Negative power supply
4 IO Output signal pin
5 A1 Digital input bit 1 (Most
Significant Bit)
6 A2 Digital input bit 2
7 A3 Digital input bit 3
8 A4 Digital input bit 4
9 A5 Digital input bit 5
10 A6 Digital input bit 6
11 A7 Digital input bit 7
12 A8 Digital input bit 8 (Least
Significant Bit)
13 VCC Positive power supply
14 VREF+ Positive reference voltage
15 VREF- Negative reference voltage
16 COMPENSATION Compensation capacitor pin
Block Diagram of DAC 1408
Typical circuit for IC 1408
Here, resistor RB (5 K) is connected between Vref and the output terminal of IC 1408
DAC Pin Diagram. This gives a constant current source of 1 mA. The output-current
range of a standard Bipolar DAC is generally between zero and 2 mA.
► The output current Io can be given as

Note : Input A1 through A8 can be either 0 or 1. Therefore, for typical circuit full scale current can be given
as,
► It shows that the full scale output current is always 1 LSB less than the reference
current source of 2 mA. This output current is converted into voltage by I to V
converter. The output voltage for full scale input can be given as
Important Electrical Characteristics for IC
1408
THANK YOU
STEPPER MOTOR
INTERFACING AND
TRAFFIC LIGHT CONTROL
INTERFACING
STEPPER MOTOR INTERFACING

• Stepper motor is a widely used device that translates electrical pulses into mechanical movement
• Stepper motors is used in applications such as disk drives, dot matrix printer, robotics, etc.,

Step angle
• Step angle is defined as the minimum degree of rotation with a single step.
• No. of steps per revolution = 360⁰ / step angle
• If step angle is 1.8⁰. So the number of steps per revolution = 360 / 1.8 = 200.
Stepper motor Excitation modes

► There are three commonly used excitation modes for stepper


motors
(i)Full step Excitation Mode
(ii) Half step Excitation Mode
(iii) Micro stepping Excitation Mode
These excitation modes have an effect on
both the running properties and torque the motor delivers.
Full Step Excitation Modes

► There are two types of full step excitation modes.


They are
(i) One-phase on - full step
(ii) Two-phase on - full step
One-phase on - full step Excitation Mode

► In one-phase on - full step, the motor is operated with only one phase energized
at a time. This mode requires the least amount of power from the driver of any
of the excitation modes.
Two-phase on - full step Excitation Mode

► In two-phase on - full step, the motor is operated with both phases energized at
the same time. This mode provides improved torque and speed performance.
Two-phase on provides about 30% to 40% more torque than one phase on,
however it requires twice as much power from the driver.
Half step Excitation Mode 

► Half step excitation mode is a combination of one phase on and two phase on
full step modes. This results in half the basic step angle. This smaller step
angle provides smoother operation due the increased resolution of the angle.
► Half step produces about 15% less torque than two phase on - full step,
however modified half stepping eliminates the torque decrease by increasing
the current applied to the motor when a single phase is energized.
STEPPER MOTOR INTERFACING
Step A B C D HEX Step A B C D HEX
1 1 0 0 1 09 1 1 0 0 0 08
2 1 1 0 0 0C 2 0 1 0 0 04
3 0 1 1 0 07 3 0 0 1 0 02
4 0 0 1 1 03 4 0 0 0 1 01
Full Step – Two Phase ON Full Step – One Phase ON

Step A B C D
1 1 0 0 1
2 1 0 0 0
3 1 1 0 0
4 0 1 0 0
5 0 1 1 0
6 0 0 1 0
7 0 0 1 1
8 0 0 0 1
Half Step
MOV A, #80 Move CWR value to Accumulator D7 D6 D5 D4 D3 D2 D1 D0 Hex
MOV DPTR, #4003 Move data pointer to Address 4003 1 0 0 0 0 0 0 0 80

MOVX @DPTR, A Move the data (CWR value) externally to PORT A 4000 9200 09H 92 00
operate in 8255 in simple I/O Mode.
4001 9201 0CH DPH DPL
START: MOV DPTR, Move data pointer to memory 9200 to access
#9200 the sequence 4002 9202 07H

MOV R1, DPL Move data pointer low Value 00 to register R1. DPTR 4003 9203 03H

MOV R2, DPH Move data pointer High Value 92 to register R2. 4004

MOV R0, #04 Number of sequence (09, 0C, 07, 03) 92 01


REP: MOVX A, @DPTR Move the value where the DPTR is present – DPH DPL
DPTR at 9200, value is 09.
MOV DPTR, #4000 Move DPTR to PORT A accessing address
MOVX @DPTR, A Moving externally the value 09 to stepper
motor.
LCALL DELAY Create delay to operate slowly
INC R1 Incrementing R1 register to load next value. DELAY: MOV R7, # 55 Move Value 55 to R7 register
MOV DPL, R1 Moving the value in R1 to DPL (01 to DPL) LOOP3: MOV R6, # 55 Move Value 55 to R6 register
MOV DPH, R2 Moving the value in R2 to DPH (92 to DPH) LOOP2: DJNZ R6, LOOP2 Decrement R6 by 1
DJNZ R0, REP Decrementing R0, from 4th value to 3rd value. DJNZ R7, LOOP3 Decrement R7 by 1
SJMP START Jumping to start point RET
Disadvantages of Stepper Motor

► Following are the drawbacks or Disadvantages of


Stepper Motor:

➨Noise and vibration


➨Resonance occurs if it is not properly controlled.
➨Progressive loss of torque at high speeds. Hence it is not
easy to operate at extremely high speeds.
➨ Low accuracy
➨ No Feedback to indicate missed steps.
Applications

1. Industrial Machines – Stepper motors are used in automotive gauges and


machine tooling automated production equipment.
2. Security – new surveillance products for the security industry.
3. Medical – Stepper motors are used inside medical scanners, samplers, and
also found inside digital dental photography, fluid pumps, respirators, and blood
analysis machinery.
4. Consumer Electronics – Stepper motors in cameras for automatic digital
camera focus and zoom functions.
TEMPERATURE CONTROL INTERFACING
• Sensors can be interfaced with microprocessor.
• Temperature sensor is interfaced with microcontroller.

Temperature Sensor
• Transducers convert physical data to electrical signals.
• Physical data are temperature, light intensity, flow, speed, etc.
• Depending on the transducers, the output is in various formats
• Voltage
• Current
• Resistance
• Capacitance
• Temperature is converted into electrical signal using a transducer called Thermistor.
• Widely used linear temperature sensors are LM34 and LM35 series from National Semiconductors.
Temperature Sensor Interfacing
LM34
• Output voltage is linearly to the Fahrenheit Temperature
• External calibration not required because it is internally calibrated
• Outputs 10mV for each degree of Fahrenheit temperature
LM35
• Output voltage is linearly to the Celsius Temperature
• External calibration not required because it is internally calibrated
• Outputs 10mV for each degree of Centigrade temperature
Signal Conditioning
• Signal conditioning is widely used in the data acquisition.
• The most 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 ADC. This
conversion is commonly called signal conditioning.
Sensor Data flow method

Analog world (Temperature, pressure, etc)

Transducers

Signal Conditioning

ADC

Microprocessor
Interfacing LM35 with 8255

• ADC 0808 will involve the interface between LM35 and 8255.
• The ADC 0848 has 8 bit resolution with a maximum of 256 steps and the LM35 or
LM34 produces 10 mV for every degree of temperature change.
• So Vin of the ADC 0808 must produce a Vout of 2.56 volt for full scale output.
• In order to produce the full scale output for ADC 0808, we need to set Vref=2.56V.

8085🡨🡨8255🡨🡨ADC🡨LM35
TRAFFIC LIGHT CONTROL INTERFACING
• PORT A is used to control
lights on N – S Road.
• PORT B is used to control
lights on E – W Road.
THANK YOU

You might also like