Professional Documents
Culture Documents
Unit 3
Unit 3
Unit 3
PROGRAMMABLE PERIPHERAL
INTERFACE
(8255)
Modes of Operation
1. I/O Mode
2. Bit Set – Reset mode (BSR)
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.
• 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
► 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)
► 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)
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
► 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)
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
► 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
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
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