Testing The PIC Microcontroller (Pic 16F877A)

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 6

Testing the PIC Microcontroller (PIC16F877A)

Experiment no. ______


Name: __________________________________
Day/Time: ____________

Course/Yr: ________
group: _______

II. TOOLS AND EQUIPMENT


(1) PIC16F877A
(1) Rolling Robot with (12) 1.5-V battery
(1) PC with PICBASIC PRO/PICBASIC
(1) 40-Pin IC socket
(1) Digital Tester
III. PROCEDURE
1. Examine the schematic circuit of LIKHA Robot 01. Observe that there are (4)
1.5-V batteries for motors (or servomotors), and 9-V battery for the
microcontroller (MCU). Motors require a separate power supply in order to
draw large current as against less supplied current if the MCU and the motors
draw current from single power source (or that battery can drain very fast if
only using one unit of power supply).

1st Ed: 03.02.10

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)

1st Ed: 03.02.10


Note: The following pin configuration is commonly found in my designed
LIKHA Robots
symbol RSensor = portd.2
symbol LSensor = portd.1
SYMBOl Rwheel = portb.5
symbol Lwheel = portb.6
symbol RLed = portd.3
symbol LLed = portc.5
Symbol Lbumper = portd.4
Symbol Rbumper = portc.4
Symbol Beef = porta.5
symbol Neck = portb.7
LSENS VAR portb.2 'portb.2
CSENS VAR portb.1
RSENS VAR portb.0
BSENS VAR portd.5
'
SYMBOL IRCRX = portd.2
' IR Center RCVR
'IRCRX = b4
SYMBOL IRCTX = portc.2
'P17 IR center TX
SYMBOL IRRTX = portc.1
'P16 IR RIGHT RCVR, p16 S pmw1
2. Complete Table 1 by filling the information of PORT connection to PIC16F877A.
Components
16F877A Port
Pin
11,
12
of
MAX323CPE,
respectively

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.

1st Ed: 03.02.10

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.

b. Check the port available as indicated by the computer. The LOADER


should have exact number of port on the computer connection.
c. If the problem persists, reboot your computer.

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

1st Ed: 03.02.10

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

' Wait for LCD to startup

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

10. What is the purpose of DEFINE LOADER_USED 1 in the beginning of your


program?
_______________________________________________________________________________
_____________________________________________________________________________
What happen if it is not specify in the program?
_______________________________________________________________________________
_____________________________________________________________________________
11. Why do you need to know the connection first before programming the PIC?
_______________________________________________________________________________
_______________________________________________________________________________
____________________________________________________________________________

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?
_______________________________________________________________________________
_______________________________________________________________________________
____________________________________________________________________________

1st Ed: 03.02.10

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

bumper right connected to portc.4

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.

1st Ed: 03.02.10

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.

You might also like