Seminar Topics & Project Ideas On Computer Science Electronics Electrical Mechanical Engineering Civil MBA Medicine Nursing Science Physics Mathematics Chemistry ppt pdf doc presentation downloads and Abstract

Full Version: PIC 16F877A Tutorials for Pitt Robotics Club
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
PIC 16F877A Tutorials for Pitt Robotics Club

[attachment=53390]

INTRODUCTION

These tutorials demonstrate how to code simple input & output for your robot using the popular PIC 16F877A microcontroller. They help you get your sensors & motors working. The rest of the code is up to you!
The tutorials assume basic knowledge of programming and electronics. If you are new to programming, you should learn the basics of C or C++. You should also know rudimentary electronics, and how to construct simple circuits.
I got most of this information from the PIC MCU Compiler reference manual & the help of other club members. You are welcome to edit or add new tutorials. Please email the club if you make another tutorial.

How to hook up the PIC so it will run?

Materials
PIC16F877A
Breadboard
20 Megahertz crystal oscillator
2 7-20pf capacitor
Black & red wires
>7.2 volt battery
• For use with a higher voltage supply, you will need to use a voltage regulator to convert the higher voltage to 5v. Typically a 7805 is used. Look up the datasheet by searching Google “7805 voltage regulator”.

Circuit

1. Insert PIC on breadboard. Refer to pin diagram above for pin numbers. To prevent confusion, orient the PIC so the dimple on top faces the same way as the pin diagram.
2. Connect breadboard side strips - power to power (red strips), ground to ground (black strips). Just like the bottom 2 wires below. Those strips are now referred to as “power” & “ground”.

What do the pins mean?

The pins RB0-RB7, RC0-RC7, and RD0-RD7 are digital I/O pins. The pins CCP1 and CCP2, which share locations with RC1 and RC2, can be used for a PWM signal (see DC Motor tutorial). The pins AN0-AN7 are for analog I/O (see Photoresistor tutorial). TX and RX are for debugging I/O (see Output Messages to Computer tutorial). The remaining pins deal with power/ground, the clock signal, and programmer I/O.
A PIC is made of several “ports.” Each port is designated with a letter, RB0-RB7 are a port. RC0-RC7 and RD0-RD7 are a port as well. RA0-RA5 and RE0-RE2 are also ports, but with fewer pins. Some of these pins have special purposes, but most can be used as basic input/output pins.
For example, you can set pin RB0 to be either an input pin, or an output pin. As an input pin, the digital voltage on the pin can be read in. For example, if RB0 is connected to ground (0v), then you would read a digital 0. If RB0 was connected to power (5v), then you would read a digital 1.
On the other hand, if you wanted to set RBO as an output pin, you could choose to make RB0 either be 5v, or 0v. This can be used, for example, to turn off or on a LED, or to turn off or on a motor.

How to program the PIC?

I omit step by step details of how to program the PIC because software always changes.
As of spring 2010, the club uses software from CCS We use the PCW Compiler to write & compile programs and CCS Load and the ICD-U40 programmer to write programs to the PIC. Always load a .hex file onto the PIC – the compiled machine language program. The hex file should be located in the same folder as your project file.
You need to connect the ICD’s Ethernet cable pins to the appropriate pins on the PIC in order to load a program. You also need to have the PIC running (i.e. under +5V power) when programming.
See “How do I connect the CCS ICD to my own hardware?” in the CCS FAQ,