Documente Academic
Documente Profesional
Documente Cultură
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
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.
[+] Feedback
AN2226
ADCINC14
49.9 k
Type K
1.0E+03
(+15 mV)
150
1.0E+02
Figure 5. Sequential Offset Subtraction fL is the lower frequency limit (0.01 Hz)
Vdd (5.0V)
49.9 k
Type K
ADCINC14
(+15 mV)
150
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
[+] 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
-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
[+] 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%.
[+] Feedback
AN2226
[+] 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
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
TX8_1_PutSHexInt(fAccum_val);
//tranmit the sample through RS232
TX8_1_PutChar('\n');
//transmit token (line feed)
[+] 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
[+] 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.
[+] Feedback