Programming the MicroChip PIC16F877 using CCS "C"
12/08/00 EWJNote: When programming and debugging the robot always make sure the robot wheels are elevated off of the bench.
Overview:
Be sure to read Guide to Robot Hardware before attempting to program.
The PIC16F877 is a Microprocessor based system, including input and output (I/O) interfaces, on a single integrated circuit. This type of device is called a Microcontroller.
The '877 device contains several features that are useful when using the device to control a process. Not all of the features of the '877 are available at the same time so when the device is used in an application such as the robot choices must be made as to what features are going to be in the overall design.
Your Program:
The beginning of your program must include the following statement:
#include "ee350201.h"
Reserved Constants:
FORWARDSPEED
RIGHTSPEED
LEFTSPEED
ALL_OUT
ALL_IN
Robot Functions:
|
Name |
Description |
Returns |
||
|
clr_LCD() |
Erases LCD screen |
None |
||
|
line1() |
Places LCD cursor at beginning of line 1 |
None |
||
|
line2() |
Places LCD cursor at beginning of line 1 |
None |
||
|
loc_LCD(p) |
Locates LCD cursor at position p (1 to 16 for line one and 17 to 32 for line two). |
None |
||
|
Beep(t) |
Beeps for time t where t is in 0.1 sec increments |
None |
||
|
init_DA() |
Initializes Digital to Analog function. Must be called once at start of program if out_da(s,v) is used. |
None |
||
|
out_da(s,v) |
Sends digital data v (0 to 1023) to output s. "s" must be FORWARDSPEED , RIGHTSPEED, LEFTSPEED ONLY |
None |
||
|
init_AD() |
Initializes Analog to Digital converter. Must be called once at start of program if in_ad0(), in_ad1(), or in_ad2() are used. |
None |
||
|
In_ad0() |
Left front sensor value from analog to digital converter. |
Long integer |
||
|
In_ad1() |
Right front sensor value from analog to digital converter. |
Long integer |
||
|
In_ad2() |
Battery voltage value from analog to digital converter. Scaled by 3.13 |
Long integer |
||
|
|
|
|
||
Sample Programs
: