Jun 26, 2014 0 Comments in Learning, Peripheral, Sensor, SPI by
Managing the thermocouple MAX31855

This product can be bought at our shop as:

Thermocouples are a common form of temperature measurement devices that are widely used in industrial applications. Achieving high system accuracy from thermocouple measurements can be difficult because there are many sources of error within a given system.

Using an integrated analog front-end + ADC specifically designed for precise measurements of thermocouples makes designs simple, and also provides on-chip cold junction compensation.

By using this peripheral you can get very accurate temperature measurement due the fact that this converter resolves temperatures to 0.25° C, allows readings as high as +1800°C and as low as -270°C, and exhibits thermocouple accuracy of +/-2°C for temperatures ranging from -200°C to +700°C for K-type thermocouples.

Connecting the device

In order to get access to the device you need to should consider the table below.

Mega 2560 extension

Signal J19
Chip Select (active low)
23
N.C.
MISO 20
Clock 15
GND 33
VCC 5

See the board’s data sheet here for further info.

Accessing the device

In order to get access to the device from the user space you must configure the kernel accordingly. There is no dedicated device driver for this peripheral but you can use the SPIdev driver for retrieving needed data!

warning Note: the following example is for Cosino Mega 2560 board but you can adapt it according to your hardware.

Verify DTS file linux/arch/arm/boot/dts/at91-cosino_mega2560.dts is holding the following code into the apb section:

If soyou should check if the spidev device is already present by using the command below:

In case of error you should try to use the modprobe command to load the driver into the kernel as show below:

Then you can redo the above test to verify that the spidev device is ready to use.

Now simply using the utility spidev_fdx (from kernel sources linux/Documentation/spi/spidev_fdx.c) you can read temperature data. You can compile it directly on your host PC simply going into the directory linux/Documentation/spi and by using the command:

Then run it as follow:

Looking at max31855 data sheet we see that each read we get 32 bits as follow:

Name Bits
Temp. Sign
31
Temperature 30 – 18
Fault 16
Int. Temp. Sign 15
Internal Temperature 14 – 4
Short circuited to VCC 2
Short circuited to GND 1
Thermocouple Open 0

So by reading bytes the four bytes 01 98, 1a 60 we get binary number 0000-0001 1001-1000 0001-1010 0110-0000 which means:

  • Temperature is positive (D31 = 0) at 25.5°C (0x66 * 0.25°C)
  • There is no fault (D16 = 0)
  • Internal temperature is positive (D15 = 0) at 26.375°C (0x1a6 * 0.0626)
  • There is no short on VCC, no short on GND and thermocouple is not open.
Facebooktwitterlinkedin
Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *

48 + = 56