Difference between revisions of "PIC Analog-Digital-Converter Example"

From Mech
Jump to navigationJump to search
 
(5 intermediate revisions by the same user not shown)
Line 7: Line 7:


==Project Files==
==Project Files==
Download the MPLAB project here: [[image:PIC_tutorial_ADC.zip|PIC ADC Tutorial Files]].
Download the MPLAB project here: [[media:PIC_tutorial_ADC.zip|PIC ADC Tutorial Files]].


This was compiled using MPLAB 7.6 and C18 3.12 (student version).
This was compiled using MPLAB 7.6 and C18 3.12 (student version).
Line 15: Line 15:
*<tt>main.c</tt> contains the code entry point and main control loop.
*<tt>main.c</tt> contains the code entry point and main control loop.
*<tt>main.h</tt> contains miscellaneous functions and macros.
*<tt>main.h</tt> contains miscellaneous functions and macros.

==Wiring Diagram==
[[Image:C18_tutorial_ADC_wiring.gif|thumb|center|Wiring Diagram for the ADC example]]

[[media:C18_tutorial_ADC_wiring.ppt|Wiring Diagram for the ADC example (PowerPoint)]]

==Breadboard Layout==
[[Image:C18_tutorial_ADC_breadboard.jpeg|thumb|Example Breadboard Layout|center]]

Latest revision as of 17:37, 14 November 2007

Introduction

This is a simple project that uses a PIC18F4431's ADC to sample an analog signal, which is used to control the brightness of an LED. A potentiometer is used to create an analog voltage signal, and the PIC reads the analog signal and outputs a PWM duty cycle corresponding to the voltage level. The PWM signal drives the LED, which will appear brighter or dimmer depending on the duty cycle.

Components Datasheets

PIC18F4431

Project Files

Download the MPLAB project here: PIC ADC Tutorial Files.

This was compiled using MPLAB 7.6 and C18 3.12 (student version). If MPLAB has problems finding files or does not compile, it may be because the directories on your computer are set up differently. In this case, create a new project following these instructions, and copy in the source files.

The source code is split into two files:

  • main.c contains the code entry point and main control loop.
  • main.h contains miscellaneous functions and macros.

Wiring Diagram

Wiring Diagram for the ADC example

Wiring Diagram for the ADC example (PowerPoint)

Breadboard Layout

Example Breadboard Layout