Embedded Systems Lab Lab 2 Seven segments Applications

advertisement
Embedded Systems Lab
Lab 2
Seven segments Applications
Eng. Dalia A. Awad
Objectives
To get familiar with interfacing 7-Seg display to PIC18F4550.
Tools
PIC18F4550 Microcontroller, MPLAB software, 7-seg display.
Theory
Delay Loops
The principle of the delay is that we count down from a previously set number, and when it reaches
zero, we stop counting. The zero value indicates the end of the delay, and we continue on our way
through the program. The largest number we can have is 255 or FF h in hex.
Example
DELAY
LOOP
MOVLW .10
MOVWF count
NOP
DECFSZ count
GOTO LOOP
1
1
1*10
1*9 + 2
2*9
Total delay = (1+1+1*10+2*9+1*9+2) cycle= 41 cycle
•
1 pulse → 1 MHZ ( Instruction Frequency)
Instruction period = 1 /f = 1/ 1MHz = 1 μsec
•
Total delay = 41 * 1 μsec = 41 μsec
Seven Segment Display
Seven-segment displays are commonly used in electronics as a method of displaying decimal
numeric feedback on the internal operations of devices. A seven segment display, as its name
indicates, is composed of seven elements. Individually on or off, they can be combined to
produce simplified representations of the Hindu-Arabic numerals. Each of the numbers 0, 6, 7
and 9 may be represented by two or more different glyphs on seven-segment displays.
The seven segments are arranged as a rectangle of two vertical segments on each side with one
horizontal segment on the top and bottom. Additionally, the seventh segment bisects the
rectangle horizontally. Often the seven segments are arranged in an oblique, or italic,
arrangement, which aids readability.
The segments of a 7-segment display are referred to by the letters A to G, as follows:
Where the optional DP decimal point (an "eighth segment") is used for the display of non integer
numbers.
Seven segment displays can be divided into 2 types of connection. One is called common anode of
which all the anodes of the LEDs are connected together, leaving the cathodes open for connection.
The other one is called common cathode of which all the cathodes of the LEDs are connected
together, leaving the anodes open for connection.
Multiplexing
The simplest way to drive a display is via a display driver. These are available for up to 4 displays.
Alternatively displays can be driven by a microcontroller and if more than one display is required, the
method of driving them is called "multiplexing."
The main difference between the two methods is the number of "drive lines." A special driver may need
only a single "clock" line and the driver chip will access all the segments and increment the display.
If a single display is to be driven from a microcontroller, 7 lines will be needed plus one for the decimal
point. For each additional display, only one extra line is needed. To produce a 4, 5 or 6 digit display, all
the 7-segment displays are connected in parallel. The common line (the common-cathode line) is taken
out separately and this line is taken low for a short period of time to turn on the display. Each display is
turned on at a rate above 100 times per second, and it will appear that all the displays are turned on at
the same time. As each display is turned on, the appropriate information must be delivered to it so that it
will give the correct reading. Up to 6 displays can be accessed like this without the brightness of each
display being affected. Each display is turned on very hard for one-sixth the time and the POV
(persistence of vision) of our eye thinks the display is turned on the whole time.
Lab Exercises:
Part 1
1. Connect the circuit shown in the Figure_1 below on Proteus ISIS program.
2. Write an assembly program that display 5 on the 7-seg.
3. Load the(.hex) file to PIC18f4550 microcontroller.
4. Simulate the circuit using Proteus ISIS program.
Part 2
1. Write an assembly program that counts form 0-9 and displays the digits on the 7-seg
2. Load the(.hex) file to PIC18f4550 microcontroller.
3. Simulate the circuit using Proteus ISIS program.
Part 3
4. Write an assembly program that displays 46 on two 7-seg using multiplexing techniques.
5. Load the(.hex) file to PIC18f4550 microcontroller.
6. Simulate the circuit using Proteus ISIS program.
Best Wishes… Dalia
Download