Difference between revisions of "PIC Microcontrollers with C18 Compiler"

From Mech
Jump to navigationJump to search
 
(95 intermediate revisions by the same user not shown)
Line 1: Line 1:
__TOC__
__TOC__
==PIC Microcontroller==
The microcontroller used for this project is the PIC18F4431 made by [http://www.microchip.com Microchip]. This is an 8-bit microcontroller with motor PWM generators, a quadrature encoder interface (QEI), and other "peripherals". The microcontroller uses an external 40MHz oscillator.


The microcontroller controls two wheel motors with PWM driving external H-bridges. The H-bridges draw their power directly from the batteries, not regulated power.


==Compiler and IDE==
Each of the wheels also has a quadrature encoder. The left wheel encoder is connected to the PIC's QEI via a schmitt trigger buffer. The right wheel encoder is wired to a U.S. Digital LS7183 chip (because the PIC only has 1 QEI) which outputs pulses on one of two pins, depending on whether the wheel is spinning backwards or forwards. The two pins are then each connected to a counter on the PIC, which keeps track of the number of pulses. The location of the wheel can be determined by subtracting the reverse-pulse counter from the forward-pulse counter.
The C18 compiler is a C-language compiler for the Microchip PIC18 family of microcontrollers. The student version of this compiler is available for free at Microchip's website. The difference between the student version and the commercial version is the level of optimization available. For most purposes, the student version should suffice.


Be aware that there are some differences between Microchip's C18 compiler and C compilers for other platforms. For example, an <tt>int</tt> data type in C18 is 16 bits, instead of the usual 32 bits. Refer to the C18 user guide for more information.
The PIC is interfaced with the XBee modem via the RS-232 serial interface.


Microchip's IDE, MPLAB, is also available for free at Microchip's website.
===Programming the PIC===


==Connecting the Programmer==
===Troubleshooting===
[[media:Using_ICD2_Poster.pdf|Connecting the ICD2 Programmer]]
*If MPLAB has trouble connecting with the ICD2, open the Device Manager ('''Control panel>System>Hardware>Device Manager''') and disable then re-enable the ICD2. Also be sure that you followed in installation instructions in the manual when you installed the ICD2.


==Writing the Code==
==XBee==
[[Writing Code with the C18 Compiler]]
==Code==

==PCB==
==Example Projects==
[[PIC Analog-Digital-Converter Example]]

[[PIC Motor Control and Serial Port Example]]

[[PIC Motor Control with EEPROM and Interactive Menu Example]]

For more examples, see the C18 User's Guide and the application notes on Microchip's website.

==Tips and Troubleshooting==
[[PIC/C18 Compiler Tips and Troubleshooting]]

==Documents==
===MPLAB and C18 Compiler===
[[media:MPLAB_GS.pdf | MPLAB Quick Start Guide]]

[[media:MPLAB_UG.pdf | MPLAB User's Guide]]

[[media:Microchip_C18_GS.pdf | C18 Compiler Getting Started]]

[[media:Microchip_C18_UG.pdf | C18 Compiler User's Guide]]

[[media:Microchip_C18_libraries.pdf | C18 Compiler Libraries]]

===PIC18===
[[media:PIC18_config_settings.pdf | PIC18 Configuration Settings Addendum]]

===PIC18F4431===
[[media:PIC18F4431_datasheet.pdf | PIC18F4431 Datasheet]]

[[media:PIC18F4431_errata.pdf | PIC18F4431 Errata]]

Latest revision as of 15:23, 11 October 2007


Compiler and IDE

The C18 compiler is a C-language compiler for the Microchip PIC18 family of microcontrollers. The student version of this compiler is available for free at Microchip's website. The difference between the student version and the commercial version is the level of optimization available. For most purposes, the student version should suffice.

Be aware that there are some differences between Microchip's C18 compiler and C compilers for other platforms. For example, an int data type in C18 is 16 bits, instead of the usual 32 bits. Refer to the C18 user guide for more information.

Microchip's IDE, MPLAB, is also available for free at Microchip's website.

Connecting the Programmer

Connecting the ICD2 Programmer

Writing the Code

Writing Code with the C18 Compiler

Example Projects

PIC Analog-Digital-Converter Example

PIC Motor Control and Serial Port Example

PIC Motor Control with EEPROM and Interactive Menu Example

For more examples, see the C18 User's Guide and the application notes on Microchip's website.

Tips and Troubleshooting

PIC/C18 Compiler Tips and Troubleshooting

Documents

MPLAB and C18 Compiler

MPLAB Quick Start Guide

MPLAB User's Guide

C18 Compiler Getting Started

C18 Compiler User's Guide

C18 Compiler Libraries

PIC18

PIC18 Configuration Settings Addendum

PIC18F4431

PIC18F4431 Datasheet

PIC18F4431 Errata