Using ADCs

From OpenCircuits
Jump to: navigation, search

( this is a fairly early draft, more will come )

Introduction

An ADC or analog to digital converter is a useful device to bridge the analog world to the digital world. For example there is a useful device called the LM35 which outputs a voltage that is directly related to the temperature. If you have a PIC877A it has an ADC which can convert this voltage to a digital value of 10 bit precision. At that point you can treat the temperature as any other value in the microcontroller. Sometimes ADCs are found as components inside a microcontroller, others are packaged by themselves.

So this note will discuss some of the ins and outs of ADCs.

Some Theory

What does an ADC do: it converts a continuously variable voltage ( in theory any analog quantity, but in practice almost always voltage ) into a digital value. Normally there are three analog voltages involved. Two of these are normally constant: they are the low reference voltage and the high reference voltage ( typically both must be greater than 0 volts and less than the ADC power supply ). Often they are 0 and the power supply, but sometimes the ADC has internal voltage references that can be used. Do not make the mistake of thinking you are not using reference voltages, you are, but they may be defaulting to some value specified in the data sheet or by configuration set up. Often both voltages may be set via input pins.

When an ADC make a voltage reading it typically takes some time, often time to acquire the signal and then additional time to measure it. Look at your spec. sheet to see how yours works. The measurement when done determines the voltage from the low reference to the high reference into a value from 0 to the highest value the converter can represent. What is the high value? Normally all 1 in the digital value the converter outputs: for an 8 bit converter one of 256 values, for a 10 bit converter one of 1024 values. For a 8 bit converter each step represents 1/255 of the range between the low reference ( output of 0 ) and the high reference ( output of 255 ) The formula for the measured voltage is:


v = v_ref_low + ( ( ( v_ref_high – v_ref_low ) / 255 ) * count )

where count = digital output of the ADC

Hardware

There are a few tricks with the ADC. First ADCs really do not like voltages that are two low or too high. These voltages are usually 0 and the power supply voltage of the ADC. So you should make arrangements not to exceed these voltages. Additionally the equivalent resistance of the voltage source should be reasonable low say 10 K ohms. So you need to check your input to make sure you stay within this limit. ( for your device check its data sheet ).

While many people do not use the next feature it can be very useful: it is the ability to set the upper and lower voltage reference ( if you do not set them they usually default to 0 and the power supply voltage ).

So what is the digital value that you read from the ADC? It depends upon the number of bits and the upper and lower voltage reference.



Where

= input value read by the ADC


=


=


= number of bits read


Some examples:

for an 8 bit conversion with 0 and 5 volts reference each input bit represents a voltage of .0275 volts if the reference is instead 0 and 2.5 volts each input bit represents a voltage of .0098 volts ( half the prior amount )

for an 10 bit conversion with 0 and 5 volts reference each input bit represents a voltage of .00498 volts

So what is the use of these reference voltages? If you voltage is only in the range from 0 to 4 volts then you get more accurate readings using a references of 0 and 4 volts.

Now if you stick to reference voltages of 0 and 5 and have input voltages of values that do not match well to 0 to 5 volts what do you do? If the voltage is 0 to something higher than 5 volts you can use a voltage divider to adjust the voltage. It is not perfect as you have to design the divider so that it equivalent resistance is 10 k or less. If you have an input voltage of 0 to 1 volt then you will waste most of you input readings ( from 1 volt to 5 volts ).

A more general solution to input conditioning is to use operational amplifiers. The general solution is to use an adder-sub tractor circuit. In this type of circuit you an either amplify a small signal or attenuate a large signal. Additionally you can offset the the output voltage either adding a constant amount to the value or subtracting one. Using this you should be able to get most voltages within the two reference voltages. I should note here that the output resistance of an op amp is low so the resistance into the ADC is not an issue.

An additional advantage with an op amp can be realized by using a rail to rail op amp with a single power supply of 5 volts. With such an op amp you cannot have input to the ADC that is out of range.


A circuit:

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox