Samstag, 1. Juli 2017

pt-100 temperature logger

Introduction

At work we have this unit to read out pt-100 temperature sensors for monitoring purposes. I was asking myself, if precise temperature logging really needs to be so expensive? I started to design a similar device with the aim of achieving similar performance and functionality.

Pt-100 sensor

Platinum pt-100 temperature sensors are standard devices for temperature measurement with positive temperature coefficient (PTC, resistance increases with temperature) and have 100 Ohm at 0 °C. Using such a sensor requires a precise resistance measurement. This can be done by sending a small current through the sensor and then measuring the voltage drop, but there are a few issues:
  • If current flows through the temperature sensor, there will be power dissipated (P=R*I^2). This causes the sensor to heat up and the resulting temperature measurement will be too high. In order to get precise readings even when there is not much thermal mass coupled to the sensor (for example if air temperature is measured), the current has to be very small. In addition, the current should only be switched on for a short time to take the measurement.
  • Small currents will lead to small voltage drops. A differential amplifier will be necessary in order to fill the dynamic range of the ADC.
  • The commercial unit mentioned in the introduction uses a 24-bit ADC, so I want to use a 24-bit ADC as well.
  • If the sensor is connected to the measurement device through a cable, the cable resistance will add to the sensor resistance and lead to wrong readings. This problem can be overcome by using four wires on the sensor: two for the supply current, and the other two for the voltage reading. This is known as 4-wire measurement. There is also 3-wire measurement, but I'll not support this to keep things simple.
  • The current source for the sensor has to be precise, because current errors will directly lead to errors in the resistance measurement. It may help if the current source is driven by the same reference that is used in the ADC. If that reference is varying (e.g. to higher values), the current will be higher and the measured voltage is higher, which is compensated by the higher reference value. Ideally, ADC and current source are in the same IC.

ADS1248

I found a nice IC that is designed for exactly this application: the ADS1248 from TI. It has four differential programmable gain amplifiers, a 24-bit sigma-delta ADC and two current sources (I only need one). It is controlled via SPI interface. The task is now reduced to interface that part with a microcontroller and a bit of coding. I've chosen the ATMEGA328p as controller and use the VUSB library for USB connectivity to a host computer running a command line tool to control the device.

Design files

The project is a bit more complex. Too much code to include in the blog. I've put the complete project (kicad files, firmware, and command line tool) on github. Feel free to copy, rebuild, improve, ...
https://github.com/miree/tempLoggerNG

Circuit

The circuit has the AVR controller, the ADS1248 and four MOSFETS to switch the current from the source to one of four sensors. For The sensor cables I'll abuse USB mini-B connectors. USB cables have 4 wires (for 4-wire measurements) and the mini-B type is robust, cheap, and small. 

The device

I made the first prototype myself with the toner transfer method
But later I decided to get a professionally manufactured PCB from https://oshpark.com/
Because of the abuse of USB mini-B connectors, it looks a bit like a USB hub... The single USB mini-B connector is for the host PC, the other mini-B connectors are for the sensor cables which need to be equipped with a pt-100 temperature sensor like this:
One lead of the sensor goes to USB-VCC and USB-D+, the other sensor lead goes to USB-GND and USB-D-. This allows a four-wire measurement where the cable resistance drops out. So in principle the cable can be very long and should result in the same measurement as with a short cable.

Calibration

The readings from the ADS1248 chip depend on the temperature of that chip. For really accurate measurements this has to be taken into account. The ADS1248 can measure the voltage drop on an on-board diode junction by connecting it to the ADC. So it is possible to correlate the measured value (of a fixed 100 ohms resistor) with the junction temperature and correct for that. In order to do this I heated up the chip with a heat gun and took some data of the 100 ohm resistor while it was cooling down back to room temperature.
It looks a bit messy but I think the point is clear: The fixed 100 ohm resistor has a lower value, depending on the chip temperature (i.e. the value of V_diode). Using the fitted line, I can correct the measured resistance. Better results might be achieved by using a quadratic correction, but remember that this is the temperature correction of the device. I believe that for values around room temperature (at which the device will be operated most of the time) the linear correction will be fine. The calibration coefficients can be stored into the EEPROM of the ATMEGA328p permanently and needs to be done only once.

Command line tool

Part of the project is a command line tool that communicates with the device using libusb http://libusb.org/
The tool can be used to read temperature value from the device in regular intervals (down to 8 times per second) and display on the terminal as well as saving them to a text file.

A measurement

letting the four probes hanging in the air and touching one sensor after the other with my fingertips results in the following measurement. The sensors react fast because of their low thermal mass. After being touched they approach room temperature again. There is a bit of spread in the different sensors. This is normal because I only have pt-100 of type B, and they are allowed to have a spread in absolute value of ±(0,30°C + 0,005 T).

How cold is my fridge?

How cold is it, and how does it vary with time? With a temperature logger, this question can be answered. I put one of the four sensor cables into the freezer of my fridge. The other three probes are inside the fridge at different locations.
The measurement went over 140 minutes and the compressor switched on two times (~min 40 and ~min 140). The temperature is lowest in the freezer (purple line). The freezer is located in the upper part of the fridge. It seems to be true that the coldest temperature (apart from the freezer) is on the bottom of the fridge (yellow line).

1 Kommentar: