1
07-ADC (Analog to
Digital Converter).
By : Mohamed Fawzy
Programming AVR Microcontrollers
© Mohamed F.A.B 2015
Lecture Notes:
2
o Set Your Phone To Vibration Mode.
o Ask any time.
o During labs, Feel Free To Check Any Materials or
Internet.
o Slides are self content.
o Feel Free To Share This Materials With Your Friends.
o Work Hard For Achieving Most Of This Course.
© Mohamed F.A.B 2015
3
Don't Forget !!!!
© Mohamed F.A.B 2015
Any Expert Was Once A Beginner

4
Lesson(12).
© Mohamed F.A.B 2015
Lesson (12):
Analogue to Digital Conversion.
5
Lesson (12) Topics.
© Mohamed F.A.B 2015
► What and Why ADC.
► Characteristics of ADC.
► Interfacing LM35 temperature sensor.
6
What & Why ADC?
© Mohamed F.A.B 2015
 Digital Computers uses binary values, but in physical
world everything is analog.
 Temperature, Pressure, humidity, and velocity are
examples of physical quantities.
 A physical quantity is converted to electrical signals
(voltage or current) using device called sensor.
 So, we need Analog-to-Digital Converter to translate
the analog signal to digital numbers so that micro-
controller can read and process them.
7
Example.
© Mohamed F.A.B 2015
Analog
Digital
0
1
1
0
0
0
0
1
8
Characteristics of ADC.
© Mohamed F.A.B 2015
 The resolution of ADC is the number of bits at which
converted data stored in such as 8, 10, 16 or even 24-bit.
Resolution
Vref
 It is an input voltage used for voltage reference.
𝑠𝑡𝑒𝑝 𝑠𝑖𝑧𝑒 =
[(𝑉𝑟𝑒𝑓+) − (𝑉𝑟𝑒𝑓−)]
2 𝐵𝑖𝑡 𝑛𝑜
𝑠𝑡𝑒𝑝 𝑠𝑖𝑧𝑒 =
[5 −0 ]
210 =
5
1024
=0.00488 V*1000=4.88 mv
 Higher resolution ADCs means smaller step size and high accuracy.
 Smaller Vref ADCs means smaller step size and high accuracy.
NOTES:
9
Characteristics of ADC. Cont’
© Mohamed F.A.B 2015
Conversion Time:
Conversion time is the time it takes to convert the
single analogue sample to digital.
o Example.
Digital Output=
𝑉_𝐼𝑛𝑝𝑢𝑡
𝑆𝑡𝑒𝑝_𝑆𝑖𝑧𝑒
10
ADC Features of ATMEGA32.
© Mohamed F.A.B 2015
 10 bit ADC.
 It has 8 analog input channels.
 Converted output binary data is held by two
registers ADCL and ADCH.
 Three options for Vref (VCC or 2.56V or External
AREF pin).
 Conversion time is defined by crystal frequency
connected to XTAL pins and ADPS0:2.
11
ADC registers in ATMEGA32.
© Mohamed F.A.B 2015
12
ADC registers in ATMEGA32. cont’
© Mohamed F.A.B 2015
13
ADC registers in ATMEGA32. cont’
© Mohamed F.A.B 2015
• Bit 7 – ADEN : ADC Enable.
• Bit 6 – ADSC :ADC Start Conversion.
• Bit 5 – ADATE :ADC Auto Trigger Enable.
• Bit 4 – ADIF:ADC Interrupt Flag.
• Bit 3 – ADIE:ADC Interrupt Enable.
• Bit 2:0 – ADPS2:0: ADC Prescaler Select Bits.
14
ADC conversion time.
© Mohamed F.A.B 2015
15
ADC in ATMEGA32.
© Mohamed F.A.B 2015
We need to make digital voltmeter to measure 5 volt power supply.
What about 12V or 24V 
Exercise (1).
We need to make temperature controller using LM35
Temperature sensor.
Exercise (2).
16
Questions:
© Mohamed F.A.B 2015
Thank You All 
17
mo7amed.fawzy33@gmail.com
01006032792
fawzy.fab@gmail.com
© Mohamed F.A.B 2015

07 Analogue to Digital Converter(ADC).2016

  • 1.
    1 07-ADC (Analog to DigitalConverter). By : Mohamed Fawzy Programming AVR Microcontrollers © Mohamed F.A.B 2015
  • 2.
    Lecture Notes: 2 o SetYour Phone To Vibration Mode. o Ask any time. o During labs, Feel Free To Check Any Materials or Internet. o Slides are self content. o Feel Free To Share This Materials With Your Friends. o Work Hard For Achieving Most Of This Course. © Mohamed F.A.B 2015
  • 3.
    3 Don't Forget !!!! ©Mohamed F.A.B 2015 Any Expert Was Once A Beginner 
  • 4.
    4 Lesson(12). © Mohamed F.A.B2015 Lesson (12): Analogue to Digital Conversion.
  • 5.
    5 Lesson (12) Topics. ©Mohamed F.A.B 2015 ► What and Why ADC. ► Characteristics of ADC. ► Interfacing LM35 temperature sensor.
  • 6.
    6 What & WhyADC? © Mohamed F.A.B 2015  Digital Computers uses binary values, but in physical world everything is analog.  Temperature, Pressure, humidity, and velocity are examples of physical quantities.  A physical quantity is converted to electrical signals (voltage or current) using device called sensor.  So, we need Analog-to-Digital Converter to translate the analog signal to digital numbers so that micro- controller can read and process them.
  • 7.
    7 Example. © Mohamed F.A.B2015 Analog Digital 0 1 1 0 0 0 0 1
  • 8.
    8 Characteristics of ADC. ©Mohamed F.A.B 2015  The resolution of ADC is the number of bits at which converted data stored in such as 8, 10, 16 or even 24-bit. Resolution Vref  It is an input voltage used for voltage reference. 𝑠𝑡𝑒𝑝 𝑠𝑖𝑧𝑒 = [(𝑉𝑟𝑒𝑓+) − (𝑉𝑟𝑒𝑓−)] 2 𝐵𝑖𝑡 𝑛𝑜 𝑠𝑡𝑒𝑝 𝑠𝑖𝑧𝑒 = [5 −0 ] 210 = 5 1024 =0.00488 V*1000=4.88 mv  Higher resolution ADCs means smaller step size and high accuracy.  Smaller Vref ADCs means smaller step size and high accuracy. NOTES:
  • 9.
    9 Characteristics of ADC.Cont’ © Mohamed F.A.B 2015 Conversion Time: Conversion time is the time it takes to convert the single analogue sample to digital. o Example. Digital Output= 𝑉_𝐼𝑛𝑝𝑢𝑡 𝑆𝑡𝑒𝑝_𝑆𝑖𝑧𝑒
  • 10.
    10 ADC Features ofATMEGA32. © Mohamed F.A.B 2015  10 bit ADC.  It has 8 analog input channels.  Converted output binary data is held by two registers ADCL and ADCH.  Three options for Vref (VCC or 2.56V or External AREF pin).  Conversion time is defined by crystal frequency connected to XTAL pins and ADPS0:2.
  • 11.
    11 ADC registers inATMEGA32. © Mohamed F.A.B 2015
  • 12.
    12 ADC registers inATMEGA32. cont’ © Mohamed F.A.B 2015
  • 13.
    13 ADC registers inATMEGA32. cont’ © Mohamed F.A.B 2015 • Bit 7 – ADEN : ADC Enable. • Bit 6 – ADSC :ADC Start Conversion. • Bit 5 – ADATE :ADC Auto Trigger Enable. • Bit 4 – ADIF:ADC Interrupt Flag. • Bit 3 – ADIE:ADC Interrupt Enable. • Bit 2:0 – ADPS2:0: ADC Prescaler Select Bits.
  • 14.
    14 ADC conversion time. ©Mohamed F.A.B 2015
  • 15.
    15 ADC in ATMEGA32. ©Mohamed F.A.B 2015 We need to make digital voltmeter to measure 5 volt power supply. What about 12V or 24V  Exercise (1). We need to make temperature controller using LM35 Temperature sensor. Exercise (2).
  • 16.
  • 17.
    Thank You All 17 mo7amed.fawzy33@gmail.com 01006032792 fawzy.fab@gmail.com © Mohamed F.A.B 2015