Testing The PIC Microcontroller (Pic 16F877A)
Testing The PIC Microcontroller (Pic 16F877A)
Testing The PIC Microcontroller (Pic 16F877A)
Course/Yr: ________
group: _______
I. OBJECTIVE
1. To familiarize PIN configuration of PIC microcontroller such as PIC16F877A.
2. To familiarize with PICBASIC PRO programming to simulate the PIC
microcontroller.
3. To familiarize the use of the Microcode Studio Plus (and/or a independent
LOADER)
Ping))) sensor
Tx antenna
Rx antenna
IR sensor Left
IR sensor Right
Bumper Left
Bumper Right
Buzzer, Amplifier Q1
3. What is the use of Pin 11 and Pin 12 of MAX323CPE? Why they need to be
connected to MCU at the ports youve indicated in Table 1?
_______________________________________________________________________________
_______________________________________________________________________________
_______________________________________________________________________________
___________________________________________________________________________
4. Connect a USB connection from computer to the robot. Open Microcode studio
plus and make (copy) a program blinking LEDs.
Filename: Led_ilaw
DEFINE LOADER_USED 1
Loop:
HIGH portd.3
PAUSE 500
LOW portd.3
pause 500
Goto Loop
Run and compile the program.
Table 1
Alternately, you can make this program to run the same output.
Filename: Led_ilaw2
Symbol RLed = portd.3
DEFINE LOADER_USED 1
Loop:
HIGH Rled.3
PAUSE 500
LOW Rled
pause 500
Goto Loop
Run and compile the program
5. Make a program that blinks the two LEDs alternately. Use a delay of 50 ms.
6. Open VIEW toolbar, and select LOADER. This should detect your robot. If in
case your computer does not detect the MCU, troubleshoot the robot and look
for fault (or ask your instructor)
a. Check the cable if properly connected.
8. Observe the hardware first: Indicate the connection of LCD into MCU by
completing Table 2.
LCD Pin
PIC 16F877A Port
DB4
DB5
DB6
DB7
RS
RW
E (enable)
Vdd (+5 V)
Vss
DB0 DB3
7. Assuming you have fixed the problem of your robot about loading your
programs into MCU, you are now ready for some programming trials.
Table 2
9. Copy and compile the program
Filename: LCD_try
DEFINE LOADER_USED 1
' PicBasic program to demonstrate operation of an LCD in 4-bit mode
Pause 500
loop:
Lcdout $FE, 1
' Clear LCD screen
Lcdout "HUMACON" ' Display Hello
Pause 500
' Wait .5 second
Lcdout $FE, $C0
' Starts writing at the second line
Lcdout "by TROPANG BOT"
' LCDOUT $FE, $0E
Pause 500
' Wait .5 second
Goto loop
' Do it forever
13. The LCD may be connected to the PIC MCU using either a 4-bit bus or an 8-bit
bus. Differentiate a 4-bit bus from an 8-bit bus.
_______________________________________________________________________________
_______________________________________________________________________________
____________________________________________________________________________
In an examined LCD connection, which bus is being used in this procedure?
______________________________________________________________________________
14. In an example program 2, what is meant by $FE, 1? By $FE, $C0?
_______________________________________________________________________________
_______________________________________________________________________________
____________________________________________________________________________
12. In your opinion, which first part of designing a project should precede,
hardware first then software or software first then hardware, so as to find a
room for innovation? Reason out.
_______________________________________________________________________________
_______________________________________________________________________________
_______________________________________________________________________________
___________________________________________________________________________
15. Write a simple program that greets and says, Mr Watson, come over here! (a
phrase used by Alexander Graham Bell, when by accident, discovered the
propagation of sound in a wire; the same historical account when the third
year ECE students etched their PCB with no copper left after an overnight
testing!!!). Mr Watson needs to be in first line and the rest of the phrase in
second line of an LCD display.
16. Copy and compile the program.
Filename: Sound_condition
When pressing the right bumper, a sound can be heard through the buzzer.
DEFINE LOADER_USED 1
Rbumper var portc.4
buzz var porta.5
main:
if Rbumper = 0 then
Sound PORTA.5,[100,70,100,20]
endif
goto main
17. Make a program of when bumper is pressed, the LED on the opposite side lit,
and the other is off. Same with the other bumper. Draw the schematic of your
hardware parts.
18. Make a program that uses the two bumpers and 2 LEDs and a buzzer. If a
bumper is pressed, the corresponding LED turns on and the buzzer produces a
sound. Do with another bumper, but use IF THEN ELSE statement.