0% found this document useful (0 votes)
13 views18 pages

Ch5 Part1 ADC

Uploaded by

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

Ch5 Part1 ADC

Uploaded by

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

EMBEDDED SYSTEM

APPLICATIONS
DEC5052

TOPIC 5: HARDWARE INTERFACING – ADC & Sensor Interfacing


Outline
 Discuss the ADC section of the PIC18 chip.
 The process of data acquisition using ADC.
 ADC Programming in the PIC18.
 Interface temperature sensors to the PIC18.

11 November 2024 [email protected] 2


Analog to Digital Converter (ADC)
 Widely used in data acquisition.
 Major Characteristics of the ADC
 Resolution: The higher resolution provides a smaller step
size. Step size = Vref/resolution
 Conversion time: time takes to convert the analog input to
a digital number.
 Vref = Vref(+) – Vref(-)
 Digital Data Output, Dout = Vin / Step Size

11 November 2024 3
Example 13-1 (pg. 502)
For an 8-bit ADC, we have Vref = 2.55V. Calculate the D0 – D7 output if the analog
input is (a) 1.7V and (b) 2.1V

Solution:
Step size = 2.55/255 = 10mV
(a) Dout = 1.7V/10mV = 170 in decimal or 10101011 in binary
(b) Dout = 2.1V/10mV = 210 in decimal or 11010010 in binary

11 November 2024 4
Review Questions
1. Give to factors that affect the step size calculation
1. Number of steps / resolution size 2. Reference Voltage, Vref

2. Find the step size for an 8-bit ADC, if Vref = 1.275V.


1.275V/255 = 5 mV

3. For question 3, calculate the D0-D7 output if the


analog input is:
(a) 0.7V 0.7V/5mV = 140 and D7 – D0 is 10001100 in binary
(b) 1V 1V/5mV = 200 and D7 – D0 is 11001000 in binary

11 November 2024 5
Analog-to-digital converter
 An analog-to-digital
converter (abbreviated
ADC, A/D or A to D) is a
device that converts a
continuous physical
quantity (usually
voltage) to a digital
number that represents
the quantity's amplitude.

11 November 2024 6
Concepts

 Resolution
The resolution of the converter
indicates the number of discrete
values it can produce over the
range of analog values.

Resolution can also be defined


electrically, and expressed in volts.
The minimum change in voltage
required to guarantee a change in
the output code level is called the
least significant bit (LSB) voltage.

11 November 2024 7
PIC18 ADC Features Programming
 Resolution: 10-bit
 Have 5 – 15 channels depending on the family member.
 The converted output binary data is kept in ADRESL and ADRESH.
 The A/D Control Register (ADCONx) used to configured conversion clock
source, channel selection, port configuration control bits, ADC on/off, and
start/end of conversion.

In order to reduce the power consumption of the PIC18, the


ADC feature is turned off when the microcontroller is
powered up.

11 November 2024 8
PIC18F4550: ADC Pins

11 November 2024 9
AD Block Diagram

11 November 2024 10
ADCON0
Register

11 November 2024 11
ADCON1
Register

Voltage Reference
1. Internal
Vref+ = VDD
2. External
Different voltage between
Vref+ and Vref- must be
larger than ( > ) 3V with
Vref+ < VDD + 0.3V and
Vref- > VSS – 0.3V

11 November 2024 12
ADCON2
Register

Calculating A/D
Conversion Time:
1. Tad is the conversion
time per bit.
2. For PIC18, the
conversion time is 12
times Tad
3. Tad cannot be faster
than 1.6usec

11 November 2024 13
A/D RESULT JUSTIFICATION

Study the
Example 13-2 and 13-3.

11 November 2024 14
Calculating A/D Conversion Time (Tad)
 The A/D conversion requires 12 Tad per 10-bit conversion
 The source of the A/D conversion clock is software selectable. The seven
possible options for TAD are:
 2 TOSC
 4 TOSC
 8 TOSC Study the
 16 TOSC Example 13-4 to 13-6.
 32 TOSC
 64 TOSC
 Internal RC oscillator.
 For correct A/D conversions, the Tad must be selected to ensure a
minimum Tad time is 1.6 μs.

11 November 2024 15
Steps in Programming ADC using Polling
1. Turn on ADC [ADCON0bits.ADON = 1]
2. Set the selected ADC channel as input pin [TRISAbits.RAx = 1]
3. Select Vref, input channels, and conversion speed in ADCON0 and ADCON1
4. Wait for the required acquisition time, Tacq. Typical value = 15 μs. This to allow
the sample-and-hold capacitor to charge fully to the input voltage.
5. Activate start conversion [ADCON0bits.GO = 1]
6. Wait for the conversion to be completed [ while(ADCON0bits.DONE ==1) ]
7. Read ADRESL and ADRESH
Study the
8. Repeat step 4
Program 13-1C (pg. 513)

11 November 2024 16
Programming ADC using Interrupts
Interrupt Flag bit Register Enable bit Register
ADIF (ADC) ADIF PIR1 ADIE PIE1

Note:
• Upon power-on reset, ADC is assigned to high-priority interrupt
• We can change to low-priority by using ADIP bit of the IPR1.

Study the
Program 13-2C (pg. 514)

11 November 2024 17
Review Questions
1. Give the main factor affecting the step size of ADC in PIC18 Vref
2. The ADC of PIC18 is a/an _________
10 - bit converter.
3. True or false. The ADC in PIC18 is an off-chip module.
4. Find the step size for an PIC18 ADC, if Vref = 1.024V. Step size = 1mV
5. For problem 4, calculate the D0-D9 output if analog input is
a) 0.7V 10 1011 1100
b) 1V 11 1110 1000
6. Indicate the number of available analog input channels for each of the following options in
the ADCON1 register:
a) PCFG = 0100 11 Channels
b) PCFG = 1001 6 Channels
7. True or false. The conversion time is equal to 12 x Tad.
8. 1.6  s.
The minimum Tad allowed is ________
9. Which bit is used to poll for the end of conversion? DONE bit of the ADCON0 register

11 November 2024 18

You might also like