Sie sind auf Seite 1von 13

10/17/2016 Analog To Digital (A/D) Converters

Analog to Digital Converters (A/Ds)


What Are They?

Some Properties Of A/D Converters

Where Do You Use A/Ds?

You are at:  Bits&Bytes - Interface Circuits - Analog To Digital Converters (A/Ds) 
Return to Table of Contents

A/D Converters

        Analog-to-Digital converters - a.k.a. A/D converters - are widely used by many engineers
and scientists of all types, often without their realizing it.  Whenever they make a measurement
of a voltage, and that measurement is taken into a computer, an A/D is used.

        If you're going to take measurements - and just about every engineer will do a lot of that -
then you will be better off if you understand some of the basic ideas behind A/D converters. 
There are two simple goals for this lesson.

  Given an A/D converter with a given range and number of bits,

  To be able to calculate the resolution of the converter.

  Given an A/D converter in the laboratory,

  To be able to determine the resolution of the converter and the number


of bits used in the converter.

What Are A/D Converters?

        A/D converters are electrical circuits that have the following characteristics.

The input to the A/D converter is a voltage.


A/D converters may be designed for voltages from 0 to 10v, from -5 to +5v, etc., but
they almost always take a voltage input.  (Some rare exceptions occur with current
inputs!)  In any event, the input is an analog voltage signal for most cases.
The output of the A/D converter is a binary signal, and that binary signal encodes the
analog input voltage.  So, the output is some sort of digital number.

        A comparator can be used as a simple one-bit A/D converter.  Although a converter with
just one bit isn't particularly useful, you can begin to see how an A/D converter works by
puttering with it for a moment.  If you read the lesson on comparators you encountered a
simluation of a comparator.  That simulator is reproduced below.  Click here if you want to read
the lesson on comparators. 
https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html 1/13
10/17/2016 Analog To Digital (A/D) Converters

Comparator Simulator

Sim1  Here is the comparator simulator.  You can think of a comparator as a one-bit A/D
converter.  The input is an analog signal, and the output is a one bit digital representation of the
analog signal.  In the simulator, you can control a simulated voltage source that is the input the
the comparator, and the digital output bit is indicated with a simulated LED.  Notice the
following.

The input can range from zero (0) to ten (10) volts.
When the input voltage goes above five (5) volts, the output is a binary one (1) and the LED
lights.  When the input voltage is less than five volts, the output is a binary zero (0) and
the LED does not light.

Properties of A/D Converters

       The comparator simulation reveals a few important facts about A/D converters.

An A/D converter has a range.  The simulator has a range from 0v to 10v, or a total of ten
(10) volts.  The total range of an A/D is the difference between the highest and lowest
voltages the A/D can convert.
An A/D has a resolution that is determined by the largest count that the A/D's
counter/register can hold.
The largest count is determined by the number of bits in the counter.
If there are N bits in the counter, the largest count is 2N-1.
In the comparator, there is only one bit, and the largest count is 1, and there are only
two different outputs that are possible.

        Clearly, if you want a more accurate conversion the converter will need to have a lot more
than just one bit.  Let's look at another simulation.  This simulation is a four-bit A/D converter. 

Four Bit A/D Converter Simulator

Sim2  Here is a simulation of a four bit A/D converter.  Note the following:

https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html 2/13
10/17/2016 Analog To Digital (A/D) Converters

As in the comparator simulation, we assume that the input voltage can range from zero (0)
to ten (10) volts.
We have added some "fine control" with two buttons that "nudge" the voltage up or down,
but not beyond the 0-10v range.

Try the simulator first, and then we will examine what happens in a little more detail.

        Now, consider the following observations about the converter above.

There are four bits in the simulation converter.


The range is from 0v to 10v, or 10v total range.
With four bits, there are 16 different count values (0 through 15).
Thus, 10v is divided into 16 different parts, each part being:
10/16 = 0.625 volts wide.

        Now, let's consider an example question.

Example

E1   How many bits would you need to divide 10 v into .01 v intervals?  To get the answer to the
question consider the following.

If you divide 10 v into .01 v intervals you need 1000 intervals.


If you need 1000 intervals you need to think about a power of 2 that is larger than 1000.
The smallest power of 2 that is larger than 1000 is 210 which is equal to 1024.
That means that you need 10 bits in the converter, and the the count in the
counter/register will run from 0 to 1023.
And that leads us to observe that real converters often go to 10.23v, not 10v because that
gives perfect .01v increments between resolvable voltages.
And another converter might run from -5.12v to +5.11v for the same reason.

        Almost all A/D converters use a scheme in which the analog voltage is first converted into
a binary integer (a "count", as in the simulator above) when the conversion is done.  In some
cases, there may be some software that gives you the actual count - the binary integer.  In

https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html 3/13
10/17/2016 Analog To Digital (A/D) Converters

other cases the conversion might be converted - using software - to a a numerical value or a
character representation of a numerical value. 

Example

E2   A GPIB (IEEE-488) voltmeter is used to measure a DC voltage.  The instrument uses an A/D
converter that generates a binary number.  Within the instrument, that binary number is
converted to a string of characters which is, in turn, transmitted to a computer connected to
the instrument. 

        To illustrate the concept in the example, consider the revised simulator below.  In this
simulator, the conversion algorithm - from the count in the register to an analog voltage - is
given by:

Vmeas = Count*0.625
Note:  .625 = 10/16 = Range/#Counts

Here is the simulation.

Four Bit A/D Converter Simulator (Revised)

Sim3  Here is a revised simulation of a four bit A/D converter.  Note the following:

Vmeas = Count*0.625
Vmeas is displayed on the simulation.

        Of course, the simulation only raises a few more issues.

The largest issue is that the computed voltage is always lower than the actual voltage.
The average error would probably be less if we used a different way to compute the
computed voltage.
The formula for the computed voltage is:
Vmeas = Count*0.625

https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html 4/13
10/17/2016 Analog To Digital (A/D) Converters

        Using this expression for the calculated voltage, we can plot the calculated voltage as a
function of the count.  That's shown in the figure below.

Even more interesting is the plot of the calculated voltage against the voltage input that is being
measured.  That's shown next.  We've also included a plot (the blue line) that shows what the
output would be ideally (And that might take many, many bits in the converter!).  Notice that the
calculated voltage is always lower than the voltage input using the calculation method we
assumed above.  Note also that the largest error occurs just before the converter switches
when the voltage is rising.  For example, as the voltage rises from 0v to 3v, there is a time when
the converter output switches from 0v to 0.625v.  The largest error occurs just before that
point, so a bound on the error is:

Error < 0.625

https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html 5/13
10/17/2016 Analog To Digital (A/D) Converters

        We can reduce the error if we calculate the voltage differently.  We can examine what
happens if we use a different expression for the computed voltage.  We will use:

Vmeas = Count*0.625 + 0.3125

The result is shown in the next simulator.

Now, here is a plot of the calculated voltage against the voltage input that is measured.  Notice
that the error limit is half of what it was using the first calculation method.

       The conclusion is that the way the voltage is computed can affect the average error when
an A/D is used to measure voltage values.

        Whenever you buy an A/D converter, or a voltmeter, or a data acquisition unit, you need to
be cognizant of how the data presented to the user is actually computed.  That's not usually a
problem in instruments, but there are A/D computer cards that use the first method above to
calculate voltage, and you should be aware of that when it happens.  It is less important when
the number of bits in the converter is higher, but when you have high requirements for
accuracty you should be thinking of what might be taking place.

https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html 6/13
10/17/2016 Analog To Digital (A/D) Converters

The Effect of Number of Bits

        The number of bits used in the counter also affects the accuracy of the conversion.  Again,
we will use a simulation to show the effect of the number of bits. 

Six Bit A/D Converter Simulator

Sim4  Here is a simulation of a six bit A/D converter.

Run the simulator, and compare results with the four bit simulators above.

        We can think a little bit about error in an A/D.  First, note that the error limit depends
upon the range and the number of bits.

If there are N bits, the number of divisions is 2N-1.


If the total range of voltage is VRange, then the size of a division is:
SmallestDivision = VRange/2N
The error is related to the Division size.
If the calculated voltage is SmallestDivision*Count, the error is the same size as the
smallest division.
If the calculated voltage is SmallestDivision*Count + SmallestDivision/2, the error is
SmallestDivision/2, i.e. half the size of the smallest division.
See the simulations above for a better appreciation/understanding of the error.

        We're not going to give you any more simulators with more bits.  Actually, we've almost
reached the resolution limit for the screen.  The simulators with the "nudge buttons" just nudge
the controls by a single pixel, and that is too much for a twelve bit converter, for example.

Example

E3  A popular A/D board gives a count and requires you to perform the computation shown in the
line of C code shown below.  The variable binary is the count value that is returned.
https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html 7/13
10/17/2016 Analog To Digital (A/D) Converters

MeasuredVolts = (((binary-2048)*20)/4096);

The A/D converts voltages from -10v to +10v.  We can conclude the following.

The converter has 12 bits.  You get that conclusion by noting that the count can vary
from 0 to 4095.  When the count is 0, MeasuredVolts = 0.

        Let's sum up a few points.

More is better when it comes to bits in an A/D.  The indicated voltage will be closer to the
actual value of the voltage being measured when there are more bits.
More is pricier when it comes to bits in an A/D.  It takes more parts, and they have to be
made more accurately if there are more bits.

How Does An A/D Work?

        While we have discussed A/D converters above, we haven't yet given you any insight into
how you could build an A/D.  Here we will discuss a simple way to build an A/D.  This might not
be the fastest A/D possible, but it will start to give you some insight into what happens inside
an A/D.

        The circuit is shown in the simulator below.

Simulator - Showing How You Might Construct An A/D

Sim 5  This simulator is a four bit A/D, and it consists of the following components.

A pulse generator that produces a sequence of 0's and 1's.


A counter which counts the pulses and produces an increasing count.
The counter has a "Stop" input.  When that input goes high, the counter ceases to
count.
A D/A which produces an analog signal proportional to the count output from the counter.
An adjustable input voltage source.
A comparator which produces a "1" when the D/A output is larger than the input voltage.
The output of the comparator is used to stop the counter.

Here is the circuit.

https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html 8/13
10/17/2016 Analog To Digital (A/D) Converters

Here is how the A/D Simulator works.

First, set a DC voltage from the adjustable source.


Second, click the "Convert" button.
The counter begins counting, and the count is displayed on the LEDs and the
numerical value of the count is displayed.
The digital count signals (four bits of signals in this case) form the input to a D/A
converter which produces an output voltage proportional to the count.
The output voltage from the D/A is compared to the input voltage.
When the output voltage from the D/A becomes larger than the input voltage the
comparator develops a "Stop" signal that is used to stop the counter.
The count that remains in the counter is a digital representation of the input voltage.

Try the simulator, using different voltages within the allowable range, i.e. 0-5v.

       The simulator lets you see the inner workings of one type of A/D converter.  Note the
following about any A/D converter.

The conversion takes time.  In the simulator, there is a variable amount of time until the
counter reaches the correct count.  We have slowed down the simulator so you can see
what happens, but even in the best A/Ds there is some time that must elapse between the
start of a conversion and the end of a conversion.  That time limits how many conversions
can be done per second.  People have worked on that problem and there are other kinds of
converters that convert more quickly.
The conversion is not exact, and the accuracy depends upon the number of bits in the
counter.
The result of the conversion is an integer, and that integer still must be translated into an
equivalent voltage (although the conversion isn't hard to do).

Practical A/Ds

https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html 9/13
10/17/2016 Analog To Digital (A/D) Converters

        Now, consider what happens in a typical application of an A/D.  We'll look at a voltmeter. 
In a voltmeter, this is what happens.

A voltage is applied to the voltmeter, and an A/D converts the voltage to a count.
The count is converted to a floating point number.
The floating point number is displayed on an LCD or LED display.

If the voltmeter is connected to a computer (say through an IEEE-488 bus) the following also
takes place.

The floating point data is converted to a character representation to transmit over an


IEEE-488 or internet connection.

        You can see that there are a few conversions that have to take place in this process. 
There are a number of other considerations here as well.

The number of bits in the A/D converter will affect the accuracy of the voltmeter.  There
is a lot of legend and lore in that area.  Click here to examine that.
You need to be aware of how to make conversions.  Actually, you need to become
knowledgeable about the different representations as well as how to program those
conversions in various programming environments like C, C++, Visual Basic and LabView.

         A/D converters are found in many places - including places where you might not think that
you would find them.  Here are a few.

Voltmeters are digital today.  To display a digital result for a voltage measurement the
voltage is first converted to digital form in an A/D, and then it is changed to a decimal
format to be displayed.
A/Ds are used in digital thermometers, so if you've spent some time in the hospital, you've
used an A/D.

And, you get the idea.

        However, there is an important situation where you need to dig deeper into how A/Ds
operate, and how they interface with the software and hardware that is often used in
measurement and control situations.  Let's think about a few typical situations.

Assume that you are recording temperature at four points in a heat-treating oven.  You
need to do the following.
You need to get the data into a computer and you need to compute and record the
average temperature (the four temperature data points).

https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html 10/13
10/17/2016 Analog To Digital (A/D) Converters

You have three tanks used for chemical processing.  You need to control the level of the
liquid in the three tanks.  Each tank has a small computer with an A/D board that measures
and controls the liquid level in each tank and also measures the temperature.  Each
computer has a network card that connects it to an Ethernet LAN.  There is a central
computer on the LAN and you need to send information from each of the control
computers to the central computer.
You need to take the data at each computer and you need to transmit it over the
network to the central computer so that it can be recorded there and be available
for any computations that might be necessary.

        In both of these situations you need to consider how to manipulate the data that you
measure and want to store.  Here are some of the considerations.

If you take data with an instrument connected to a computer (like a data acquisition unit or
a voltmeter) the instrument may be connected to the computer with an IEEE-488 (GPIB)
connection.  (Click here to learn more about IEEE-488.)  IEEE-488 connections have some
considerations.
Most IEEE-488 instruments convert data into strings of characters and those
strings are transmitted to the computer.
If you send data over a network, you must send strings of characters.

        The conclusion that you need to reach is that you need to be aware of how data has to be
converted in these kinds of situations.  Let's look at the sequence of operations you might face.

The A/D converter gets some raw data or information and it is in the form of an integer
count.  Often it is simply a binary number represented with some fixed number of bits.
The count could be a number like 10001000 (or 129 in decimal numbers).
If the A/D converter has eight (8) bits or less, the data will take a single byte.
If the A/D converter has more than eight bits (which is typical) the data will take
more than one byte.  Usually, for most converters, the data will take two bytes, since
most converters are 10, 12 or more bits.
The count is converted to a number that represents the voltage (or possibly some other
physical variable).  That takes some computer code (And there will probably be some sort
of computing chip in the instrument.) and the process results in a number that is probably a
floating point number.
The floating point number might be something like 3.1416v.
If you transmit that floating point number you need to generate a string of characters.
The string of characters might be something like a "3", a period ("."), a "1", a "4", etc.
In many cases you may need to add one or more characters to signal the end of a
string.  That could be a carriage return and a line feed, for example.

Representing Instrument Data

https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html 11/13
10/17/2016 Analog To Digital (A/D) Converters

        Taking data with an instrument immediately leads you to consider several things about
data.  Here is a sample.

If you take a lot of data, you need to know how the data is represented.
If you take a lot of data, you need to know how the data is transmitted from the
instrument to a computer.
If you take a lot of data, you need to know how the data you get will be stored if you store
it in a computer file.

Digital Voltmeters

       Digital Voltmeters are a special case of A/Ds.  Obviously, if voltage measurements are
taken and the results are displayed digitally with LED or LCD displays, the instrument has to
contain an A/D converter.  Digital voltmeters have some characteristics that you might need to
understand.  You can click here for more material on digits in digital voltmeters.

Digital voltmeters usually have scales that are 0-0.3v, 0-3v, 0-30v, 0-300v, etc.

You need to learn a little terminology and the reasons for the terminology.  Let's take a look at a
sample voltmeter.

Example

E4   Consider a voltmeter built around a 10 bit A/D converter.  We will assume the following.

The range of the voltmeter is from 0-3v, and it does DC voltage measurements.  It does
not measure negative voltages.

Then, with 10 bits we can draw these inferences.

Ten bits will produce 210 intervals.  That's 1024 intervals.


If there are 1024 intervals over a range of 3v, each interval will be 3/1024 = .00293v.
It is easier to compute the displayed voltage if the interval is adjusted to .003v.
That would make the range 0-3.072v.  (That's .003 x 1024.)
If you are measuring a voltage that varies around 3v, that would allow you to keep the
range the same, but still change the range when the voltage got large enough. 
Manufacturers like to build in a little "hysteresis" to prevent constant range changes
in situations like that and it might be especially hard on auto-ranging meters.
If you wanted to measure negative voltages and have the range be from -3v to +3v, you
would have intervals of .006v, and the meter would measure from -3.072v to +3.072v.
If you wanted to measure voltages on a 0-30v scale, you would probably use a voltage
divider or some other way to reduce the voltage by a factor of (exactly) 10 (i.e., multiply it
by exactly 0.1) and then use the same converter as on the 0-3v scale.

If we could use a 12 bit A/D, then some conclusions would change.


https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html 12/13
10/17/2016 Analog To Digital (A/D) Converters

Twelve bits will produce 212 intervals.  That's 4096 intervals.


If there are 4096 intervals over a range of 3v, each interval will be 3/4096 = .000732v.
It is easier to compute the displayed voltage if the interval is adjusted to .0075v.
That would make the range 0-3.072v - just as it was in the case of the 10 bit
converter,
That produces the same advantages as you had with the 10 bit converter.
If you wanted to measure negative voltages and have the range be from -3v to +3v, you
would have intervals of .0015v, and the meter would measure from -3.072v to +3.072v.

        At this point, you should have a good idea about how the number of bits in an A/D
converter determines the accuracy of the converter - i.e. the resolution of the converter.

        You also need to learn how to determine the resolution of an instrument in the laboratory,
and relate the resolution of lab instruments to what you know about the number of bits in a
converter.  You can click here for an laboratory exercise which leads you through getting the
number of bits in the A/D converter inside a voltmeter.

Problems

Getting specs for a D/A board

Links to Related Laboratory Work

Determining the Number of Bits in the A/D inside a Voltmeter

Links to Related Lessons

Interfaces - Comparators
Interfaces - D/A Converters
Interfaces - A/D Converters
Interfaces - Digital Voltmeters

Return to Table of Contents

Send us your comments on these lessons.

https://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Interfaces/ConvAD.html 13/13

Das könnte Ihnen auch gefallen