You are on page 1of 60

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Reset Circuit Diagram

WATCH DOG TIMER BLOCK DIAGRAM


BLOCK DIAGRAM OF REAL TIME CLOCK
I/O Sub Systems
8051 Interfacing

Serial Communication Interface (RS232)

Serial communication means transfer data bit by bit serially at a time, where as in parallel
communication, the number of bits that can be transferred at a time depends upon the number of
data lines available for communication.

Two methods of serial communication are


1. Synchronous Communication: Transfer of bulk data in framed structure at a time
2. Asynchronous Communication: Transfer of a byte data in framed structure at a time
8051 has built in UART with RXD (serial data receive pin) and TXD (serial data transmit pin) on
PORT3.0 and PORT3.1 respectively.

Asynchronous communication: Asynchronous serial communication is widely used for byte


oriented transmission.

Frame structure in Asynchronous communication:


START bit: It is a bit with which serial communication start and it is always low.
Data bits packet: Data bits can be 5 to 9 bits packet. Normally we use 8 data bit packet, which is
always sent after START bit.
STOP bit: This is one or two bits. It is sent after data bits packet to indicate end of frame. Stop bit is
always logic high.
In asynchronous serial communication frame, first START bit followed by data byte and at last
STOP bit, forms a 10-bit frame. Sometimes last bit is also used as parity bit.

Interface standard

 8051 serial communication has TTL voltage level which are 0 v for logic 0 and 5 v for logic 1.
 In computers and most of the old devices for serial communication, RS232 protocol with
DB9 connector is used. RS232 serial communication has different voltage levels than 8051
serial communication. i.e. +3 v to +25 v for logic zero and -3 v to -25 v for logic 1.
 So to communicate with RS232 protocol, we need to use voltage level converter like
MAX232 IC.
 Although there are 9 pins in DB9 connector, we don’t need to use all the pins. Only 2nd
Tx(Transmit), 3rd Rx(Receive) and 5th GND pin needs to be connected.
 serial communication has different voltage levels than 8051 serial communication. i.e. +3 v
to +25 v for logic zero and -3 v to -25 v for logic 1.
 So to communicate with RS232 protocol, we need to use voltage level converter like
MAX232 IC.
 Although there are 9 pins in DB9 connector, we don’t need to use all the pins. Only 2nd
Tx(Transmit), 3rd Rx(Receive) and 5th GND pin needs to be connected.
Keypad & 7 Segment Display Interface

Keypad Interface:

Matrix Keypad

Matrix Keypads are commonly used in calculators, telephones etc where a number of input
switches are required. We know that matrix keypad is made by arranging push button switches in
row and columns. In the straight forward way to connect a 4×4 keypad (16 switches) to a
microcontroller we need 16 inputs pins. But by connecting switches in the following way we can
read the status of each switch using 8 pins of the microcontroller.

 The status of each keys can be determined by a process called Scanning. For the sake of
explanation lets assume that all the column pins (C1 – C4) are connected to the inputs pins
and all the row pins are connected to the output pins of the microcontroller. In the normal
case all the column pins are pulled up (HIGH state) by internal or external pull up resistors.
Now we can read the status of each switch through scanning.
 A logic LOW is given to R1 and others (R2 – R4) HIGH
 Now each Column is scanned. If any switch belongs to 1st row is pressed corresponding
column will pulled down (logic LOW) and we can detect the pressed key.
 This process is repeated for all rows.
 This article is about how to interface a seven segment LED display to an 8051
microcontroller.
 If you need to save more pins of your microcontroller then you can interface keypad using
the ADC module of your microcontroller
7 Segment Display:

 7 segment LED display is very popular and it can display digits from 0 to 9 and quite a few
characters like A, b, C, ., H, E, e, F, n, o,t,u,y, etc. Knowledge about how to interface a seven
segment display to a micro controller is very essential in designing embedded systems.
 A seven segment display consists of seven LEDs arranged in the form of a
squarish ‘8’ slightly inclined to the right and a single LED as the dot character.
 Seven segment displays are of two types, common cathode and common anode.
 In common cathode type , the cathode of all LEDs are tied together to a single terminal which
is usually labeled as ‘com‘ Â and the anode of all LEDs are left alone as individual pins
labeled as a, b, c, d, e, f, g & Â h (or dot) .

 In common anode type, the anode of all LEDs are tied together as a single terminal and
cathodes are left alone as individual pins. The pin out scheme and picture of a typical 7
segment LED display is shown in the image above.
 The circuit diagram shown above is of an AT89S51 microcontroller based 0 to 9 counter
which has a 7 segment LED display interfaced to it in order to display the count.
 This simple circuit illustrates two things. How to setup simple 0 to 9 up counter using 8051
and more importantly how to interface a seven segment LED display to 8051 in order to
display a particular result.
 The common cathode seven segment display D1 is connected to the Port 1 of the
microcontroller (AT89S51) as shown in the circuit diagram. R3 to R10 are current limiting
resistors.
 S3 is the reset switch and R2,C3 forms a de bouncing circuitry.
 C1, C2 and X1 are related to the clock circuit. The software part of the project has to do the
following tasks.
 Form a 0 to 9 counter with a predetermined delay (around 1/2 second here).
 Convert the current count into digit drive pattern.
 Put the current digit drive pattern into a port for displaying.
LCD Interfacing
LCD DISPLAY:

LCD Initialization

 For initializing the LCD display, the following are the steps which are given below and
these steps are same for almost all the applications.
 Send 38H to the 8-bit data line for initialization
 Send 0FH for making LCD ON, cursor ON, cursor blinking ON
 Send 06H for incrementing cursor position
 Send 01H for clearing the display and return the cursor
 Sending Data to the LCD
 The following are the steps for sending the data the LCD module which is given below.
The logic state of these pins that make the module to determine whether a given data
input is a data or command to be displayed.
 Make R/W low
 Make RS=1, if the data byte is a data to be displayed and make
 RS=0, if data byte is a command.
 Place data byte on the data register
 Then pulse E from high to low

Repeat above steps for sending other data

Circuit Diagram of LCD interfacing of 8051 Microcontroller

 The circuit diagram of Interfacing 16×2 LCD module with AT89S51 Microcontroller is as
shown below.
 Resistor R3, Capacitor C3 and push button switch S1 will form the reset circuitry.
 Crystal X1 and ceramic capacitors C1, C2 is related to the clock circuitry which will produce
the system clock frequency.
 P1.0 to P1.7 pins of the microcontroller is connected to the module DB0 to DB7 pins
respectively, this route the data which go to the LCD module.
 P3.3, P3.3 and P3.5 connect to the E, R/W, RS pins of microcontroller and this route the
control signals which are transferred to the LCD module.
 R1 resistor limits the current through the LED backlight and the backlight intensity.
 POT R2 is used for adjusting the contrast of the display.
Stepper Motor Interfacing

A stepper motor is an electro mechanical device which generates discrete displacement


(motion) in response to DC electric signals. It differs from normal DC motor in its operation. The DC
motor produces continuation rotation on applying DC voltage whereas a stepper motor produces
discrete rotation in response to the DC voltage applied to it.

Stepper motors widely used in embedded system applications, Consumer electronics like some disk
drives, dot matrix printers and robotic control systems. Paper feeding mechanism of a printer
makes use of stepper motor for its functioning.

The main advantage of using the stepper motor is the position control. Stepper motors generally
have a permanent magnet shaft (rotor), and it is surrounded by a stator.

Based on the coil winding arrangements, a 2 phase stepper motor is classified into Two. They are

1. Unipolar 2. Bipolar

Unipolar: A Unipolar stepper motor contains 2 windings per phase. The direction of rotation
(Clock wise / anti clock wise) of a stepper motor is controlled by changing the direction of current
flow. Current in one direction flows through one coil and in opposite direction flows through other
coil. It is easy to shift direction of rotation by switching the terminals to which coils are connected.

Bipolar: A bipolar stepper motor contains single winding per phase. For reversing the motor
rotation the current flow through the windings is reversed dynamically. It requires complex
circuitry for current flow reversal.
Interfacing Stepper Motor with 8051 Microcontroller

We are using Port P0 of 8051 for connecting the stepper motor. HereULN2003 is used. This is
basically a high voltage, high current Darlington transistor array. Each ULN2003 has seven NPN
Darlington pairs. It can provide high voltage output with common cathode clamp diodes for
switching inductive loads.

The Unipolar stepper motor works in three modes.

 Wave Drive Mode: In this mode, one coil is energized at a time. So all four coils are energized
one after another. This mode produces less torque than full step drive mode.

The following table is showing the sequence of input states in different windings.

Steps Winding A Winding B Winding C Winding D

1 1 0 0 0

2 0 1 0 0

3 0 0 1 0

4 0 0 0 1

 Full Drive Mode: In this mode, two coils are energized at the same time. This mode produces
more torque. Here the power consumption is also high

The following table is showing the sequence of input states in different windings.

Steps Winding A Winding B Winding C Winding D

1 1 1 0 0

2 0 1 1 0

3 0 0 1 1

4 1 0 0 1
 Half Drive Mode: In this mode, one and two coils are energized alternately. At first, one coil is
energized then two coils are energized. This is basically a combination of wave and full drive
mode. It increases the angular rotation of the motor

The following table is showing the sequence of input states in different windings.

Steps Winding A Winding B Winding C Winding D

1 1 0 0 0

2 1 1 0 0

3 0 1 0 0

4 0 1 1 0

5 0 0 1 0

6 0 0 1 1

7 0 0 0 1

8 1 0 0 1

Two phase unipolar stepper motors are the popular choice for embedded applications. The
current requirement for stepper motor is little high and hence the port pins of micro controller not
able to drive them directly. Also supply voltage required to operate stepper motor varies in the
range 5V to 24V. Depending on the current and voltage requirements, Special driving circuits are
required to interface stepper motor with the micro controller.
 Resistor R3, Capacitor C3 and push button switch S1 will form the reset circuitry.
 Crystal X1 and ceramic capacitors C1, C2 is related to the clock circuitry which will produce
the system clock frequency
8255 Interfacing (PPI)
BSR MODE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

You might also like