EE313 Lab 2
EE313 Lab 2
GROUP NAME
Roaia Roota – S11080735
Carlos Babu – S11147301
AIM:
Design lookup table (array) of equivalent code in hex to display number from 0 to 9.
(Take reference LED segment type Common Cathode)
Write a C program and compile generate hex file for PIC18F8722
Display number 0 to 9 in a loop with delay of say 1 sec
Add more code to use KEY input. If a key is pressed the number will be incremented.
INTRODUCTION
Microprocessor know as an electronic device that can perform an arithmetic and logical
operation such as adding, subtracting, transferring numbers, and comparing 2 numbers or more.
Microprocessor can be found in small device such as smart watch up to big electronic devices
included supercomputers [1]. The experiment going to focused on one of the applications of
microprocessor using a microcontroller (PIC18F8722). Firstly, it going to program the
microprocessor (PIC8F8722), using a PIC C language to do the courting from 0 to nine, and
then display it on the 7-segment display. Secondly, it will be used key input to count from 0 to
nine using the same program with small changed to it. This experiment can be integrated with
many applications that a very useful in our daily basis such as digital clock, timer and many
more.
EQUIPMENT
PIC18F8722
DC Power Supply
7- Segment LED common cathode or anode type
MEHODOLOGY
Before starting the experiment, all required component need to connected according to the
PIC18F22 manual setup. To setup microcontroller these steps are followed:
Connect the ICD to the microcontroller using the Modular cable. ICD has to connect to
the PC by a USB cable for ICD.
Microcontroller has to powered by a 9v dc power supply
Check the LED light on the ICD is brightly illuminate (indicate that is connected)
If not, the ICD not connected probably and cannot detected by the PC.
It recommended to check all the connection are secure if so, the ICD need to replace
(ICD 40, ICD60)
If it all satisfy, run ICD program from the PC and run test the Dialog box of ICD will
appear
To setup a 7-segment display, the ground (port G) from the microcontroller has to
connect to common ground of 7 segment display.
The 7-segment display LED connect to Microcontroller port as followed
o F0 to a, F1 to b, F2 to c, F3 to d, F4 to e, F5 to f, F6 to g, and F7 to h.
RESULTS
Task 1: Display Number 0 to 9 with a delay of 1 Second
Figure 2.0 Shows the sniped code of display number 0 to 9 with the delay of 1 second.
Figure 2.1 Displays the output obtain from the code in figure 1.0.
Figure 2.2 Illustrate the modified code from figure 1.0. It defines the input KEY in order to
increment by 1.
A. B.
Figure 1.3. Displays the output of the code from figure 1.2.
DISCUSSION
The experiment contains two task as shown in the result section. The main objective was to
write a code in PIC C compiler to generate hex file for PIC18F8722 to display digits 0 to 9 in
seven segment LED. Task 1 requires to write a program that design lookup table array that
display digits (0 to 9) with delay of 1 second. As shown in Figure 1.0 was the sniped simple
program in PIC C compiler. The first 4 lines code represent the header file and comes the main
program where the array of hex code for common cathode type are declared before the ‘while
loop’. The while loop keeps the display continued with the delay of 1 second for the condition
“for (t = 0; t<10; t++)” is true. This is how the digits (0 to 9) continued to displayed, non-stop
In Figure 1.2 shows the result obtain from the task 2. This task requires to modified the code
in task 1 and displays 7 segment LED with control by KEY input to increment 1. Figure 1.3
shows output as the key was entered from the KEYBORD which the digit increases from 6 to
7.
CONCLUSION
The experiment went as expected, it managed to build a circuit for a 7-segment display, and
used a microcontroller as its main driver for the display. For the code generated and compile
in the c language the experiment was successfully.
References