Fixing the internal Thermocouples - taliesin/T-962-improvements GitHub Wiki

The thermocouples are read using the internal ADC of the LPC2144. The opamp used is a TLC27L2, which is a poor choice as its offset voltage may be up to 10mV (which corresponds to about 250°C!). The amplification is adjusted by trim potentiometers which might have heavy temperature drift, surely more than a normal metal film resistor (~50ppm/K). The adjustment can't fix the offset in the original design! Additionally thermocouples are twisted at the junction and positioned incorrectly.

Fix Thermocouple location and untwist them

This is what we want ...

Thermocouple

  • remove the thermocouples from their tubes
  • untwist carefully

Add cold junction compensation

The proposed method:

Original Coldjunction Compensation

This is not perfect for 2 reasons:

  • it uses parasitic mode (for parasite power Maxim specifies a 'strong' pullup) and there is no real reason for using this mode!
  • thermal coupling to the plastic of the connector is weak

So:

  • use 5V and GND from the nearby un-populated 27L2 (U6), pin 4 and 8 respectively for GND and Vcc
  • lay the TO-92 housing flat onto the PCB (flat side down), putting some thermal grease underneath
  • put the pullup resistor (4.7k, 0805) across C20-R2 and short R2, this way pin 3 of U6 can be used to directly connect DQ pin of the DS18B20 to it (no wire needed).

DS18B20 footprint

This is a somewhat strange setup as the DS18B20 is powered from 5V here, but has a pullup to 3.3V.

This is not a problem for several reasons:

  • 4k7 from 5V to 3.3V will not influence 3.3V (even if DS18B20 would short DQ to VDD)
  • P0.7 is 5V tolerant on the LPC2134 (like almost all pins)

Replace the amplifier, set correct gain

To fix the offset problem use a better opamp, like the OPA2333 (10µV offset, zero drift → less than 0.25°C offset error).

The amplification in the original design is set to around 80, the ADC values in the original software are shifted to the left (dividing it by 2) and taking the value as °C (41.276µV/K). This is of course a pretty bad decision as it reduces resolution for 300°C to about 1V or 310/1024 LSBs. Setting the gain to >220 makes it a lot better and is safe for up to 350°C.

So:

  • remove the trim potentiometers (use the pins either for the second resistor or short them)
  • replace R34 and R37 with accurate (0.1%) 1k resistors (use 1% and select), or keep them and set the gain!
  • replace R38 and R33 with 220k+1.2k resistors (0.1%), gain is 222.2 (see firmware settings below), the second resistors can be placed where the potis were.
  • if accurate resistors are not available one can fall back to trimming the gain in SW.

Check the setup:

  • set the gain to the calculated value (222.2) → see below
  • check the cold junction compensation temperature (this should be about room temperature)
  • at room temperature, possibly correct the offsets so that both TCs show the room temperature value
  • go to 'bake' and set 100°C use a reference temperature probe (need not be a thermocouple) to check the calibration.

NOTE: A gain of over 200 is stable with the OPA2333 without any further changes!

Improve Vref decoupling

Vref of the controller is directly connected to 3.3V, even though the LM1117 has 1% accuracy, this will let Vref pickup noise from the power supply line. Simply cut the nicely visible line that connects pin 63 (Vref) of the controller, insert a 4.7kOhm resistor and place a 100nF capacitor to the nearby C5 GND vias.

All this should allow for an accuracy of about 1%, with some (software) calibration probably even something like 0.5% (about 1.5°C at 300°C), not including the thermocouple errors.

Settings in the new firmware

The calibrations calculates the temperature from the sensor in the following way:

  • oversample 4 times, from 256 samples (somewhat strange mean calculation using a buffer instead of running), so the 10bit values comes out as 16bit value with 14bit 'resolution', see adc.c

  • in sensor.c it gets the gain and offset configuration

    gain (min=10, max=190, default=100) -> defines the multiplier -> 10 .. 0.1, 100 .. 1, 190 .. 1.9 offset(min = 0, max=200, default=100) -> defines additive part -> 0 .. -25, 100 .. 0, 200 .. +25

  • with the default amp (gain ~= 80) and the default configuration (100, 100), this leads to (at 300°C) 300K * 41.276µV/K * 80 = 991mV ... 307 LSBs → 307°C

  • using a pre-amp with gain=222.2 (220k+1.2k) and no offset error leads to: gain setting = 80/222.2 = 0.36003 → setting = 36 300K * 41.276µV/K * 222.2 = 2751 mV ... 854 LSBs → 307°C using a gain setting of 35 instead delivers 299°C

One could improve the resolution of the gain and offset compensation to adjust the range to allow for finer granularity.

Offset compensation

The firmware first adjusts gain and then adds offset, this is correct as offset is caused (mainly) by the opamp. Assuming 200µV of offset (pretty dense for TLC27L2!):

For the original setting:

  • gain=80 → 4.95 LSBs → offset value should be 80, as (80 - 100)*0.25 = -5

For a gain of 222.2:

  • 13.8 LSBs → offset value is (45 -100)*0.25 = -13.75

Note: Offset compensation with the firware min/max only works if the opamp offset is within +/- 362µV.

But TLC27L2 specifies typ. 1.1mV and max 10mV!

Turn around the thermocouple connector

To allow other modifications to the power part of the board the thermocouple connectors should be turned into the opposite direction. This works as the trim potentiometers are gone.