Hardware Reference
In-Depth Information
There are several versions of the MAX31855 chip: one per cable type. The chip
on Adafruit's breakout board can use only K-type thermocouples. Connect the
wire to the breakout board, being careful to use the correct polarity (red and
yellow wires).
Sketch
Now that the hardware is connected, it is time to deal with the software. This
sketch communicates with the MAX31855 through the SPI bus. The datasheets
explain how the data transmits. The MAX31855 sends 32-bits of data (unless
stopped by the slave select pin), corresponding to several pieces of information.
The transmission is shown in Table 7-3.
Table 7-3: MAX31855 Data Output
BIT
NAME
FUNCTION
D[31:18]
14-bit thermocouple tempera-
ture data
Contains signed 14-bit thermocouple
temperature
D17
Reserved
Always reads as 0
D16
Fault
Reads as 1 if a fault is detected, otherwise 0
D[15:4]
12-bit internal temperature
data
Contains signed 12-bit cold junction
temperature
D3
Reserved
Always reads as 0
D2
SCV Fault
Reads 1 if the thermocouple is shorted to
VCC
D1
SCG Fault
Reads 1 if the thermocouple is shorted to
ground
D0
OC Fault
Reads 1 if the thermocouple is not
connected
The data is delivered in a 32-bit package, but there is something interesting
about the layout. It can be seen as two 16-bit values: bits D31 to D16 and D15
to D0. The i rst 16-bits contains everything that is essential: the temperature
detected on the thermocouple and a fault bit. If there is a fault, or if the user
wants to know the cold-junction temperature, then the second 16-bit value can
be read, but otherwise, it is not required.
Time to write the sketch as follows in Listing 7-1:
Listing 7-1: Digital Thermometer Sketch (fi lename: Chapter7.ino)
1 #include <SPI.h>
2
3 const int slaveSelectPin = 10;
 
Search WWH ::




Custom Search