Summary of Connect ADC with PIC16F877
This article details an ADC library for PIC microcontrollers, offering routines to initialize the module and read analog values. It describes three key functions: `ADC_Init` for setup with RC clock, `ADC_Get_Sample` for acquiring channel data, and `ADC_Read`, which combines initialization and reading. The text emphasizes requirements like using internal voltage references and configuring TRISx bits as inputs before use.Parts used in the ADC Library Project:
- PIC MCU modules with built-in ADC
- RC clock source
- Analog signal input channels
- Internal voltage reference source
- TRISx configuration bits
Library Routines
ADC_Init
| Prototype | void ADC_Init(); |
|---|---|
| Returns | Nothing. |
| Description | This routine initializes PIC’s internal ADC module to work with RC clock. Clock determines the time period necessary for performing AD conversion (min 12TAD). |
| Requires |
|
| Example |
Code listing
|
ADC_Get_Sample
| Prototype | unsigned ADC_Get_Sample(unsigned short channel); |
|---|---|
| Returns | 10 or 12-bit unsigned value read from the specified channel (MCU dependent). |
| Description | The function aquires analog value from the specified channel. Parameter channel represents the channel from which the analog value is to be acquired. Refer to the appropriate datasheet for channel-to-pin mapping.
|
| Requires |
|
| Example |
C source (2)
|
ADC_Read
| Prototype | unsigned ADC_Read(unsigned short channel); |
|---|---|
| Returns | 10 or 12-bit unsigned value read from the specified channel (MCU dependent). |
| Description | Initializes PIC’s internal ADC module to work with RC clock. Clock determines the time period necessary for performing AD conversion (min 12TAD). Parameter channel represents the channel from which the analog value is to be acquired. Refer to the appropriate datasheet for channel-to-pin mapping.
|
| Requires |
|
| Example |
C source (3)
|
For more detail: Connect ADC with PIC16F877
Quick Solutions to Questions related to ADC Library:
- How does ADC_Init work?
This routine initializes the PIC's internal ADC module to operate with an RC clock. - What is the minimum time period for AD conversion?
The clock determines the time period necessary for performing AD conversion, which must be at least 12TAD. - Can I use an external voltage reference source?
No, the functions do not work with the external voltage reference source; they only support the internal voltage reference. - What must be done before using ADC_Get_Sample?
The ADC module needs to be initialized, and appropriate TRISx bits must be configured to designate pins as inputs. - Does ADC_Read initialize the module?
Yes, the ADC_Read function description states it initializes the PIC's internal ADC module to work with RC clock. - What value type does ADC_Get_Sample return?
It returns a 10 or 12-bit unsigned value depending on the specific MCU. - How do I specify the channel for reading?
You pass the channel number as a parameter to the function, referencing the datasheet for channel-to-pin mapping. - Is prior initialization required for ADC_Read?
The requires section for ADC_Read does not explicitly list prior initialization as a strict requirement unlike ADC_Get_Sample, though it performs initialization itself.
Related projects
PIC16F877 Driving LCD in 4-Bit Mode using PIC16F877 with Proteus Simulation
Introduction This microcontroller project shows how a PIC16F877 can drive an LCD display using 4-bit mode inside a Proteus simulation.The project demonstrates...
Programmers & ICSP · PIC16F877AEPE PIC/LCD Demo using PIC16F877 with Proteus Simulation
IntroductionThe EPE PIC/LCD Demo is a classic microcontroller project that demonstrates how a PIC16F877 can fully control a PG12864F graphical LCD.Designed as...
Motors & Robotics · PIC16F877AEfficient Sun-Following Robot: A Solar Tracker with Microcontroller Control
Abstract The impending global challenge of dwindling non-renewable fuel resources underscores the urgency of transitioning towards renewable energy alternatives like solar power....
Meters & Test Instruments · PIC16F688Determine capacitance by measuring the charging time using PIC16F688
When TEST botton is pressed, RA3 pin is set to "1". R2 and R3 are divide the voltage to 1/2 Vra3 which...
Meters & Test InstrumentsFrequency Meter Using Microcontroller
This tutorial simply states how to calculate frequency of a pulse source using a microcontroller. Story https://youtu.be/NAoj-HLRIro This tutorial simply states how...
Meters & Test Instruments · PIC16F84ADigital thermometer with PIC16F84 circuit
This electronic project is a very simple thermometer that is based on the PIC16F84A microcontroller, designed by Microchip. Why to use a...

