Digital Systems III Practical Manual - Ver1.2
Digital Systems III Practical Manual - Ver1.2
By
Mr. W.M. Ndlovu & Mr. N. Mngomezulu
Digital Systems III PRACTICAL MANUAL
Copyright © WM.Ndlovu, N.Mngomezulu. All rights reserved
The student is encouraged to read the text book and additional text given in the study
guide for more details in the topics covered in this document.
PLEASE NOTE:
It is compulsory that all codes are to be typed on a computer program called
‘Notepad’ or ‘Notepad++’ and must be saved on USB memory stick before
attending any lab session!!
It is compulsory that a student brings his/her own power supply when attending any
lab session!!
In The Lab:
The student will be introduced to how the PIC Microcontroller work, how are they
interfaced with peripheral components and programming using C18 and MPASM
compilers.
Practical experiments will be covered in the lab and a student MUST attend one lab
session per week.
Lab Objectives:
The student must be able to apply embedded C language and Assembly language
programming on the practicals.
The student must be able to create, edit and build projects using MPLAB X IDE.
The student must be able to use C18 & MPASM Compilers to instruct a PIC
Microcontroller to perform a certain task.
The student must be able to build and simulate the circuit on Proteus simulation software.
The student must be able to interpret datasheets and components applications.
The student must be able to do a hands-on type of work, building circuits using PICkit 3
Programmer & real components.
The student must be able to understand the application of the practical & components.
1. Window Menu.
Click on Window –
Projects, to view existing
projects.
Click – Desktop (on the left hand icons), select the folder you created earlier.
File Name: type the same project name WITHOUT SPACES. Make sure that the
“Extension” is C for C language is selected. Click – Finish.
3.Error type.
The error is caused by an
instruction typed wrong.
Locate an underlined blue sentence with the word “Error” and Click on it.
4.Error identification.
The cursor blinks on “line 11” of the “example01.c” file. Error is
caused by line 9, “TRISC=0x0F” line without “;” at the end.
2.Error location.
Error is on “line 22” of the
“assembly011.asm” source file.
3.Error type.
The error is caused by an
instruction typed wrong.
Locate an underlined blue sentence with the word “Error” and Click on it.
4.Error identification.
The cursor blinks on “line 22” of the “assembly011.asm” file.
Error is caused by “TRIC” which is supposed to be TRISC.
After correcting all the errors, click on “Clean and Build” icon again.
5.Debug.
Click Pause icon. This compiles, build a source code
and simulate the project on MPLAB X.
For C Language
For Assembly
R1
10k U1
13 15
OSC1/CLKI RC0/T1OSO/T1CKI ?
1 16
MCLR/VPP RC1/T1OSI ?
17
RC2/CCP1 ?
2 18
1
RA0/AN0/CVREF RC3/SCK/SCL ?
3 23
C1 RA1/AN1 RC4/SDI/SDA ?
22pF
X1 4
RA2/AN2/VREF- RC5/SDO
24
?
CRYSTAL 5 25
RA3/AN3/VREF+ RC6/TX/CK ?
FREQ=4MHz 6 26
RA4/T0CKI RC7/RX/DT ?
2
7
RA5/AN4/SS/LVDIN
14 19
RA6/OSC2/CLKO RD0/PSP0/C1IN+
20
C2 RD1/PSP1/C1IN-
33 21
22pF RB0/INT0 RD2/PSP2/C2IN+
34 22
RB1/INT1 RD3/PSP3/C2IN-
35 27
RB2/INT2/CANTX RD4/PSP4/ECCP1/P1A
36 28
RB3/CANRX RD5/PSP5/P1B
37 29
RB4 RD6/PSP6/P1C
38 30
RB5/PGM RD7/PSP7/P1D
39
RB6/PGC
40 8
RB7/PGD RE0/RD/AN5
9
RE1/WR/C1OUT/AN6
10
RE2/CS/C2OUT/AN7
R9 R8 R7 R6 R5 R4 R3 R2 PIC18F458
330 330 330 330 330 330 330 330 CLOCK=4MHz
D8 D7 D6 D5 D4 D3 D2 D1
After connecting the circuit, RUN the simulation. Observe the operation of the circuit.
Digital Systems III, Practical Manual 13
LAB 3 HARDWARE & TOOLS
Learning Objectives:
After completing the chapter, you must be able:
To know how to connect and use PICkit 3 programmer.
To build and transfer a “hex” file generated from MPLAB X into the actual I.C.
To connect and test the project on the breadboard.
To correctly connect the microcontroller pins on a breadboard.
EQUIPMENT
Tools Components
5V Power supply 1 x PIC18F458 microcontroller
1 x Side Cutter 1 x 4MHz Crystal
1 x Pliers 2 x 22pF Capacitors
5 x Male to Male Jumper wires or 1 x 10kΩ Resistor
Breadboard wires 8 x LEDs
Breadboard 8 x 220-470Ω Resistors
Digital Multimeter
PICkit 3 Programmer/Debugger
PIC18F458 Datasheet
USB MEMORY STICK!!
Click on the serial number of the PICkit3 you are using. This is to change MPLAB X from
using Simulator to use the PICkit3 programmer. Click – Apply – OK.
3.3.2. Troubleshooting.
If you see “Target Device ID (0x0)” error, Click Cancel.
EQUIPMENT
Tools Components
5V Power supply 1 x PIC18F458 microcontroller
1 x Side Cutter 1 x 4MHz Crystal
1 x Pliers 2 x 22pF Capacitors
5 x Male to Male Jumper wires 1 x 10kΩ Resistor
Breadboard 8 x LEDs
Breadboard wires 8 x 220-470Ω Resistors
Digital Multimeter
PICkit 3 Programmer/Debugger
PIC18F458 Datasheet
USB MEMORY STICK!!
RB0
MCLR 470
10k RB1
470
RB2
PIC18F458
Vdd 470
Vss RB3
470
RB4
470
RB5
470
RB6
470
RB7
470
OSC1 OSC2
4MHz
22pF 22pF
Figure 1
In the Lab:
2. Connect the circuit and all required pins on the breadboard. Connect 8 LEDs on
PORTB pins.
3. Apply steps from LAB 1.
4. Open Pre-prac saved on Notepad. Copy the code and Paste it in the Source file on
MPLAB X.
5. Compile and troubleshoot if necessary.
6. Apply steps from LAB 2 and simulate the circuit.
7. Apply steps from LAB 3. Use a multimeter to measure the voltage of your power
supply before using it.
8. Edit the code to use different ports and repeat steps 5-7.
You must be able to explain all the processes and what the code does.
EQUIPMENT
Tools Components
5V Power supply 1 x PIC18F458 microcontroller
1 x Side Cutter 1 x 4MHz Crystal
1 x Pliers 2 x 22pF Capacitors
5 x Male to Male Jumper wires 3 x 10kΩ Resistor
Breadboard 8 x LEDs
Breadboard wires 8 x 220-470Ω Resistors
Digital Multimeter 2 x Push Button switch
PICkit 3 Programmer/Debugger
PIC18F458 Datasheet
USB MEMORY STICK!!
RB0
MCLR 470
10k RB1
470
RB2
PIC18F458
Vdd 470
Vss RB3
470
RB4
470
10k RB5
470
RA0 RB6
470
RB7
470
OSC1 OSC2
SW1
4MHz
22pF 22pF
Figure 2
Digital Systems III, Practical Manual 23
In the Lab:
2. Connect the circuit and all required pins on the breadboard. Connect 8 LEDs on
PORTB pins and switch is connected on PORTA pin.
Digital Systems III, Practical Manual 24
3. Apply steps from LAB 1.
4. Open Pre-prac saved on Notepad. Copy the code and Paste it in the Source file on
MPLAB X.
5. Compile and troubleshoot if necessary.
6. Apply steps from LAB 2 and simulate the circuit.
7. Apply steps from LAB 3. Use a multimeter to measure the voltage of your power
supply before using it.
8. Edit the code to use different pins, label them and repeat steps 5-7.
You must be able to explain all the processes and what the code does.
RB0
MCLR 470
10k RB1
470
RB2
PIC18F458
Vdd 470
Vss RB3
470
RB4
470
10k 10k RB5
470
RA0 RB6
470
RA1 RB7
470
OSC1 OSC2
SW2 SW1
4MHz
22pF 22pF
Figure 3
RB0 A
MCLR 470
10k RB1 B
470
RB2
PIC18F458
C
Vdd 470
Vss RB3 D
470
RB4 E
470
RB5 F
470
RA0 RB6 G
470
RA1 RB7 C
POT=10k 470
OSC1 OSC2
4MHz
22pF 22pF
Figure 4
_____
MCLR
10k
RB0 RD0
470
PIC18F458
RB1
RB2 RD1
470
RB4
1 2 3
RB5 RD2
470
4 5 6 RB6
7 8 9 RB7 RD3
470
0 # OSC1 OSC2
*
1 2
10k 10k 10k 10k
4MHz
22pF 22pF
+5V
Figure 4
EQUIPMENT
Tools Components
5V Power supply 1 x PIC18F458 microcontroller
1 x Side Cutter 1 x 4MHz Crystal
1 x Pliers 2 x 22pF Capacitors
5 x Male to Male Jumper wires 1 x 10kΩ Resistor
Breadboard 1 x Liquid Crystal Display (16x2)
Breadboard wires
Digital Multimeter
PICkit 3 Programmer/Debugger
PIC18F458 Datasheet
USB MEMORY STICK!!
16X2 LCD
Vee
RW
Vss
Vcc
D0
D1
D2
D3
D4
D5
D6
D7
RS
E
+5V
RB0
RD6
RD7
MCLR
10k RB1
RB2
PIC18F458
Vdd
Vss RB3
RB4
RB5
RA0 RB6
RA1 RB7
OSC1 OSC2
4MHz
22pF 22pF
Figure 5
Digital Systems III, Practical Manual 36
Missing text……proceed to the next page.
Digital Systems III, Practical Manual 37
Missing text……proceed to the next page.
IMPORTANT PINS:
Pin 1: Master Clear pin. It must be connected to +5V through a resistor with a value
between 4.7kΩ & 10kΩ.
Pin 11&32: VDD pins. These pins must be connected direct to +5V. These pins supply
power to the microcontroller.
Pin 12&31: VSS pins. These pins must be connected direct to Ground. These pins supply
power to the microcontroller.
Pin 13&14: OSC1 & OSC2 pins. These are oscillator pins which connects a crystal with a
microcontroller. See picture below.