Lab 6 - SSD

You might also like

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

EXPERIMENT 06

INTERFACING SEVEN SEGMENT DISPLAY (SSD) TO


MICROCONTROLLER
OBJECTIVE:
1. Displaying data sent on the output port on seven segment display

2. Getting introduced to lookup table

3. Implementing up/down counter from 0-9

EQUIPMENT:
HARDWARE:
• 89c51 microcontroller

• Seven segment displays (SSDs)

• Resistances

SOFTWARE:
• Keil u-vision

• Smart-pro 5000u

DISCUSSION:
ADDRESSING MODES:

1) IMMEDIATE ADDRESSING:
In this addressing mode the source operand is a constant. in immediate addressing mode, as the
name implies, when the instruction is assembled, the operand comes immediately after the
opcode. Notice that the data in this instruction must be preceded by pound sign. For example:

MOV A,#25h
2) REGISTER ADDRESSING MODE:
Register addressing mode involves registers to hold the operands or data to be manipulated. For
example:

MOV A,R0

MOV R2,A

Limitation: the movement of data between Rn registers is invalid for example:

MOV R4,R7 is invalid.

3) DIRECT ADDRESSING MODE:


In the direct addressing mode, the data is in a RAM memory location whose address is known,
and this address is given as a part of instruction. Contrast this with the immediate addressing
mode in which the operand is provided itself with the instruction. The “#” sign distinguishes
between the two modes. Examples are:

MOV R0,40h

MOV R4,7Fh

4) REGISTER INDIRECT ADDRESSING MODE:


In the register indirect addressing mode, a register is used as a pointer to the data. Only R0 and
R1 are used as pointer. When R0 and R1 are used as a pointer, that is when they hold the address
of RAM location, they must be preceded by “@” sign as shown below:

MOV A,@R0 ; move contents of RAM location whose address is held by R0 into A

5) INDEXED ADDRESSING MODES:


Indexed addressing mode is widely used in accessing the data elements of the look-up table
entries located in the program ROM space of 8051. The instruction used for this purpose is
“MOVC A, @A+DPTR “. The 16-bit DPTR and A register are used to form the address of entry
in lookup table. In the instruction MOVC C means code so this instruction means move code. In
this instruction the contents of A are added to the 16-bit DPTR form the 16bit address of
required data.

LOOKUP TABLE:
Lookup Table is just like a memory. We design a lookup table of our desired values which can
be accessed by data pointer. It’s just like an array which can save bytes. It is a very useful
method in many implementations of many applications i.e. you can save many quantization
points to represent a sin wave and you can send them one by one to any port and interfacing a
digital to analog converter with that port will change these levels to their analog equivalent levels
producing a sin wave.

SEVEN SEGMENE DISPLAYS:


INTRODUCTION
For the seven segment display you can use the LT-541 or LSD5061-11 chip. Each of the
segments of the display is connected to a pin on the 8051 (the schematic shows how to do this).
In order to light up a segment one the pin must be set to 0V. To turn a segment off the
corresponding pin must be set to 5V. This is simply done by setting the pins on the 8051 to '1' or
'0'.

LED displays are

1. Power-hungry (10ma per LED)

2. Pin-hungry (8 pins per 7-seg display)

But they are cheaper than LCD display

7-SEG Display is available in two types:

1. Common cathode

2. Common anode

1. The Common Cathode (CC) – 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).
2. The Common Anode (CA) – 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).

But common anode display are most suitable for interfacing with 8051 since 8051 port pins can
sink current better than sourcing it.

Example of Common Anode SSD

DIGIT H G F E D C B A

0 1 1 0 0 0 0 0 0

1 1 1 1 1 1 0 0 1

2 1 0 1 0 0 1 0 0
You can connect the segment pins as follows:

Segment number 8051 PIN

A P1.0

B P1.1

C P1.2

D P1.3

E P1.4

F P1.5

G P1.6

H P1.7

• Cathode pins should be connected through resisters to limit current

• Anode is tied to 5V source


EXAMPLE: The given example is a complete code to generate a count from 0 to 9, and also
you are provided with the sequences used to generate the numbers from 0 to 9 on SSD using
common anode SSD.

org 00h table1: db 11000000b

mov dptr,#table1 db 11111001b

main: db 10100100b

mov r1,#0 db 10110000b

loop1: db 10011001b

mov a,r1 db 10010010b

movc a,@a+dptr db 10000010b

mov p1,a db 11111000b

inc r1 db 10000000b

call delay db 10010000b

cjne r1,#10,loop1 end

jmp main

delay:

mov r6,#200

dl1:

mov r7,#249

djnz r7,$

djnz r6,dl1

ret
org 000h table: db 11000000b

mov dptr,#table db 11111001b

mov r1,#10 db 10100100b

next: db 10110000b

mov a,#0 db 10011001b

movc a,@a+dptr db 10010010b

mov p2,a db 10000010b

call delay db 11111000b

call delay db 10000000b

inc dptr db 10010000b

djnz r1,next end

delay:

mov r6,#200

dl1:

mov r7,#249

djnz r7,$

djnz r6,dl1

ret

PROCEDURE:

• Use port 2 to implement a single digit counter and connect it from LSB to MSB in a
sequence starting from segment a to segment h
• The segment h means dot should be permanently off
• The sequences used should be according to connections made.
EXERCISES:
Write codes for following exercises

1. Counter from 0-9 or Counter from 9-0

Before writing the code first you have to verify either the SSD you are using is common
anode or common cathode

• Write the codes for each exercise in software and generate the hex file for each code

• Implement the circuit by interfacing SSDs to microcontroller

• Verify the output for each code

2. Show the hexadecimal numbers from 0 to F using seven segment display.

3. Write a program to display numeric from 0-9 by using direct addressing mode method.

You might also like