How do Analog to Digital Converters Work?

Well, I’ve got an electronics test tomorrow (in a chemistry class, go figure) and although I understand most of it perfectly well, I have yet to figure out how an A to D converter works. The problems provided by the professor were no help, as I could never find a way to solve them or a resource that had something similar. So, can you guys tell me how they work? And maybe, if it’s not too much trouble, how a D to A converter works as well?

Without knowing exactly what level course this is or what your professor has taught, any explanation I give might do more harm than good (unless all you need is “it converts an analog signal to a digital one”). Most importantly I don’t know at what conceptual level you need to know how it works, or whether you’re studying a specific architecture or not.

But I can provide you with at least a few resources … the manufacturers’ technical documents might help you, or they might be too much, I don’t know. A decent, if brief discussion of data converters (especially different methods) is in Texas Instrument’s Data Converter Selection Guide (file is pdf, link is not).

Other manufacturers are Analog Devices and Linear Technologies; look up data converters or ADC.

Well, it’s an analytical chemistry class.

Let me see if I can give a basic background. I know what a comparator is. It takes a voltage and compares it to a threshold voltage. If the input voltage is at or higher than the threshold voltage, it comes out as a 1. Lower comes out as a 0.

That’s about it. His explanations have been less than helpful.

As I understand it, an A to D converter analyzes an analog signal’s sine wave pattern and assigns a 1 to the peaks and a 0 to the valleys.

I just searched the net for it:

How do ADCs work?

Analog-to-digital converter architectures offer assorted speeds and resolution in test equipment.

Plenty to read at:
http://www.e-insite.net/tmworld/index.asp?layout=article&articleid=CA224083

I’ve looked all over the net but never found that.

Thanks a lot.

Well, now that I think about it, maybe an example problem would help.

The question is, basically, given that the component drawn is an A/D converter, and the input signal is 2.49 volts, what is the output in binary?

If I was pressed for time on the test, I would probably either give two or zero and go on. But that just doesn’t seem right.

A couple more things must be specified:
– What is the resolution of the ADC (i.e. how many binary bits)?
– What is the full-scale voltage it’s measuring?

Let’s say it’s a 10-bit ADC set up to measure 0 to 5 volts. That means a signal of zero volts (or lower) corresponds to an output value of 0, and a signal of 5 volts (or higher) yields 1023. A signal of 2.49 volts would yield a decimal value of 1023*(2.49/5) which works out to be 509. (Convert 509 to binary as necessary).

“The question is, basically, given that the component drawn is an A/D converter, and the input signal is 2.49 volts, what is the output in binary?”
They’ll need to specify the voltage range that the A/D operates over, and how many bits it it uses.

An 8 bit A/D can output 256 (2[sup]8[/sup])distinct values.
Those values are uniformly distributed over the voltage range. So if your 8 bit A/D measures voltages between 0 and 5 volts, 2.49 volts would give an output of (2.49/5) * 256 = 127 = 7F hex = 01111111 binary.
A 16 bit A/D can output 65536 (2[sup]16[/sup])distinct values. So with again a 5 volt range, you get an output of (2.49/5) * 65536 = 32636 =7F7C hex = 0111111101111100 binary.

Okay, thank you guys. That’s the math I wasn’t able to figure out.

I believe the problem makes the A/D have 8-bit resolution–at least, that’s the size of the answer box he gave us. And since this is just part of a only somewhat-related class, everything is at a fairly general level and that should cover it.

Now, if only I can remember the truth tables for D and J-K flip flops…

So, here’s some basic A/D theory. Remember I’m a programmer who dabbles in hardware, not a real EE, so some of this may be wrong.

(On preview I see that Handy has beaten me to it with an excellent page. Look at his page as you read this!)

An A/D converter is made from two basic building blocks:

A source of known voltage. (Usually a voltage divider circuit.)

and

A comparator. (Which tells you if your unknown voltage is greater or less than the voltage from the known voltage source.)

A brief note about how both of these elements work…

The voltage divider is a simple but ingenious circuit made from just two resistors and some wires. There’s discussion of the most basic kind here:

http://www.saburchill.com/tech/electronics/elect003.html

Basically, if you connect two resistors together in series, and apply a voltage to them, the voltage at the point inbetween the resistors will be some fraction of the input voltage. What fraction will be roughly determined by the the ratio of values of the two resistors. The actual formula is, I believe: Vbetweenresistors = Vin*R2/(R1+R2). It takes some algebra to get that formula out of the two formulas given on the page. If you want to verify that, feel free - I’m too lazy.

The comparitor, I’m not so sure how that works. I know that in practice we use op-amps as comparitors, because that’s just how they work. And I know an op-amp is basically just a circuit made of both NPN and PNP transitors. But beyond that my understanding is fuzzy. Anyway, I think most people understand comparators intuitively - you feed two voltages into it, and the thing tells you which one is greater.

With those building blocks, you can make at least two differnet kinds of A/Ds. The simplest A/D, called a “flash” A/D, is made something like this…

It starts with a bunch of voltage dividers, each putting out a slightly different voltage. For instance, you might have voltages of 0v, 1v, 2v, 3v, etc… Except the people who build the circuit make each voltage exactly equal to some specific digital output value, so the voltages would probably be powers of two or something. Anyway, each voltage is fed into one input of a dedicated comparator. That’s right, each voltage divider has its own comparator. The comparator’s only job is to compare the known voltage from the voltage divider to the unknown one that you’re trying to measure. After that, you simply feed the unknown voltage into the other input of all those comparators simultaniously.

Now it’s a simple matter to look at the output of each comparator, and see where along the line the comparators stop saying “unknown voltage is more than my reference voltage” and start saying “unknown voltage is less than my reference voltage.” The unknown voltage must be between those two known voltages. So you fudge and say that the unknown voltage is halfway inbetween the two known ones. Since the digital number that comes out is usually limited to some small number of bits (generally 4-12), this approximation doesn’t usually hurt you very much - you knew you were only going to get an approximation, because a digital number cannot usually perfectly represent an analog value.

(Actually, getting the digital output is really even easier than that. If you set up the reference voltages correctly as powers of 2, then the output of the comparators actually ARE the bits of the binary digital value, and you can just pick them straight off the comparator outputs and send 'em out. But I’ll leave that for you to ponder on your own.)

This kind of “flash” A/D has both advantages and problems. It’s good because it compares the unknown voltage to every known voltage simultaniously, which makes it very fast to measure the unknown voltage. The downside is that if you want a good estimation of the unknown voltage, you have to have a LOT of reference voltages to compare to, and that means a LOT of resistors and a LOT of comparators all running simultaniously. This takes a lot of power, which can be a problem in itself if the thing you’re building runs on batteries. Lots of power consumed also usually leads to lots of heat, which can cause the resistors to become slightly more resistant, which slightly alters the voltage coming from the voltage dividers, thus throwing your measurement off. Also, things that get hot and stay hot all the time tend to wear out and break down much faster than things that stay cool.
To address the problems of flash A/Ds, someone came up with the idea of “successive approximation” A/Ds. The idea with these is that you only have one voltage reference - but it’s a variable one and can be changed to whatever voltage you want. And you have some kind of circuitry to set the variable voltage reference to 0v initially, and then at each step to a larger and voltage. At each step, the comparator (only need one) compares the voltage reference to the unknown signal. At some point, the comparator will stop saying “unknown voltage is greater than known voltage” and start saying “unknown voltage is less than known”, and at that point you know, approximately, what the unknown voltage is.

Actually, again, you can be more clever than that. You can start by setting your voltage reference to halfway inbetween the minimum and maximum voltages, and see what the comparator says. If it says more, then you set the voltage reference to halfway between the middle voltage and the max voltage, and check the comparator again. And so on. This allows you to cut your range of measurement in half each time, and is significantly faster than just checking agains 0v, then 1v, then 2v, then 3v, etc… For the computer geeks, it’s an O(n) vs O(log(n)) difference.

A successive approximation A/D is a lot cheaper to make and consumes a lot less power because it simply has quite a bit less circuitry. A 12-bit flash A/D has to have 2^12 comparators and 2 * (2^12) resistors. I don’t even need to do the math to know that no matter how complicated or clever you make the successive approximation A/D, you’re not going to come anywhere near that number.

On the other hand, a 12 bit successive approximation A/D is going to take at least 12 times as long to give you the digital equivalent of an analog signal. If you’re recording music digitally, that can be quite signficant. Think of only being able to record every 12th note!
I was going to throw in some more circuit diagrams here, and maybe explain D/As as well, but I think I’ve blasted enough information at you for now. If you care, you know where Google is.

HTH!
-Ben

Xema has it right, I think.

An Analog to Digital converter takes a continuously variable input, samples it at one point in time, and outputs a number that corresponds to that measurement. They may sample very slowly or very quickly, up to many thousands of times a second. For each sample you get one number.

The number will be determined by the resolution (usually specified in bits) and the range of input it is designed to handle.

A very low resolution converter might be 3 bits. With three bits, you can have only eight different numbers, 0 through 7. So whatever input range you feed it, you get one of those eight numbers out. If the input range is 0 to 5 volts, you get eight voltage ranges:
0 (or lower) to .625 = output 0, binary 000
626 to1.25 = output 1, binary 001
1.26 to 1.875 = output 2, binary 010
1.876 to 2.5 = output 3, binary 011
2.51 to 3.125 = output 4, binary 100
3.126 to 3.75 = output 5, binary 101
3.76 to 4.375 = output 6, binary 110
4.376 to 5 (or higher) = output 7, binary 111

When you sample the voltage, it will be in one of these eight ranges, and the output will tell you which range. The more bits, the smaller the ranges, and so the resolution get better.

There are different techniques for A/D sampling and coverting and some are quite simple in concept. For instance, let’s suppose you have an analog input between 0 and 1 volt and you want to convert it to a digital ouput with 6 bits resolution.

You build a circuit which generates a ramp starting at 0 and going up to 1 V in a period of time T. as the ramp starts you have a 6 bit counter which progresses from 0 to 111111 also in a period of T. The ramp and the analog input are fed to a comparator and when the ramp reaches the analog input value the counter is stopped and the value fed to a latch register where it is kept until the next value comes in. As you can see it is quite simple.

Or, more simply, build things so that the voltage for the comaprison is generated from the digital outputs of the counter.
And yeah, there are a zillion ways to do analog to digital conversion.
There are flash converters (used for low bit counts) that use a shit pot full of window comparators to convert signals damned near as fast as the analog signal.
There are dual slope converters that work much like the one sailor described, only much faster and they converge from above and below to the correct value.
There are pulse width modulator converters that use trains of variable length pulses and an integrator to generate the comparison voltage.
Some AD converters have only analog filters on the input, and some have none at all. Some high precision units have a simple analog filter that won’t screw up the phase of the signals in the frequency range that is to be measured, and they AD converter oversamples by some rediculous number (256X) then digitally filters and downsamples the signal so as to get rid of aliasing (frequencies above the sampling rate that get mirrored back to below the actual sampling rate) without screwing up the phase relationships of the signals you actually want to measure.

As you see, it is a wide field.

I do not think that is simpler as a ramp generator is simpler than the D/A converter you propose. In any case, I know of many ways to do it and I am sure there are many more ways I have not seen yet. I was just showing a very simple conceptual way of doing it.

It is also a simple task to show the position of a joystick or other pot or variable resistor as it is easy to see how long it takes to charge a capacitor though it. Just count the time it takes to charge.