Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

20 Adc1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Analog to Digital Conversion - Part 1

November 30, 2011

1 Introduction

In this lesson, we explore some elementary ideas concerning analog-to-digital


conversion. Please keep the processor manuals in hand while solving the exer-
cises in this lesson.

2 What is analog to digital conversion?

Most real world sensors convert physical parameters (like say temperature, pres-
sure etc) into some kind of electrical signal. Let us take a commonly available
sensor (Figure 1), the LM35, as an example.
LM35 is a temperature sensor. As shown in the gure, it is a 3 pin device
- Vcc, GND, Vout. If the temperature is 0 degree centigrade, the voltage on
the pin Vout is 0. For every 1 degree rise in temperature, the output voltage
increases by 10mv. So if the temperature is 30 degree celsius, the output on
Vout will be 300mV. If you are able to measure this voltage, you are eectively
measuring the temperature!
Analog to digital conversion is the name given to the process by which you
convert an analog signal (say voltage output of a temperature sensor which can
vary from 0 to 1V) to a discrete, binary pattern. An ADC (Analog to digital
converter) is a device which performs Analog to Digital conversion. A lot of
electrical engineering concepts are to be kept in mind when using an ADC to
build real world systems. We will not deal with these issues in this lesson;
interested students can refer the excellent text prescribed in the References
section of this document to get more information.
Analog to digital convertors are available as independent components - you
can also nd them integrated into microcontrollers (like our MSP430G2231). In
this lesson, we treat the ADC as a black box - we are going to learn about the
nature of the ADC's input and output - but we shall not examine how the ADC
actually performs the conversion .
1

1 It might be interesting for Computer Science students to learn about the

use of the binary search algorithm as part of the AD conversion process; refer:

http://en.wikipedia.org/wiki/Successive_approximation_ADC

1
Figure 1: LM35 temperature sensor

3 A black box view of the ADC

Let us say you have a 3-bit ADC which you are using to digitize an analog
voltage which can assume a minimum value of 0 and a maximum value of 8V.
Now, what do you mean by a 3 bit ADC?
Simple. The output of a 3 bit ADC is a binary pattern of length 3 bits.
Table 1 shows the voltage inputs and the binary outputs produced by our ADC.
Let us look at the table a bit more in detail. The rst thing you notice is
that the ADC is not really capable of giving an accurate representation of all
voltage values - for example, for any voltage input from 0V to just about 0.5V,

Voltage range Binary Output

0 to 0.5 0 0 0
0.5 to 1.5 0 0 1
1.5 to 2.5 0 1 0
2.5 to 3.5 0 1 1
3.5 to 4.5 1 0 0
4.5 to 5.5 1 0 1
5.5 to 6.5 1 1 0
6.5 to 8.0 1 1 1

Table 1: Voltage input Vs Binary output

2
the ADC gives you the same binary pattern, 000, as the output. Then, for
any input from just above 0.5V to about 1.5V, the ADC gives you the binary
pattern 001 as the output. The ADC eectively works by dividing the 0 to 8V
range into eight discrete steps. You note that each step is 1V (except at the
beginning and end).
The number of discrete steps is related to the number of bits in the output
N
- an N-bit ADC gives you 2 steps. You can reduce the size of each step by
increasing the number of bits in the output. For example, in the above case, if
you had a 4 bit ADC instead of a 3 bit ADC, you would have got a step size
of 0.5V instead of 1V (for a voltage swing from 0 to 8V). Commonly available
(and inexpensive) ADC's typically have resolutions of 8, 10 or 12 bits.

3.1 Reference voltage

Let us assume that we are dealing with a 10 bit ADC.


Besides an analog voltage input pin (called say Vin - the ADC will convert
the voltage on this pin to a binary pattern), ADC's typically have two pins
where you can apply a reference voltage - let us call these pins Vr+ and Vr-.
Let us say Vr- is grounded and 1V is applied to Vr+. The signicance of the
reference voltages is that these voltages dene the range in which the ADC
will operate. In this case, our ADC will convert any voltage starting from 0
upto 1V. If the voltage applied to the input pin (Vin) is 0V (ie, equal to Vr-),
the ADC will generate a 10 bit pattern 0000000000. If the voltage on Vin is 1V
(ie, equal to Vr+), the ADC generates the pattern 1111111111.
Let us nd out whether our 10 bit ADC is good enough to measure temper-
ature (ranging from 0 degree celsius to say +50 degree) using the LM35 sensor.
Note that this sensor generates 0V at the output when the temperature is 0
degree celsius - every 1 degree change in temperature results in the voltage out-
put increasing by 10mV. When the temperature is at its peak (+50 degree), the
voltage output will be 500mV.
10
Now, a 10 bit ADC will give 2 (ie, 1024) steps. Let us round this to 1000.
Our reference voltages are 0 and 1V - so each step of the ADC is approximately
1mV; ie, a 1mV change in the input will result in the digital output of the ADC
getting incremented by 1. Because each degree rise in temperature results in a
10mV change in voltage output, the ADC output will change by 10 units for each
degree change in temperature. Our 10 bit ADC is good enough to accurately
measure temperature using LM35!

4 ADC's integrated with microcontrollers

ADC's are available as standalone components - an example is the 0808 from


National Semiconductors - you can nd more details here:

http://www.national.com/mpf/DC/ADC0808.html#Overview.

3
ADC's also come embedded in inexpensive microcontrollers, like our MSP430G2231.
The MSP430 family guide (available from the course web site: http://recursive-
labs.com/datasheets/msp430-family-guide.pdf ) gives a detailed description of
the ADC integrated with MSP430 microcontrollers. You will also nd the docu-
ment http://recursive-labs.com/datasheets/msp430g2x31.pdf useful for nding
out the pin numbers associated with the ADC. Please keeps these documents
at hand while solving the exercises in the next section.
Having an ADC integrated with a micrcontroller is very convenient - it be-
comes easy for us to write programs which monitor outputs from various sensor
elements. In the coming lessons, we will get a chance to use the ADC to perform
some interesting experiments!

5 Exercises

The objective of the exercises is to get you acquainted with some of the terms
associated with AD converters (and also to make you read part of the processor
manual explaining the working of the ADC - don't worry if you do not under-
stand most of the things that you read in the manual - that is to be expected!).

1. Which of the following is not an error associated with ADC's:

(a) Non-linearity

(b) Missing Code

(c) Missing Data

2. The MSP430G2231 has a

(a) 12 bit ADC

(b) 8 bit ADC

(c) 10 bit ADC

3. Aliasing is a problem associated with AD conversion

(a) True

(b) False

4. Which of the following is not a register associated with the ADC in the
MSP430G2231 processor?

(a) ADC10DATA

(b) ADC10MEM

(c) ADC10AE0

5. Which of the following is not a bit in the ADC10CTL0 register?

4
(a) ADC10IE

(b) ENC

(c) ADC10STP

6. The ADC in MSP430G2231 has:

(a) 8 channels

(b) 6 channels

(c) 4 channels

6 Reference

MSP430 Microcontroller Basics - by John H Davies. This book has a thorough


treatment of the programming as well as electrical aspects of microcontroller
based system design. Available from ipkart.com.

You might also like