Sunteți pe pagina 1din 8

Correlated Double Sampling for Thermocouple

Measurement

AN2226
Author: Dennis Seguine
Associated Project: No
Associated Part Family: CY8C24xxx, CY8C27xxx, CY8C29xxx
Software Version: PSoC Designer™ 5.0
Associated Application Notes: AN2017, AN2224, AN2276

Application Note Abstract


Correlated Double Sampling (CDS) is used to measure small, slowly changing analog signals in the presence of large volumes
of low frequency (1/f) noise and DC offset. A type K thermocouple is used as an example.

Introduction Figure 2. Thermocouple Amplifier with Gain

The thermocouple (TC) is a voltage output device that


measures the difference between the sensor tip and the ADCINC14
reference lead. This is a relative measurement and to be Type K
accurate, the reference lead temperature must also be
known. Type K thermocouples have an output of 40.7 V per
degree Celsius.

Too Simple Approach The highest nominal PGA gain available is 48. This yields a
The too simple approach is to connect the reference lead of PGA output of 48*40.7 V = 1.95 mV per degree or 0.08
the thermocouple to ground and the output to a high degrees per bit. This is a good start, but the circuit still has
®
resolution ADC. In this case, the PSoC ADC with the problems with minimum operating voltage and accuracy.
highest resolution is ADCINC14.
Figure 1. Too Simple Thermocouple Circuit Accommodating Offsets
The thermocouple output is relative to the temperature of the
reference lead (the grounded terminal in Figure 2). If the
ADCINC14 reference lead is at room temperature and the thermocouple
is colder, then the output voltage is negative. The PSoC
Type K does not handle negative voltages. Therefore, the input must
be biased above ground by an amount sufficient to
accommodate the negative temperature limit of the
The thermocouple’s output is absolute (not ratiometric), so thermocouple. A practical measurement limit is -100 C. This
the reference for the ADCINC14 is selected to be an is only -4 mV.
absolute voltage referenced to the PSoC’s internal bandgap. Next, the opamps in the PGA and the ADCINC14 have input
The lowest ADC scale is 0 to 2*Vbg or 2.6V. For the offset voltages. The opamp specification limit is ±10 mV with
ADCINC14, the resolution is 2.6V/2^14 or 159 V per bit. a 1.6 mV typical. The offset of the ADCINC14 is reflected to
This is four degrees per bit and is not useful for one degree the PGA input divided by the gain. The worst case offset
accuracy. compensation required is the sum of PGA offset, ADC offset,
and negative signal range, a total of 14.2 mV.
Simple Approach
The offset is achieved using a resistive divider from the Vdd
With insufficient ADC resolution, DC gain is required to make
supply.
the measurement useful. A PGA is added to boost the input
signal.

June 12, 2009 Document No. 001-45198 Rev. *B 1

[+] Feedback
AN2226

Figure 3. Accounting for Circuit Offset Figure 6. Opamp Noise Characteristic


Vdd (5.0V) nV/rtHz
1.0E+04
Voltage noise

ADCINC14
49.9 k
Type K
1.0E+03

(+15 mV)

150
1.0E+02

The ±10 mV offset voltage is equal to ±250 C and must be


calculated. This is done by measuring both sides of the
1.0E+01
thermocouple and then taking the difference. The multiplexer 0 1 10 100 Hz 1000 10000 100000
is the standard PSoC port 0 input mux.
This is from a model in AN2224, taken from characterization
Figure 4. Thermocouple Offset Compensation
data.
Vdd (5.0V)
The total PGA noise is given by:
1
49.9 k 2
Type K fu
ADCINC14 v nt n0 f u fl f c ln Equation 1
(+15 mV)
fl
150
In this equation:
n0 is the flat band noise
fC is the 1/f corner frequency
The easy thing to do is to measure the offset at the reference
side of the thermocouple at startup and store the digitized fU is the upper frequency limit
value. The mux is switched to the thermocouple output and
the value digitized. (~fSAMPLE/2=60Hz/2)

Figure 5. Sequential Offset Subtraction fL is the lower frequency limit (0.01 Hz)

Vdd (5.0V) vnt = 12.4 V RMS


The noise bandwidth is limited by the sin(x)/x noise shaping
of the incremental ADC. The -3 dB point of the filter is at 0.44
49.9 k
Type K * fSAMPLE.
ADCINC14
(+15 mV) Figure 7. ADC sin(x)/x Response
150

Vdd (5.0V)

49.9 k
Type K
ADCINC14
(+15 mV)

150

The stored offset value is subtracted from the thermocouple


output measurement. Problems with this technique arise The ADC rejects noise above the sample rate, but it has no
from opamp input noise and offset voltage drift. effect on offset or low frequency noise.

The PGA has input noise dominated by a 1/f term. The flat The indicated temperature is the difference between the
band noise level is 65 nV/rtHz, with the 1/f corner at 4.5 kHz. stored value and the most recent reading. The noise
contributions from the two measurements add in RMS, so
the noise on the reading is 17.5 V RMS. ADC opamp noise
and quantization error (=1 LSB/sqrt(12)) add an amount of

June 12, 2009 Document No. 001-45198 Rev. *B 2

[+] Feedback
AN2226

error small in comparison to the PGA's noise. With this noise The combination of the correlated double sample and the
level, an indicated temperature wander of approximately ADC's sinc (sin(x)/x) filter creates a frequency response that
±1.5 degrees for a three sigma variation is expected. This is significantly reduces the low frequency components of the
worse than the desired specification and does not account noise, as shown in Figure 8.
for drift or measurement scale accuracy.
Figure 8. CDS Frequency Response
The Vos drift for PSoC1 is 5 V typical and 35 V worst
dB CDS + sinc
case. A one degree shift in die temperature indicates as 10
much as 0.9 degree change in indicated thermocouple
0
reading. A degree or two of chip temperature variation (not
unreasonable in any warm up situation) dominates the error -10
from the noise. To resolve this problem, measure and -20
subtract the offset and noise in real time. This technique is
called correlated data sampling. -30

-40

Correlated Double Sampling -50


CDS
Using the last circuit above, alternating measurements are -60 sin(x)/x

taken of the zero-referenced offset and the thermocouple Noise Response


-70
signal. 0 1 10 100 1000 10000 100000

The direct thermocouple measurement is:


The sinc filter has the low pass characteristic and the
VTC _ SAMPLE VTC VN VOFFSET Equation 2 correlated double sample has a high pass characteristic.
However, the high pass only affects the noise. The product
of the two functions results in a few dB bump in the transfer
The offset measurement is: function just below the sample rate, but overall dramatic
reduction in the total noise.
VTC _ OFFSET VN VOFFSET Equation 3 The difference of the ADC thermocouple and offset
measurement is additionally filtered with a binary-weighted
first order IIR filter, implemented in software (refer AN2276),
The offset is measured at the previous sample time: with a coefficient of 16. The corner frequency of this filter is
1
less than 1 Hz. This is still adequate, because thermocouple
VTC _ OFFSET _ DELAY (VN VOFFSET ) * Z Equation 4 signals are very slow compared to the measurement speed.
When faster response is required, the corner frequency of
the IIR filter is easily adjusted by changing the coefficient.
The difference is: This increases the noise bandwidth.
1 Figure 9. Thermocouple Noise Characteristic
VSIGNAL (VTC VN VOFFSET ) (VN VOFFSET ) * Z
dB IIR Filter
10
1
VSIGNAL VTC (VN VOFFSET ) * 1 Equation 5 0
Z
-10

-20
VOFFSET is static and its value on the current sample is the
-30
same as the value on the previous sample. V N is not static;
this is the noise and drift term to be eliminated. -40

-50
1
VSIGNAL VTC VN * 1 Equation 6 -60 IIR
Z SUM_Filt
-70
Using the bilinear transform: 0 1 10 100 1000 10000 100000

sT The noise power increases as frequency decreases (1/f).


1 The noise voltage increases as square root of 1/f. The
Z 2 Equation 7 voltage attenuation of the filter increases as frequency
sT decreases as 1/f. As the frequency is reduced, the resulting
1 noise level continues to drop. In the limit, (DC or f=0, as in
2
In this equation, T = 1/fSAMPLE. With a little algebraic offset voltage), there is no noise contribution and the offset
manipulation: voltage is completely cancelled. The resulting noise curve is
shown in Figure 10 on page 4.
2s
VSIGNAL VTC VN * Equation 8
s 2 f SAMPLE
June 12, 2009 Document No. 001-45198 Rev. *B 3

[+] Feedback
AN2226

Figure 10. Thermocouple and CDS Noise Response The mean gain is calculated as 46.8, or 2.3% below the
nominal of 48.0. It is accurate to describe the PGA (nominal
nV/rtHz Noise Reduction
1.E+05 gain 48) as Gain = of 46.8 ±1.8 % at Vdd = 5.0V. This
tolerance accounts for variations due to internal component
1.E+04 matching and opamp gain to a three sigma limit.
1.E+03
ADC Gain Accuracy
1.E+02
The output of the PGA is 40.7 V*46.5 = 1.908 mV/deg C
1.E+01 ±0.6%. This uses up part of the error budget. The ADC is a
lot worse. The ADCINC14 accuracy specification (and all
1.E+00
PGA Noise other ADCs) is ±3% on the internal reference. Of this error,
1.E-01
Net TC Noise 0.1% is from the ADC, the dominant portion is from the
reference. Using an external signal for analog ground and
1.E-02 reference reduces this slightly, but there are still offset and
0 1 10 100 1000 10000 100000 gain errors in the reference block.
The very low frequency noise is reduced by a factor of 100. The solution to gain error in ADC and PGA problems is
The offset drift, dependent on the rate of change of the die calibration: add an external reference source.
temperature, is reduced to near zero. The integrated total
noise voltage is approximately 3 mV RMS. This is adequate Figure 11. Thermocouple Scale Compensation
to make the worst case noise sufficient for resolution of Vdd (5.0V)
thermocouple temperature down to one quarter of a degree
49.9 k
Celsius.
121 k
0.1%
PGA Gain Accuracy LM4140A
1.2V+/-0.1%
Type K
41.2
The PGA has a gain of the form of: (+15 mV)
0.1% ADCINC14

75
R2
GPGA 1 Equation 9
R1
The LM4140A provides a 1.2V ±1% reference above the
R2 and R1 are large value resistors, selected by a multiplex
offset point. The resistive divider provides a 4.07 mV
tap from a single tapped string. There are switches in series
reference above the offset point. This is equal to a 100 C
with each end of the resistors to select the feedback drive
calibration point. The scale reference point, offset point, and
and the reference voltage. This is detailed in the block
thermocouple output can be measured sequentially. The
schematic in the PSoC Technical Reference Manual. The
scale is 100 degrees over the difference between the
DC open loop gain of the opamp is finite (typically equal to
reference point and the offset point. Correlated double
10000 in PSoC). Including contributions from the open loop
sampling on the scale along with the input removes any
gain and switches, the gain is:
noise on the reference. The calibration is now as accurate as
the reference diode and the resistors selected. Note that
R2 RSW error in scale is a function of reading. Therefore, at reduced
1 temperatures such as room temperature range, the scale
R1 RSW
G PGA Equation 10 error is less than that at full scale calibration point (100 C).
1 R2 RSW The cost of the LM4140A and the precision resistors is about
1 1
A R1 RSW $1 from Digikey. More precision is possible with more
expensive precision resistors. The money is worth spending
until the scale factor no longer dominates the error budget.
The total resistance (sum of R1 and R2) is fixed. For a
nominal gain of 48, the value of R1 is the unit value, Reference Temperature
approximately 15k ohms. The value of R2 is (48 – unit value)
times 15k ohms. If the switches were ideal, the gain would The last problem is measurement of reference lead
be G = 1 + (47*15k)/(1*15k) = 48.0. Tolerance matching on temperature. This is done by embedding the reference lead
these resistors is approximately 0.5%. As a practical matter, connection in a thermally isolated block with a measurement
the switches do not have zero resistance; their value is about thermistor. Reference temperature accuracies of better than
300 ohms at Vdd = 5.0V and 450 ohms at 3.3V. The opamp 0.5 C can be achieved using the methods detailed in
contributes 0.5% to the total error at guaranteed minimum AN2017. Better resistor tolerance and more precise
gain of 10000. The expected maximum gain for a "really calculation methods may yield slightly lower error.
good" PSoC opamp is 100000, reducing the opamp-induced
gain reduction to 0.4%.

June 12, 2009 Document No. 001-45198 Rev. *B 4

[+] Feedback
AN2226

Figure 12. CSD PSoC Block Layout


Caveats
Sufficient resources are available in CY8C27x43 or
CY8C29x66 to implement both measurements
simultaneously. In CY8C24x23, with half of the analog block
count, the PGA must be reconfigured and analog mux bus
connections must be reconnected to make the reference
measurement. This is easy to do with dynamic
reconfiguration.
CY8C24x23 has a PGA offset voltage induced by a known
problem in the Vss routing of the reference block. It results in
an additional PGA offset voltage of up to 7.5 mV, depending
on reference block power setting. This is automatically
compensated through the correlated double sample, but the
voltage must be accommodated by raising the offset
reference point by 7.5 mV.
Increased ADC resolution is achieved with Delta Sigma
converters, but this topology has a mathematically induced
error (not circuit design fault) near Vss and worse differential
nonlinearity at certain points in the range. The incremental
form, ADCINC14, is preferred.
Type K thermocouples are nonlinear, deviating from the
nominal by about one quarter of a degree over a 50 C range.
Correcting this curvature is a matter of more algebra in the
code.
Code
The code is written in C. The IIR filter on the correlated
double sample difference uses 1/16 times the new data plus
Project 15/16 times the historical data:
The PSoC project was built on a PSoC Eval 1 board using
CY8C27443. The project is limited to measuring both sides 1 VDIFF
VRESULT [n] VRESULT [n 1] * 1 Equation 11
of a "simulated thermocouple" and shipping the data to the 16 16
onboard LCD through UART to a PC terminal program. The
output is in counts of a 14 bit converter, resulting in 3.4 V
per bit equivalent to 0.083 degrees per bit. The project does Multiplications are executed much faster in the PSoC than
not include conversion from counts to degrees. It also does divisions, so the equation is rewritten:
not include scale compensation using measurement of a
calibrated reference source. The simulated thermocouple is 1
a resistive divider from Vdd to the offset reference. The
VRESULT [n] (VRESULT [n 1] VDIFF ) * 1 VDIFF
16
voltage across the simulated thermocouple is measured as
Equation 12
44 mV average with 2 mV of "flicker" using an Agilent 34410
DMM with 1.0 V resolution.
The block layout is shown in Figure 12. It can be
implemented in any PSoC with continuous time and switched
capacitor blocks: CY8C24x23, CY8C24x94, CY8C27x43, or
CY8C29x66. It cannot be implemented in CY8C21xxx or
CY8C20xxx.
The Tx8 is used only to transfer data to the terminal program
of the PC; if the Tx8 is not used (data shipped through I2C or
USB), then the project fits in CY8C24x23 or CY8C24x94.

June 12, 2009 Document No. 001-45198 Rev. *B 5

[+] Feedback
AN2226

//----------------------------------------- LCD_1_Position(0,0);
// C main line LCD_1_PrHexInt(fAccum_val);
//----------------------------------------- }
bIndex^=0x01;//change index to next pin
#include <m8c.h> // part specific constants }
//and macros }
#include "PSoCAPI.h" // PSoC API
//definitions for all User Modules
BYTE bIndex=0x00; // bIndex is a The calculations are executed in floating point to display the
//pointer to the pin being measured simplicity of the algorithms. Conversion to fixed point
int iValue[2]; // iValue holds values involves fractional arithmetic to avoid truncation errors.
//from both sides of the thermocouple
float ftemp; //temporary variable for IIR Results
float fcurr_Reading,fAccum_val; //current The data is captured to a text file through a 9600 baud UART
//and accumilated readings for the IIR filter with an RS232 connection. Eight seconds of data is captured
at 60 samples per second, totaling about 480 samples. The
void main() data analysis and plotting is done with Microsoft Excel.
{
char ctokens[2] = {',' , '\n'}; //tokens The output data is in counts of the 14 bit ADC. One bit
//for data to be sent over RS232 represents 3.4 V. The average reference output is 2470
M8C_EnableGInt; //Enabling global counts. When the PGA gain is 46.5 (from nominal gain of 48)
//interrupts for the ADC_INC and 14 bit ADC using 2.6V full scale, this average reference
voltage is 7.5 mV. This is a reasonable level, offset from the
//Starting the user modules designed 15 mV compensation voltage by the PGA's input
PGA_1_Start(PGA_1_HIGHPOWER); offset voltage. The raw thermocouple data is first evaluated
LCD_1_Start(); by subtracting the AVERAGE reference voltage from the TC
TX8_1_Start(TX8_1_PARITY_NONE); reading.
ADCINC14_1_Start(ADCINC14_1_HIGHPOWER);
Figure 13. Raw Thermocouple Data
//loop for ever Raw Measured - Average Ref
20
19
while(1) 18
{ 17

AMX_IN&=0xFE; 16

AMX_IN|=bIndex; //selecting the right 15


14
//pin to connect to the mux for current 13
//sample 12

ADCINC14_1_GetSamples(1); //ADC samples 11


10
while(!ADCINC14_1_fIsDataAvailable()); 9
iValue[bIndex]=ADCINC14_1_iGetDataClearFl 8

ag(); 7
Meas-Avg(Ref)
6
//put the value on the index
//corresponding to the pin from which it
//was measured The peak to peak noise is 12 counts, or roughly one
degree C. This can be averaged with an IIR filter (coefficient
TX8_1_PutSHexInt(iValue[bIndex]); 1/16) to reduce the noise.
//tranmit the sample through RS232 Figure 14. Filtered Thermocouple Data
TX8_1_PutChar(',');
//transmit token (delimiter) 20
Raw Measured, Filtered Raw
19
//Filter 18

if(bIndex==1) //calculated only on second 17


16
// measurement 15
{ 14
fcurr_Reading=iValue[0]-iValue[1]; 13

// Calculate CDS difference 12


11
ftemp=(fcurr_Reading-fAccum_val)/16; 10
// Scale difference and accum 9
8
Meas-Avg(Ref)
fAccum_val+=ftemp; // Filtered value 7
Filt(Meas-Avg(Ref))
6

TX8_1_PutSHexInt(fAccum_val);
//tranmit the sample through RS232
TX8_1_PutChar('\n');
//transmit token (line feed)

June 12, 2009 Document No. 001-45198 Rev. *B 6

[+] Feedback
AN2226

This reduces the peak to peak noise to four counts. Even at Summary
this filtered level, a general negative drift is seen. There is no
guarantee that the offset measured at the start of the scan is A straightforward method of implementing a Type K
the correct value in the long run. thermocouple measurement using correlated doubling
sampling in PSoC1 is outlined.
The correlated double sample takes the difference between
the measured value and the reference at every sample. This Scale adjustments necessary to accommodate the ±4% error
removes much of the low frequency and the peak to peak from PGA gain and ADC range are not demonstrated but are
variation. simple to implement. Compensation for reference lead
temperature using a thermistor is straightforward. There is a
Figure 15. Double Sample on TC Data very high probability that the required accuracy of one
degree Celsius can be achieved.
CDS
20
19 The signal processing techniques used to extract the TC
18 data from offset and 1/f noise are simple, proven, and
17
applicable to any DC or low frequency sensor.
16
15
14
13
12 About the Author
11
10
Name: Dennis Seguine
9
8
Title: Member of Technical Staff
7
6
CDS Background: BSEE, MSEE University of California,
Berkeley
Comparing the unfiltered CDS data with the raw data (minus Mr. Seguine has signal processing
the average or initial value) shows that peak to peak span of patents for critical care medical
the signal is reduced. The large low frequency jumps seen in devices, software patents for PSoC
the raw signal indicate that the dominant part of the noise is Designer, and numerous patents
common to reference. Overlaying the averaged CDS data pending for PSoC chip features and
(averaged with the same 1/16 coefficient filter) shows a applications.
measurement with about 1.2 counts peak to peak noise.
Contact: seg@cypress.com
Figure 16. Thermocouple Output with CDS Compensation
CDS Comparison
20
19
18
17
16
15
14
13
12
11
10
9
8 CDS
7 Filt(CDS)
6

Compared to the filtered CDS data to the filtered raw data,


the performance improvement of the CDS technique is
obvious. The standard deviation of the noise is reduced
from 7.6 V to 0.66 V. When the bandwidth of the IIR filter
is reduced, it results in the corresponding reduction of
standard deviation of the noise. This indicates that the noise
is broadband compared to the IIR filter bandwidth.

June 12, 2009 Document No. 001-45198 Rev. *B 7

[+] Feedback
AN2226

Document History
Document Title: Correlated Double Sampling for Thermocouple Measurement
Document Number: 001-45198
Revision ECN Orig. of Change Submission Date Description of Change
** 2274691 SHEA/PYRS 04/06/2008 New application note.
*A 2631863 YARA/PYRS 01/20/2009 Corrected Figure 7.
*B 2718255 FKL 06/12/09 Included ‘Thermocouple Measurement’ in title and
updated software version.

In March of 2007, Cypress recataloged all of its Application Notes using a new documentation number and revision code. This new
documentation number and revision code (001-xxxxx, beginning with rev. **), located in the footer of the document, will be used in all
subsequent revisions.

PSoC is a registered trademark of Cypress Semiconductor Corp. "Programmable System-on-Chip" and PSoC Designer are trademarks of
Cypress Semiconductor Corp. All other trademarks or registered trademarks referenced herein are the property of their respective owners.

Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
Phone: 408-943-2600
Fax: 408-943-4730
http://www.cypress.com/

© Cypress Semiconductor Corporation, 2008-2009. The information contained herein is subject to change without notice. Cypress Semiconductor
Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any
license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or
safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as
critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The
inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies
Cypress against all charges.
This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide
patent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a
personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivative
works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress
integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source
Code except as specified above is prohibited without the express written permission of Cypress.
Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the
right to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application or
use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where a
malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems
application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
Use may be limited by and subject to the applicable Cypress software license agreement.

June 12, 2009 Document No. 001-45198 Rev. *B 8

[+] Feedback

S-ar putea să vă placă și