100% found this document useful (2 votes)
129 views

ADC of PIC Microcontroller

This document discusses analog to digital conversion using a PIC18F4520 microcontroller. It has 8 analog inputs that convert analog signals into 10-bit digital numbers. There are registers associated with the ADC module including ADRESH, ADRESL, ADCON0, and ADCON1 that control aspects of the analog to digital conversion process like selecting the analog channel, initiating conversions, and setting the clock. The document also provides details on analog input voltage ranges, conversion resolution, acquisition time, and clock selection to ensure precise analog to digital conversion of signals like cell voltage, charging current, and temperature.

Uploaded by

killbill
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
129 views

ADC of PIC Microcontroller

This document discusses analog to digital conversion using a PIC18F4520 microcontroller. It has 8 analog inputs that convert analog signals into 10-bit digital numbers. There are registers associated with the ADC module including ADRESH, ADRESL, ADCON0, and ADCON1 that control aspects of the analog to digital conversion process like selecting the analog channel, initiating conversions, and setting the clock. The document also provides details on analog input voltage ranges, conversion resolution, acquisition time, and clock selection to ensure precise analog to digital conversion of signals like cell voltage, charging current, and temperature.

Uploaded by

killbill
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

ADC of PIC

An Analog to Digital Converter or ADC is a device which converts continuous analog


quantity to corresponding discrete digital values.

PIC18F4520 microcontroller has 8 ADC inputs and it will convert analog inputs to a
corresponding 10 bit digital number.

For this project there are three Analog signals to be converted to be digital before processing
namely,

1. The Cell voltage.

2. The Charging current.

3. The temperature.

For précised conversion we use, ADC Lower Reference as –Vref and Higher Reference as
+Vref

 Vref- = -2.5V

 Vref+ = +2.5V

 n = 10 bits

 Resolution = (Vref+ – Vref-)/(2n – 1) = 5/1023 = 0.004887V

So ADC resolution is 0.00487V, which is the minimum required voltage to change a bit.

Digital Output
Analog Input
Binary Hex Decimal
0 0b0000000000 0x000 0
0.004887V 0b0000000001 0x001 1
0.009774V 0b0000000010 0x002 2
0.014661V 0b0000000011 0x003 3
4.999401V 0b1111111111 0x3FF 1023

The ADC module of PIC 16F877A has 4 registers.

 ADRESH – A/D Result High Register

 ADRESL – A/D Result Low Register

 ADCON0 – A/D Control Register 0


 ADCON1 – A/D Control Register 1

Block Diagram

ADCON0 – A/D Control Register 0

 Bit 7 ~ 6 : ADCS1 & ADCS0, A/D Conversion clock selection bits. These bits are
used in combination with ADCS2 of ADCON1 register

 Bit 5 ~ 3 : CH2, CH1 & CH0 are analog channel selection bits which will select a
particular channel out of 8.

 Bit 2 : Go_nDone is the A/D conversion status bit. Setting this bit initiates the A/D
conversion and it will be automatically cleared when the conversion completes.

 Bit 1 : Unimplemented, Read as 0.

 Bit 0 : ADON, A/D Module On bit. Setting this bit will turn on the ADC module.

ADCON1 – A/D Control Register 1


 Bit 7 : ADFM, A/D Result Format bit. Bits of result will be right justified if this bit is
set otherwise it will be left justified.

 Bit 6 : ADCS2, A/D Conversion clock selection bit. This bit is used in combination
with ADCS0 and ADCS1 of ADCON0 register.

 Bit 5 ~ 4 : Unimplemented. Read as 0.

 Bit 3 ~ 0 : PCFG3 ~ PCFG0, A/D Port Configuration Bits. Status of these bits
determine whether the pin is Analog or Digital as per the table below.

A/D Acquisition Time

Holding capacitor (CHOLD) must be charged to the input voltage to meet the accuracy specified
by the datasheet. So we must provide a delay greater than the minimum required
acquisition time to charge the capacitor. 19.72μs is the minimum time specified in the
datasheet. Please refer the datasheet for more details.

A/D Clock Selection

A/D conversion clock must be selected to ensure minimum TAD. TAD is the conversion time
per bit, which is 1.6μs. Please refer the datasheet for more details.

You might also like