Calibrating Amplifiers and ADCs in SoCs

advertisement
Calibrating Amplifiers and ADCs in SoCs
By M. Ganesh Raaja and Pushek Madaan
Introduction
In today’s world of mixed signal systems, many applications require analog quantities to be measured
and processed. Some examples are voltage, current, temperature, pressure, acceleration, pH, flow, ECG
etc. The field of use range from lab and medical equipment operating under controlled environment to
industrial equipment operating under harsh operating conditions. The analog signals to be measured can
range from a few micro-volts in ECG systems to thousands of volts in electricity generation plants.
Whatever be the application, environment or quantum of signal being measured, a basic signal
acquisition system comprises of an analog front end which amplifies and conditions the signal followed by
an Analog to Digital Converter (ADC) that converts the analog signal to a digital value which is then
processed by a microprocessor. The analog front end could be a simple amplifier or a complex system
comprising of multi stage amplifiers and filters.
The block diagram of a basic signal conditioning circuit is shown below.
Vin
+
Amplifier
Gain = A
ADC
-
Figure 1: Basic Signal Acquisition
Considering the system to be ideal, the ADC output is denoted by the following equation.
Equation-1
Where, VIN is Input voltage
A is Gain of the Amplifier
VFS is Range of the ADC
N is Resolution of the ADC
Given the ADC counts, the microprocessor calculates the input voltage from below equation.
Equation-2
Unfortunately, there is no such thing as “ideal” in the real world. In real world, there are many errors that
get introduced into the system affecting the ADC’s output.
The most important errors and the ones that
we are going to discuss in this article are the offset and gain errors.
Offset Error
Refer graph below. This is a plot of an 8 bit ADC with a range of +2.5V. X axis denotes the input voltage
and Y axis denotes the ADC counts. The blue line is the ideal ADC output. The red line is the actual ADC
output. Notice the actual output is shifted from the ideal. This shift is called the offset error.
Figure 2: System with Offset Error
All operational amplifiers have a finite offset voltage at the input. This offset voltage gets added to the
input signal, gets amplified by the amplifier’s gain and manifests at the output. Apart from the amplifier
stage, the ADC also has its own offset voltage which adds to the system error. Offset error is an additive
error and can be easily removed from the system.
Gain Error
Refer graph below. This is the plot of the same 8 bit ADC with the +2.5V range. Note that the slope of
the actual output is now different from the slope of the ideal output. This shift is called the gain error.
Figure 3: System with Gain Error
Gain error is caused mainly by the tolerance of gain setting resistors in the amplifier and tolerance of the
reference voltage in the ADC. Gain error is a scaling error and can also be easily removed from the
system.
Mathematical Representation of a Practical System
An ideal acquisition system can be represented with the help of a simple mathematical equation given by
equation 3.
Equation-3
Where,
y is the output of the system or ADC counts
mi is the ideal gain of the system
x is the input voltage
But as discussed in previous sections, introduction of offset and gain errors results in the below equation.
Equation-4
Where, ma is the gain with error of the actual system
C is the offset error
Below graph shows a system with both offset and gain errors.
Figure 4: System with Offset and Gain Errors
SoCs – System On Chips – are mixed signal controllers that have analog and digital peripherals and a
microprocessor on a single chip. They integrate all ingredients for an analog front end like amplifiers,
filters and ADCs on the same device with flexible routing options. Using these flexible resources, the
offset and gain errors can be easily dealt with.
Let us now discuss some widely used calibration methods to get rid of the offset and gain errors. Each of
the methods has its own merits and demerits. Depending on the application one or more of these
methods can be combined to get the maximum accuracy.
Two point calibration
This method of calibration takes care of both offset and gain errors. In Equation-4, if the actual gain ma
and offset C are known, the actual input can be calculated by using equation 5.
Equation-5
Parameters ma and C can be determined by using the following two point calibration process.
1. Apply 0V at the input of the analog front end, measure the ADC output and record this as Offset (C).
2. Apply a known reference voltage at the input and measure the ADC output. For best performance,
the reference voltage should be more than 90% of the full scale value.
3. Calculate Gain in Counts/Volts (ma) or Volts/Counts (1/ma).
!
!
"#$%
&'' (
)('
Equation-6
)('
"#$%
&'' (
Equation-7
4. Store the Offset and Gain values in a non-volatile memory and use these values during actual
measurement.
Once the offset and gain values are stored, the input signal may be measured by using the following
process.
1. Measure input ADC counts.
2. Calculate the input voltage using the offset and gain values
&'' ( !
Equation-8 (Using Counts/Volts)
&'' ( !
Equation-9 (Using Volts/Counts)
The trigger for performing the offset or scale calibrations can be implemented depending on the
application. This could either come from switches or from commands received over a communication
interface.
The scale can be a function of the actual unit being measured. For example, if you are measuring current
from the voltage drop across a shunt, instead of measuring the voltage and then deriving the current, you
can directly apply a reference current to the shunt and calculate the scale as Counts/Ampere. This will
remove any inaccuracies introduced by the tolerance of the shunt resistor.
Disadvantages:
There are two disadvantages with this method of offset and gain compensation.
1. The offset of an op-amp has its own temperature coefficient and will change with temperature.
This will lead to offset errors at temperatures other than the temperature at which the calibration
is performed.
2. The two point calibration introduces an additional step in the manufacturing process.
These disadvantages are addressed by the techniques discussed below.
Correlated Double Sampling a.k.a CDS
Correlated Double Sampling also called CDS is used to dynamically compensate offset error.
following is the procedure to implement CDS.
The
1. Connect the input of the Amplifier to Ground
2. Measure the ADC output. Any non-zero value measured at the ADC is due to the offset error of
the system.
3. Store this value in a variable called Offset
4. Connect input of the amplifier to the signal
5. Measure the ADC output.
6. Subtract the Offset value measured in Step#2. This gives an offset compensated result.
7. Repeat Steps #1 to #6 for every measurement.
As the offset is being measured for every measurement, any drift in offset voltage due to temperature is
automatically taken care of.
Figure 5: CDS Implementation
The disadvantage
isadvantage of this system is that the ADC’s throughput is reduced by a factor of 2 as two
measurements have
e to be taken for every cycle. If this low throughput is undesirable,, the offset voltage
can be measured less often,, i.e., iinstead of measuring the offset for every measurement cycle, offset
measurement may be performed say once in 16 or 32 measurement cycles.
Gain Calibration by External Voltage Reference
Using a highly accurate external reference voltage which has very low temperature coefficient, gain error
can be compensated.
Figure 6
6: Gain Calibration using External Reference
Following is the procedure for implementing gain compensation using an external reference.
reference
1. Connect the known reference voltage, for example AD1580B with a reference of 1.225V and a
temperature drift of 50 ppm/
ppm/°C to the input of the amplifier.
2. Measure the ADC counts.
3. From the known reference voltage and the ADC counts, calculate Gain
4. Connect the signal to the input of the amplifier.
5. Measure ADC counts.
6. Calculate input signal from ADC counts and the Gain calculated in #3.
Now, combining the CDS for offset compensation and external reference for gain compensation a
completely automatic system can be built. Figure 6 shows the implementation of such a system.
Figure 7: Offset and Gain calibration using CDS and External Reference
This method provides a fully automatic, accurate and an error free system,, but has a disadvantage of
increased cost because of the external precision voltage reference.
Putting the Concepts to Test
Some of the afore mentioned concepts – CDS and two point calibration – were put to test using a PSoC
(Programmable System On Chip) mixed signal controller from Cypress Semiconductors
miconductors with flexible
Analog and Digital peripherals and an onboard microcontroller
microcontroller.. The device has universal analog blocks
using which various analog peripherals like Programmable Gain Amplifiers, ADCs, DACs, Filters etc can
be constructed. The device
ice also has very flexible analog routing resources with input multiplexers,
analog output buffers, flexible block to block connectivity etc. The figure below shows a snapshot of how
the analog resources are configured in the device.
Input Multiplexer
Programmable
Gain Amplifier
Analog Ground
Reference Generator
ADC
Analog Ground
Output Buffer
Figure 8: PSoC Implementation
A 4:1 input multiplexer is used to switch between input signal and analog ground at the input of a
Programmable Gain Amplifier with a gain of 16. The output of the PGA is fed to a 12 bit incremental
ADC. A reference generator is used to generate an analo
analog ground of 2.5V which is brought out on a pin
using an analog buffer. A +60mV
60mV input signal is connected to the input pin with respect to the 2.5V
reference.. Using this hardware setup, three different application codes were written.
1. Application with no offset or gain compensation
2. Application with offset
ffset compensation using CDS
3. Application with two
wo point calibration for Offset and gain compensation
In all the three applications the measured input is displayed on an LCD display. The test results obtained
for the above three applications is shown below.
Input
Gain
Reference
+60mV
16.00
1.3V (Internal)
Input
(mV)
Uncalibrated
-60.00
-50.00
-40.00
-30.00
-20.00
-10.00
0.00
10.00
20.00
30.00
40.00
50.00
60.00
-53.54
-43.50
-33.53
-23.49
-13.49
-3.45
6.50
16.55
26.55
36.59
46.63
56.72
66.68
Error on
FS %
10.77%
10.83%
10.78%
10.85%
10.85%
10.92%
10.83%
10.92%
10.92%
10.98%
11.05%
11.20%
11.13%
CDS
Error on
FS
-59.77
-49.83
-39.86
-29.88
-19.92
-9.98
0.00
9.96
19.95
29.91
39.93
49.89
59.89
Table 1: Test results
Two Point
Calibration
0.38%
0.28%
0.23%
0.20%
0.13%
0.03%
0.00%
-0.07%
-0.08%
-0.15%
-0.12%
-0.18%
-0.18%
-60.00
-50.01
-40.02
-30.03
-20.02
-10.02
0.00
9.98
19.97
29.96
40.00
49.98
60.00
Error on
FS
0.00%
-0.02%
-0.03%
-0.05%
-0.03%
-0.03%
0.00%
-0.03%
-0.05%
-0.07%
0.00%
-0.03%
0.00%
The error on full scale was around +11% for the un-calibrated system. With only offset compensation
using CDS, the error reduced to about +0.4% and with two point calibration the error was the least at
+0.07%
Conclusion
Summarizing, the below table lists the advantages and disadvantages of the different techniques to
remove offset and gain errors in signal acquisition systems.
Technique
Correlated Double Sampling
Two Point Calibration
External Reference
CDS + External Reference
Advantages
Offset compensation
Compensates for offset drift due to
temperature
Compensates both offset and gain
errors.
Removes gain error
No need for manual calibration;
Compensates both offset and gain
errors
Disadvantages
Reduced throughput of ADC
Offset compensation suffers error due
to temperature drift
Additional step required for calibration
during manufacturing.
External reference increases cost
Reduced throughput of ADC
External reference increases cost
Depending on the accuracy and cost requirement one or a combination of many of the above techniques
can be used to build a highly accurate signal acquisition system.
References:
AN2226 – Correlate
d Double Sampling for Thermocouple Measurement by Dennis Seguine
Download