|
|||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||
|
|
![]()
It Takes a Little D to A to Get a Little A to D
In response to the previous article, an astute reader wrote:
Regards, Mike, you are correct. We place the analog information from the world into
'digital buckets.' I think the reason we do this is to facilitate decision making,
to limit the store of information, and to ease communication. We impose a digital
perception when it makes sense to do so. A better phrase may have been "the
world is analog in nature upon which we impose our perceptions." With that in
mind, lets look at some more of the nuts and bolts of A to D conversion.
ADC stands for 'Analog
to Digital Conversion.' How do you do this? In many cases, you
begin with a DAC (Digital to Analog Converter) and a simple comparator. Remember
the comparator circuit from previous articles that used an op-amp? The op-amp
would output a high or low signal depending on whether one input was above or
below the other. The is a great time to use a comparator as digital circuits
like obvious signals such as 'high' and 'low'. So here is the basic process:
You convert a digital
number to a known analog level, compare that to an analog signal, and if it
is close to the same value (here is where resolution counts), the digital number
you output represents the analog value. Here is a simple diagram of the process.
![]() Let's do an example. You are converting an analog signal with the actual value of 4.5. You try outputting a 1 on your DAC. The comparator says 'higher.' You then try outputting a 2. The comparator says 'higher.' You try a 3, then a 4. Guess what the comparator says each time. That's right. It says 'higher.' (You probably played this game a kid. You know, the one where you are either getting hot or cold.) So what do you try next? Of course, you try a 5. Then the comparator says 'lower.' Now your circuit knows that the value is between 4 and 5. It makes a guess and picks one of the two. The more resolution (resolution means smaller step size) that your DAC has, the closer you can estimate the value of the analog signal. There is a better and faster way than just sweeping across all the values in the range. What you do is make your first output on the DAC equal to 1/2 the range. In this case it would be 2.5. Then you look at what the comparator says and make a logic decision (digital is good for this sort of thing.) If the comparator says 'higher,' you can eliminate everything below 2.5. So you make your next output equal to 1/2 of the remaining range, which, in this case, is 3.75. Look at the comparator again, and eliminate some more possibilities, then output 1/2 of the remaining range. Repeat this process until you are out of resolution, and you will have an approximation of the analog signal. This is a very fast way of approximating an analog signal known as successive approximation. It is often used when high-speed analog to digital conversion is needed. Did you notice that I often use the word "approximation" as the A to D process takes place? This is because a digital signal can never truly equal an analog signal; it must always draw the line somewhere. Do not forget that "digital" means there are discrete steps involved. Analog has by definition, infinite increments. Now that you have the basic idea behind the A to D conversion process, lets look at some examples of DAC circuits that could be used. The R2R ladder: ![]() This is a neat way to get a digital voltage level, and you can get the R2R ladder in a nice compact package. You must take care not to hook it up to any low impedance devices without buffering, as its output level can be easily affected by external loads. How does the ladder work? A digital byte is output to the ladder which changes the voltage level to the input of the comparator. You should note that the MSB (Most Significant Bit) has the most effect on the output. The LSB (Least Significant Bit) affects the output the least. This works very well with the approximation method described above. You simply load the DAC value you want on the resistors and look at the output signal. It is very fast. The biggest down side is that it uses a lot of output pins. (The output pins must be able to sink or source sufficient current to work correctly.) One caution: make sure your processor can handle the output load of the ladder. The Zilog processor I used in one application worked fine and even has an on board comparator for the ADC process, but I did use every pin, leaving little room for additional signals if needed. PWM ramp: ![]() In this circuit, the duty cycle of the PWM (Pulse Width Modulation) signal is ramped up from 0% till it passes the value of the analog signal, this indicated by the comparator. The analog voltage is represented by the % of the PWM signal when the comparator changes state. The RC filter must turn the PWM into basically an analog level. This means the PWM must switch significantly faster than the speed of the signal you are trying to digitize. RC Charge time: ![]() This method relies on the transient response of the basic RC circuit. The step input causes the input to the comparator to increase according to the response time of the RC circuit. The output of the RC circuit is equal to Vi(1-e^-(t/tau). So if you know the value of tau, which is R*C, then you can calculate the voltage base on the time it takes to pass the input. This can be tedious to calculate in some micros, but often high accuracy is not needed, and a look-up table of the values can be implemented. In many cases, a lower resistance discharge path is added to this circuit to assure the output of the RC circuit begins at zero. The down sides to this circuit are the curve calculations, but if you could figure out how to cancel that curve out, then you would really have something! So there you have three easy ways to get a digital approximation of an analog signal. All of the above circuits are perfectly fine to use as DAC only. If you are interested, here is a link to an app note from Zilog that covers all of the above methods very clearly and in more detail. http://www.zilog.com/pdfs/z8otp/adc_z8_mcu.pdf Some other items of note: Buffering. Did you notice that all of the above DAC are hooked up to high impedance inputs. This is very important. You can't load the signal of the DAC. You will get funny results if you do. Filtering. You must kill those high frequencies. There are a lot of high frequencies created when you digitally switch a signal from a low to a high level. This has to be dealt with depending on the application. Some types of ADC circuits that don't require a DAC. A whole bunch of comparators. Each comparator compares the input to a fixed voltage and you have one for every level you need. You can imagine this one; it works well with low resolution needs, but gets very complex as resolution goes up. The voltage to frequency converter. There are some neat chips and circuits that take an analog voltage and create a frequency. This frequency can then be measured to derive the voltage level. To conclude, for those of you who realized I signed my name digitally in the last article, here is a question: How in the world is a 1 bit DAC better than a 16 bit DAC? All the portable CD players tout this 1 bit DAC as a big deal. (They used to use 16 bit DAC circuits years ago.) Product
Engineering Archive
|
||||||||||||||||||||||||||||||||||||
|
Copyright © 2003 ChipCenter-QuestLink About ChipCenter-Questlink |
|||||||||||||||||||||||||||||||||||||