0% found this document useful (0 votes)
26 views6 pages

(Adc) 5

The document provides an overview of the PIC16F887 microcontroller's Analog-to-Digital Converter (ADC) module, detailing its parameters such as resolution, voltage reference, clock source, and number of analog input channels. It includes programming instructions for utilizing the ADC, along with example MikroC source code for reading analog inputs. The document serves as a tutorial for DIY electronics enthusiasts interested in microcontroller projects involving ADC functionality.

Uploaded by

githouse36
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views6 pages

(Adc) 5

The document provides an overview of the PIC16F887 microcontroller's Analog-to-Digital Converter (ADC) module, detailing its parameters such as resolution, voltage reference, clock source, and number of analog input channels. It includes programming instructions for utilizing the ADC, along with example MikroC source code for reading analog inputs. The document serves as a tutorial for DIY electronics enthusiasts interested in microcontroller projects involving ADC functionality.

Uploaded by

githouse36
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1/8/25, 11:57 PM DIY Electronics Projects and Tutorials: PIC16F887 Analog-to-Digital Convert…

DIY Electronics Projects and Tutorials


DIY PCB Project, CPLD/FPGA Coding with VHDL, Arduino Programming Tutorials, PLC Progr
Projects, AVR Microcontroller Programming Tutorials, etc.

Analog CPLD PCB PIC16 PLC About Me Privacy

FRIDAY, FEBRUARY 5, 2021

PIC16F887 Analog-to-Digital Converter (ADC)

Introduction

Analog-to-Digital Converter (ADC) module of a microcontroller converter analog input voltage to digital va
microcontroller process with. There are many different types of ADC module inside microcontroller.

ADC module has some parameters:

1. Resolution : Define the amount of digital number of analog to digital conversion. It could be 8-bit, 10
resolution gives the conversion result more accurate.
2. Voltage reference: It also effect Resolution. Lower voltage reference of ADC makes an accurate con
be 2.5V, 3.3V, or 5V.
3. Clock : It could be driven from microcontroller clock source, or its own internal clock.
4. Number of Analog Input Channel : It refers to the amount of input pins of ADC. It usually multiplexe
pins.

00:00 / 00:00

The figure below is ADC block diagram of PIC16F887.

https://bteworkshop.blogspot.com/2021/02/pic16f887-analog-to-digital-converter.html 1/6
1/8/25, 11:57 PM DIY Electronics Projects and Tutorials: PIC16F887 Analog-to-Digital Convert…

Block diagram of PIC16F887 ADC Module

PIC16F887 has up to 14 analog input channels. They are multiplex within Port A and Port B.

Programming for ADC

ADC module inside PIC16F887 has some registers for programmer to work with. Programmer need to co

1. ADC clock
2. Analog channel inputs
3. Result arrangement
4. Channel selection
5. Start of conversion
6. Testing the result and reading the result
7. Interrupt control (optional)

These registers are,

https://bteworkshop.blogspot.com/2021/02/pic16f887-analog-to-digital-converter.html 2/6
1/8/25, 11:57 PM DIY Electronics Projects and Tutorials: PIC16F887 Analog-to-Digital Convert…

Registers relate to ADC of PIC16F887

Now let start a simple example of using ADC module. This program read analog input on RA0/AN0. Conv
on Port C and Port D.

https://bteworkshop.blogspot.com/2021/02/pic16f887-analog-to-digital-converter.html 3/6
1/8/25, 11:57 PM DIY Electronics Projects and Tutorials: PIC16F887 Analog-to-Digital Convert…

Schematic Diagram

MikroC source code:

1
2 void PORT_Init() {
3 PORTA=0x00; // Clear PORTA
4 PORTC=0x00; // Clear PORTC
5 PORTD=0x00; // Clear PORTD
6 TRISA=0x01; // RA0 AS ANALOG INPUT
7 TRISC=0x00; // PORTC AS OUTPUT
8 TRISD=0x00; // PORTD AS OUTPUT
9 }
10
11 void Analog_Init() {
12 ADCON0=0x80; // Select Fosc/32 AND ANS0
13 ADCON1=0x80; // Select Right Justified and VDD-VSS
14 /*Select Channel 0 - AN0*/
15 ADCON0.CHS0=0;
16 ADCON0.CHS1=0;
17 ADCON0.CHS2=0;
18 ADCON0.ADON=1; // Enable ADC Module
19 }
20

https://bteworkshop.blogspot.com/2021/02/pic16f887-analog-to-digital-converter.html 4/6
1/8/25, 11:57 PM DIY Electronics Projects and Tutorials: PIC16F887 Analog-to-Digital Convert…
21
22 void Read_ADC() {
23 ADCON0.GO=1; // start of conversion
24 while(ADCON0.GO); // waiting for Conversion's Complete
25 delay_us(100);
26 //Read lower register
27 PORTC=ADRESL;
28 //Read higher register
29 PORTD=ADRESH;
30 }
31
32 void main() {
33 PORT_Init();
34 OSCCON|=0x70; // Select Internal 8MHz OSC
35 Analog_Init();
36 while(1) Read_ADC();
37 }

Program8-1.c hosted with ❤ by GitHub

Click here to download zip file of this working example.

PIC16F887 Analog-to-Digital …

Posted by DIY Electronics at 6:00 AM

Labels: ADC, PIC16F887 MikroC

No comments:

Post a Comment

https://bteworkshop.blogspot.com/2021/02/pic16f887-analog-to-digital-converter.html 5/6
1/8/25, 11:57 PM DIY Electronics Projects and Tutorials: PIC16F887 Analog-to-Digital Convert…
To leave a comment, click the button below to sign in with Google.

SIGN IN WITH GOOGLE

Newer Post Home

Subscribe to: Post Comments (Atom)

LABELS

ADC (10) Analog (14) Arduino (12) Atmega16 (19) Audio (2) AVR (20) Charger (1) Cortex-M0 (1) Coun
Digital I/O (22)Display (34) EEPROM (2) Environment Sensor (1) esp8266 (2) Experiment Board (10)
LDmicro (29) measurement and instrumentation (7) Microchip Studio (3) MikroC (1) One-Shot (3) OpAmp
Microcontrollers (16) PIC16F877A (2) PIC16F887 MikroC (22) PLC (35) PWM (11) Regulator (1) RTC (
(5) SPI (5) Timer (34) UART (2) ultra-sonic sensor (1) USB (1) VHDL (21) xc8 (1) XC95108 (9) XC9536 (15
Xilinx ISE (22)

ADS

SEARCH THIS BLOG

ADS CONTACT F

Name
SUBSCRIBE TO

Posts
Email *
Comments

Message *

Send

CLOUDFLA

2020. Powered by Blogger.

https://bteworkshop.blogspot.com/2021/02/pic16f887-analog-to-digital-converter.html 6/6

You might also like