Wednesday, April 15, 2009

Using the Analog-to-Digital (A/D) Converter 3

Ratiometric Conversion
Ratiometric Conversion is the A/D conversion process in which the binary result is a ratio of the supply voltage or reference voltage, the latter being equal to full-scalevalue by default. The PIC16C7X is a ratiometric A/D converter where the result depends on VDD
or VREF. In some A/Ds, an absolute reference is provided resulting in “absolute conversion”.

Sample and Hold
In sample and hold type A/D converters, the analog input has a switch (typically a FET switch in CMOS) which is opened for a short duration to capture the analog input voltage onto an on-chip capacitor. Conversion is typically started after the sampling switch is closed.

Track and Hold
Track and Hold is basically the same as sample and hold, except the sampling switch is typically left on. Therefore the voltage on the on-chip holding capacitor “tracks” the analog input voltage. To begin a conversion, the sampling switch is closed. The PIC16C7X A/D falls in this category.

Sampling Time
Sampling Time is the time required to charge the on-chip holding capacitor to the same value as is on the analog input pin. The sampling time depends on the magnitude of the holding capacitor and the source impedance of the analog voltage input.

Offset Error (or Zero Error)
Offset Error is the difference between the first actual (measured) transition point and the first ideal transition point as shown in Figure 6. It can be corrected (by the user) by subtracting the offset error from each conversion result.



Full Scale Error (or Gain Error)
Full Scale Error is the difference between the ideal full scale and the actual (measured) full scale range (Figure 7). It is also called gain error, because the error changes the slope of the ideal transfer function creating a gain factor. It can be corrected (by the user) by multiplying each conversion result by the inverse of the gain.



Integral Non-Linearity (INL), or Relative Error
The deviation of a transition point from its corresponding point on the ideal transfer curve is called “Integral Non-Linearity” (Figure 8). The maximum difference is reported as the INL of the converter. It is important to note that Full Scale Error and the Offset Error are normalized to match end transition points before measuring the INL.



Reference:
  1. AN546, Microchip Technology Inc. Sumit Mitra, Stan D’Souza, and Russ Cooper,

Monday, April 13, 2009

Using the Analog-to-Digital (A/D) Converter 2

Differential Non-Linearity (DNL)
It is the deviation in code-width from 1LSb (Figure 4). The difference is calculated for each and every transition. The largest difference is reported as DNL. It is important to note that the DNL is measured after the transfer function is normalized to match offset error and gain error. Note that the DNL cannot be any less than -1LSb. In the other direction, DNL can be >1LSb.



Absolute Error
The maximum deviation between any transition point from the corresponding ideal transfer function is defined as the absolute error. This is how it is measured and reported in the PIC16C7X (Figure 5). The notable difference between absolute error and integral non-linearity (INL) is that the measured data is not normalized for full scale and offset errors in absolute error. Absolute Error is probably the first parameter the user will review to evaluate an A/D. Sometimes absolute error is reported as the sum of offset, full-scale and integral non-linearity errors.

Total Unadjusted Error
Total Unadjusted Error is the same as absolute error. Again, sometimes it is reported as the sum of offset, full-scale and integral non-linearity errors.

No Missing Code
No missing code implies that as the analog input voltage is gradually increased from zero to full scale (or vice versa), all digital codes are produced. Stated otherwise, changing analog input voltage from one quantum of the analog range to the next adjacent range will not produce a change in the digital output by more than one code count.

Monotonic
Monotonicity guarantees that an increase (or decrease) in the analog input value will result in an equal or greater digital code (or less). Monotonicity does not guarantee that there are no missing codes. However, it is an important criterion for feedback control systems. Non-monotonicity may cause oscillations in such systems. The first derivative of a monotonic function always has the same sign.



Reference:
  1. http://en.wikipedia.org
  2. AN546, Microchip Technology Inc. Sumit Mitra, Stan D’Souza, and Russ Cooper,

Saturday, April 11, 2009

Using the Analog to Digital Converter 1

INTRODUCTION

This application note is intended for PIC16C7X users with some degree of familiarity with analog system design. The various sections discuss the following topics:

  • Commonly used A/D terminology
  • How to configure and use the PIC16C71 A/D
  • Various ways to generate external reference voltage (V REF)
  • Configuring the RA3:RA0 pins

COMMONLY USED A/D TERMINOLOGY

The Ideal Transfer Function

In an A/D converter, an analog voltage is mapped into an N-bit digital value. This mapping function is defined as the transfer function. An ideal transfer is one in which there are no errors or non-linearity. It describes the “ideal” or intended behavior of the A/D. Figure 1 shows the ideal transfer function for the PIC16C7X A/D.



Note that the digital output value is 00h for the analog input voltage range of 0 to 1LSb. In some converters, the first transition point is at 0.5LSb and not at 1LSb as shown in Figure 2. Either way, by knowing the transfer function the user can appropriately interpret the data.


Transition Point

The analog input voltage at which the digital output switches from one code to the next is called the “Transition Point.” The transition point is typically not a single threshold, but rather a small region of uncertainty (Figure 3). The transition point is therefore defined as

the statistical average of many conversions. Stated differently, it is the voltage input at which the uncertainty of the conversion is 50%.


Code Width

The distance (voltage differential) between two transition points is called the “Code Width.” Ideally the Code Width should be 1LSb (Figure 1).


Center of Code Width

The midpoint between two transition points is called the “Center of Code Width” (Figure 3).



Reference:

  1. AN546, Microchip Technology Inc. Sumit Mitra, Stan D’Souza, and Russ Cooper,

Tuesday, April 7, 2009

ADC Definitions and Specifications 5

Integral Non-Linearity (INL)



Integral Non-Linearity (INL) is defined as the sum from the first to the current conversion
(integral) of the non-linearity at each code (Code DNL). For example, if the sum of the DNL up to a particular point is 1LSB, it means the total of the code widths to that point is
1LSB greater than the sum of the ideal code widths. Therefore, the current point will convert one code lower than the ideal conversion.

In more fundamental terms, INL represents the curvature in the Actual Transfer Function relative to a baseline transfer function, or the difference between the current and the ideal transition voltages. There are three primary definitions of INL in common use. They all have the same fundamental definition except they are measured against different transfer functions. This fundamental definition is:

Code INL = V(Current Transition) – V(Baseline Transition)
INL = Max(Code INL)

The three primary definitions are:
  1. INL, Adjusted INL, or Endpoint INL — The current transition voltage is compared to the corresponding transition voltage on the Adjusted Transfer Function. This is a useful indicator of the best the ADC can do if the endpoint non-linearities (Zero- and Full-Scale Errors) are measured and trimmed out.
  2. Unadjusted INL — The current transition voltage is compared to the corresponding transition voltage on the Ideal Transfer Function. This is a measure of the total error except for Quantization Error.
  3. Best-Fit INL — The current transition voltage is compared to the corresponding transition voltage on the Best-Fit Transfer Function. This will usually give a balanced positive and negative error across the entire curve so the results look very optimistic, but since it is difficult to obtain the Best-Fit Transfer Function in application, it is not a very useful measure. Unfortunately, this is what many evaluation packages (hardware and software) measure.


There are some related definitions to Total Unadjusted Error that vary slightly in definition. These are:
  1. Total Error is the same as Total Unadjusted Error, but the term is misused in several ADC references and is therefore misleading. The less ambiguous term Total Unadjusted Error is preferred.
  2. Total Adjusted Error is the difference between the Actual and Adjusted Straight-Line Transfer Function, accounting for INL plus Quantization Error. This term is redundant and potentially confusing with respect to Total Unadjusted Error and will not be used.
  3. Code Error is the error between the ideal code and the current code. This is the only figure of merit that measures by the quantized output.

Instead of voltage. The code error is the Total Unadjusted in LSB, rounded to the nearest integer.

References:
  1. J. Feddeler and Bill Lucas, 8/16 Bit Division Systems Engineering, Austin, Texas, Aplication Note AN2438/D 2/2003, Frescale Semiconductor, Inc, Motorola 2003, www.freescale.com
  2. http://en.wikipedia.org

Sunday, April 5, 2009

ADC Definitions and Specifications 4


Offset and Gain Error
Zero-Scale Errors and Full-Scale Errors can be used to calculate Offset and Gain Errors. These terms are used to define the performance on many industry-standard ADC’s but the definitions used vary and can be misleading or inconsistent.
  1. Offset Error (EO), Adjusted Offset, or Zero-Scale Offset is the difference between the actual and ideal first transition voltages. This is the same definition as Zero-Scale Error. The term offset; however, implies that all conversions are off by an equal amount. In the case of a strong non-linearity near the Zero-Scale Value, this definition may be misleading, and the less ambiguous Zero-Scale Error term is preferable.
  2. Best-Fit Offset is the difference between the Best-Fit Straight-Line Transfer Function and the Ideal Straight-Line Transfer Function at VREFL. Some definitions define the offset point at the center-conversion ((VREFH – VREFL) /2) instead of at VREFL. This offset is virtually impossible to measure in the application and is therefore only a laboratory curiosity. Since this yields optimistic results and is not measurable in the application, it can be misleading and will not be used.
  3. Full-Scale Offset is the difference between the actual and ideal last transition voltages. This is the same definition as Full-Scale Error, and is misleading for the same reason that Offset is misleading with respect to Zero-Scale Error.
  4. Gain Error (EG) or Adjusted Gain Error is the difference in the slope of the Actual and the Ideal Straight-Line Transfer Functions. The error is not measured as a slope but rather as the difference in the total available input range from the first to the last conversions between the Ideal and Adjusted Straight-Line Transfer Functions. It is can also be expressed by: EG = EZS – EFS. Gain Error is not directly measurable and the term has been inconsistently defined in the literature. Additionally, if there are strong non-linearities at the endpoints, this definition of Gain Error may be misleading, so the less ambiguous Full-Scale Error term is preferred provided a simple gain calculation (above) is possible.
  5. Best-Fit Gain Error is the difference in the slope of the Best-Fit and Ideal Straight-Line Transfer Functions. The error is not measured as a slope but rather as the difference in the total available input range from the first to the last conversions between the Ideal and Best-Fit Straight-Line Transfer Functions. Since the Best-Fit Straight-Line Transfer Function will result in an optimistic Gain Error and is virtually impossible to measure in the application, it can be misleading and will not be used.

Consistency with previous Freescale documents can be achieved by replacing references to Offset Error with Zero-Scale Error and Gain Error with the difference between of Zero Scale Errors and Full-Scale Errors.

Differential Non-Linearity (DNL)
Differential Non-Linearity (DNL) is the maximum of the differences in the each conversion’s Current Code Width (CCW) and the Ideal Code Width (ICW). DNL is the most critical of the measures of an ADC’s performance for many control applications since it represents the ADC’s ability to relate a small change in input voltage to the correct change in code conversion. DNL is defined as:

Code DNL = CCW – ICW
DNL = Max (Code DNL)

Some literature defines DNL using the Adjusted Code Width (ACW), which means Zero- and Full-Scale Error have been adjusted for. For relatively accurate ADC’s, the difference with respect to DNL is negligible, but using the ACW complicates defining and testing DNL. Additionally, this definition is only valid if the application has trim capability.


Related to DNL are two critical figures of merit used in defining ADC operation.
These are:
  1. Missing Codes — An ADC has missing codes if an infinitesimally small change in voltage causes a change in result of two codes, with the intermediate code never being set. A DNL of –1.0 LSB indicates the ADC has missing codes (DNL measured by this definition cannot be less than –1.0 LSB).
  2. Monotonicity — An ADC is monotonic if it continually increases conversion result with an increasing voltage (and vice versa). A nonmonotonic ADC may give a lower conversion result for a higher input voltage, which may also mean that the same conversion may result from two separate voltage ranges. Often, the transfer function will completely miss the lower code until after the higher code is converted (on an increasing input voltage).

Some literature suggests that a DNL of greater than 1.0 LSB may indicate nonmonotonicity. Non-monotonicity is usually accompanied by large, positive DNL (>1.0 LSB), although a non-monotonic situation can be coincident with a DNL of less than 1.0 LSB.

Friday, April 3, 2009

ADC Definitions and Specifications 3

Best-Fit Transfer Function
Some ADC’s exhibit low Zero- and Full-Scale Errors but still have significant non-linearities. In cases where these linearities tend to be in one direction (for example, a significantly “bowed” function) the best application results may be obtained if the errors are compared to a Best-Fit Transfer Function. The Best-Fit Straight-Line Transfer Function is the line from which the average deviation of all conversions is minimum. Computing this function requires that the entire Actual Transfer Function be recorded, which is impractical in most applications. Therefore, any performance parameters calculated against the Best-Fit Transfer Function are not useful to the user. Unfortunately, many automatic evaluation packages (software and hardware) assume this type of curve.

Zero-Scale Error and Full-Scale Error
The non-linearities at the endpoints are considered special cases due to the ease with which they are measured and corrected. The non-linearity at the beginning of the Actual Transfer Function is called the Zero-Scale Error (EZS) and the non-linearity at the top end of the function is called Full-Scale Error (EFS). The Zero- and Full-Scale Errors have the following definitions:
  1. Zero-Scale Error (EZS) is the difference between actual first transition voltage and the ideal first transition voltage (if the first transition is not from $000 to $001, then use the difference between the actual and ideal $001–$002 transition voltages, and so on).

NOTE: The Ideal Code Width for the zero code is ½LSB for ADC’s with ½LSB compensated quantization.

Representing this error is by code widths: EZS = CCW(0) – ICW(0)
Or, in the case where the first “x” codes are missing, EZS = CCW(x) – sum(i=0 →x)[ICW(i)]
  1. Full-Scale Error (EFS) is the difference between the actual last transition voltage and the ideal last transition voltage (if the last transition is not from $3FE to $3FF, then use the difference between the actual and ideal $3FD–$3FE transition voltages, and so on).

NOTE: The Ideal Code Width for the last code is 1½LSB for ADC’s with ½LSB compensated quantization.

Representing this error by code widths:
EFS = CCW(last) – ICW(last)
Or, in the case where the last “x” codes are missing,
EFS = CCW(last-x) – sum(i=x→last)[ICW(i)]

References:
  1. J. Feddeler and Bill Lucas, 8/16 Bit Division Systems Engineering, Austin, Texas, Aplication Note AN2438/D 2/2003, Frescale Semiconductor, Inc, Motorola 2003, www.freescale.com
  2. http://en.wikipedia.org

Wednesday, April 1, 2009

ADC Definitions and Specifications 2

Ideal Transfer Function
The Ideal Straight-Line Transfer Function of an ADC is a straight line from the minimum input voltage (voltage reference low; VREFL) to the maximum input voltage (voltage reference high; VREFH). The Ideal Transfer Function is then quantized (divided into steps) by the number of codes the ADC is capable of resolving. The input voltage range is divided into steps, each step having the same width.

This Ideal Code Width (ICW) — also known as 1LSB — is:
ICW = 1LSB = (VREFH – VREFL)/2N

Where:
N is the “width” of the ADC, in our examples, 10 bits.

The Ideal Transfer Function is then:
Code = (VIN – VREFL) / 1LSBVIN = (Code*1LSB) + VREFL

Quantization Error (EQ) and Method
The way the Ideal transfer function is divided into steps depends on the method of quantization the ADC uses. The two possible methods are:
  1. Uncompensated Quantization — The first step is taken at 1LSB, with each successive step taken at 1LSB intervals and the last step taken at VREFH – 1LSB. The Quantization Error (EQ) in this case is from 0LSB to 1LSB.
  2. ½LSB Compensated Quantization – The first step is taken at 1⁄2LSB, with each successive step taken at 1LSB intervals and the last step taken at VREFH – 11⁄2LSB. The Quantization Error (EQ) in this case is ±1⁄2LSB
Adjusted Transfer Function
Most ADC’s exhibit some non-linearity at the endpoints due to the difficulty in measuring a signal that is identical to the reference. If these errors are accounted for, a more accurate portrayal of the ADC behavior in application is possible. For this reason, the Adjusted Straight-Line Transfer Function is drawn between the minimums input voltage plus the Zero-Scale Error (VREFL + EZS) to the maximum input voltage plus the Full- Scale Error (VREFH + EFS).

The Adjusted Transfer Function is then quantized in the same method as the Ideal Transfer Function. The Adjusted Code Width is therefore:
ACW = [(VREFH + EFS) – (VREFL + EZS)] / 2N

The Adjusted Transfer Function is then:
Code = (VIN – VREFL – EZS) / ACW VIN = (Code*ACW) + VREFL + EZS