(Adc) 5
(Adc) 5
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.
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
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…
PIC16F887 has up to 14 analog input channels. They are multiplex within Port A and Port B.
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)
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…
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
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 }
PIC16F887 Analog-to-Digital …
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.
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
ADS CONTACT F
Name
SUBSCRIBE TO
Posts
Email *
Comments
Message *
Send
CLOUDFLA
https://bteworkshop.blogspot.com/2021/02/pic16f887-analog-to-digital-converter.html 6/6