0% found this document useful (0 votes)
20 views21 pages

MC Unit-5

Uploaded by

tawexab191
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views21 pages

MC Unit-5

Uploaded by

tawexab191
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Interfacing of 8051 with 8255 (PPI)

Interfacing 8255Programmable Peripheral Interface(PPI) with8051

Why do we need additional pins when we have Ports on the 8051 already?

 For some applications, it is always recommended to use 8255 PPI to


avoid data loss and damage to the microcontroller.
 The 8051 has four ports: Out of four ports- Port 0, Port 2, Port 3– all
these ports have alternate functions.
 But Port 1, this is the only port with no alternate functions. This is the
reason why we need to interface 8255 to provide an additional three
ports, namely Port A, Port B, and Port C. and the best part about the 8255
is that it is programmable.

Components Required

1. 8051Microcontroller.
2. 8255 Programmable Peripheral Interface
3. Decoder circuit–74LS373 (for address demultiplexing)
4. NAND gate IC–74LS00
5. NOT gate IC–74LS04

Chip Select Logic

For a microcontroller to interface with 8255, a LOW pulse is given to the Chip
Select pin of 8255 as it is an active low pin

The address to the ports of 8255 PPI are


Port A: 00100000(20H)
Port B: 00100001(21H)
Port C: 00100010(22H)
Control port: 00100011(23H)
In 8255 two address pins – A0 and A1, are select different ports of 8255.
we can design a combinational logic circuit using a NAND gate
forwhichtheinputwillbeA2–A7address lines and CS’as the output.

The output of the NAND gate is LOW. When ALL the inputs are HIGH.
Therefore, from the address allocations that we have done,
A7=0,A6=0,A5=1,A4=0,A3=0,A2=0

Algorithm of Assembly Language programfor Interfacing 8255 with 8051

Step1:Constructthecontrolwordregister

D7=1, this will make all the ports of 8255 PPI are in the I/O mode.
D6 = D5 =D2= 0: selects mode 0 for Port A, Port B, and Port C.
D4= D1= 1: To select Port A and Port B as input ports.
D3=D0=0: To select both lower and upper Port C as output port.

Step 2: Input the data from Port A and Port B

Step 3: Add the contents of port A and port B

Step4: Display the result in port C


Block Diagram to interface 8255 PPI with 8051

Connections for interfacing 8255 with 8051:.


 First of all, we need supply power to both 8085 and 8255 by connecting VCC and
GND pins to the appropriate sources..
 RD* and WD* pins of 8051 are connected to the RD* and WD* pins of 8255,
respectively.
 Pins AD0-AD7 have dual functionality. They act as both; address bus and data
bus. This is achieved by multiplexing.
 To extract address, we need to demultiplex AD0-AD7 , which is done using the
IC 74LS373.
 After demultiplexing, pins A0 and A1 (from the output of IC74LS373) are
connected to the pins A0 and A1 of 8255, respectively. These two pins tell 8255
about which port the is talking about.
 A2-A7 are used to make chip select (CS) of 8255.
 Data D0 - D7 connected to microcontroller pins P0.0 - P0.7
 8255 has three ports Port A ,Port B and Port C (PC upper & PC lower)
AssemblyLanguageProgramtointerface8255with8051

PORTA EQU 0020H


PORTB EQU 0021H
PORTC EQU 0022H
CNTPORT EQU 0023H

ORG 0000H
MOV A,#92H
MOV DPTR,#CNTPORT
MOVX @DPTR,A
MOV DPTR,#PORTA
MOVX A,@DPTR
MOV R0,A
MOV DPTR,#PORTB
MOVX A,@DPTR
MOV R1,A
MOV A,R0
ADD A,R1;
MOV DPTR,#PORTC
MOVX @DPTR,A
END
Note:For Reference
INTERFACING OF LM35 TEMPERATURE SENSOR WITH 8051

The main principle of this circuit is to take the analog temperature values,
convert into digital values and displays the digital temperature value on LCD or
7-Segment Display using 8051MC.

• A temperature sensor (LM35) is interfaced to the 8051 via an ADC


(ADC0804)
• The LM35 IC generates a 10mV variation to its output voltage for every
degree Celsius change in temperature. (Scale factor 10mv/10 C)
• The Output of the temperature sensor is analog in nature so we need an
A/D converter for converting the analog input to its equivalent binary output.
• The IC ADC 0804 converts the measured temperature output voltages from
the LM35 into digital signals then handled by the 8051.
• The ADC 0804 is the analog to digital converter.
• After the INTR has become low, send a High-to-Low pulse (H-L Pulse) to the

RD pin to get the data out of the ADC 0804 IC chip.

• Here ADC0804 is connected to port1 of 8051.

• RD,WR and INTR of ADC is connected to P2.5, P2.6 and P2.7 respectively.

• Analog input is applied to Vin of ADC.

• Here WR is for the start of conversion and INTR is for the end of conversion.
Interfacing DAC with 8051
• Microcontroller are used in wide variety of applications like for
measuring and control of physical quantity like temperature,
pressure, speed, distance, etc.

• The Digital to Analog Convertor (DAC) is a device widely used to


convert digital data to analog signals.

• IC DACO808 is Digital to Analog convertor is 8-Bit IC which is


used to interface with 8051 controller.

• In these systems Microcontroller generates output which is in digital


form.

• But the controlling system requires analog signal as they don't


accept digital data.
• Thus it necessary to use DAC which converts digital data into
equivalent analog voltage.

• This IC DAC0808 converts digital data into equivalent analog


Current. Hence we require an I to V converter to convert this
current into equivalent voltage.
• The two methods of creating a DAC is Binary weighted and R/2R
ladder network.
• The interfacing circuit can generate -the triangular wave and square
wave.
Block Diagram of Interfacing 8051 with DAC
Stepper Motor Interfacing with 8051

What is a stepper motor?


• A motor is a device that converts electrical energy into
mechanical energy.
• A stepper motor is a device that rotates the motor in steps.
• It can divide a complete rotation into a number of steps.
• A stepper motor rotates at small angles to complete 360 degrees
rotation, these small angles are called steps, hence the name Stepper
Motor.

• Typically, a stepper motor consists of 200steps.

200 Steps = 360 degrees

1 Step = ‘x’ degrees

x = 360/200 = 1.8 degree

• Therefore, every step is 1.8 degrees.


• In the case of an 8-steps rotor, the step angle is 360/8 = 45 degrees.

Applications of stepper motor :

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


machines, grinder etc
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
stepper motor :

Stator: The stator is the stationary part which provides the magnetic field to rotate
the rotor. The stator is made up of coils that are energized by the pulses

Rotor: The rotor is the non-stationary part of a motor, the steps of the rotor and
alignment with the stator determines the step angle and steps per revolution.
Permanent magnets: The rotor is mounted on a permanent magnet that attracts
or repels the stator coils and hence the propulsion occurs.

Working of a stepper motor

• A stepper motor works on the principle of magnetic attraction


and repulsion.
• The coils of stators are energized and de-energized by the pulses of the
microcontroller which creates magnetic north and south on the stator
poles.
• The rotor is mounted on a permanent magnet having a permanent N and
S marked.
• The sequence in which the coils are excited to form the poles
causes attraction and repulsion causing motion in the shaft and the
load connected to it.
Steps A B C D HEX
1 1 0 0 0 08
2 0 1 0 0 04
3 0 0 1 0 02
4 0 0 0 1 01
Interfacing stepper motor to 8051 Microcontroller

Components required for interfacing a Stepper motor with 8051 Microcontroller


• 8051 Microcontroller
• Stepper Motor
• Current Driver IC (ULN2003)

Diagram show the interfacing of stepper motor with 8051 microcontroller, using
Port 2 of 8051 to generate pulses and port 2 is connected to a current amplifier IC
ULN2003, to amplify the current to drive the stepper motor using the pulse of the
microcontroller.
Block diagram of interfacing of stepper motor with 8051:

 Connect the 4 pins of Port2 to the input side of ULN 2003 IC as


follows
 Connect the outputs of the ULN2003 to the 4 wires of the stepper
motor
 Connect the two common wires of the stepper motor to IC ULN2003
to 12V DC supply.
Assembly language program to interface stepper motor with 8051

ORG 00H
MOV TMOD, #01H
MAIN: MOV P2, #08H
ACALL DELAY
MOV P2, #04H
ACALL DELAY
MOV P2, #02H
ACALL DELAY
MOV P2, #01H
ACALL DELAY
SJMP MAIN

Delay Program:

DELAY: MOV R0, #200


BACK: MOV TH0, #0FCH
MOV TL0, #018H
SETB TR0
WAIT: JNB TF0, WAIT
CLR TR0
CLR TF0
DJNZ R0, BACK
RET
END

You might also like