MAX31855 via SPI (Thermocouple-to-Digital Converter)

Harry
Moderator
Avatar
Gender:
Location: zwischen Augsburg und Ulm
Age: 59
Posts: 2135
Registered: 03 / 2003
Subject:

MAX31855 via SPI (Thermocouple-to-Digital Converter)

 · 
Posted: 01.10.2012 - 22:02  ·  #1
Hallo @ all,

falls mal jemand in die Verlegenheit kommt o.g. Baustein auslesen und umrechnen zu müssen: bitte sehr :-)

Erstmal ein paar Eckdaten:
Quote

- Cold-Junction Compensation
- 14-Bit, 0.25°C Resolution
- Versions Available for K, J, N, T, and E Type
- Simple SPI-Compatible Interface (Read-Only)
- Detects Thermocouple Shorts to GND or VCC
- Detects Open Thermocouple
- ranging from -250 to +1770°C (je nach Fühlertyp)


Code

Import SPIDriver1;

Define  
  SPIdriver1     = PortC, 4, 3, 7;  // SCK, MOSI, MISO
  SPIorder1      = MSB;
  SPIcPHA1       = 0;
  SPIcPol1       = 0;

Implementation
{$IDATA}

{------------------------------------------------------------------------------}
{ Var Declarations }
Var
  AT                : Integer;
  ATError           : Integer;
{$IDATA}
{------------------------------------------------------------------------------}
{ Functions                                                                    }
{ ---------------------------------------------------------------------------- }
Procedure ReadAT(Kanal:Byte);
  Var JT          : Word;                      // Chip-Temperatur
      B1,B2,B3,B4 : Byte;
  Begin
    Excl(PortC,5);                             // /CS  
    SDelay(200);
    B1:=SPIInpByte1;
    B2:=SPIInpByte1;
    B3:=SPIInpByte1;
    B4:=SPIInpByte1;
    ATError:=((256*Integer(B3))+Integer(B4)) and $0007;
    JT:=((Word(B3)*256)+Word(B4)) SHR 8;       // Chip-Temperatur
    If (B1 and $80)=$80
      then                                     // negative Temperatur
        AT[0]:=(-1*((((not((256*Integer(B1))+Integer(B2))) and $0FFF)+1) SHR 4))-JT;
      else                                     // positive Temperatur
        AT[0]:=(((256*Integer(B1))+Integer(B2)) SHR 4)-JT;
      EndIf;
        Incl(PortC,5);                         // /CS
  End ReadAT;


In AT ist die Temperatur in °C ohne Nachkommastellen.
ATError ist der Fehlercode des Chips (D0..2).
MOSI-Define geht auf einen nicht belegten Port.

Gruss
Harry
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 14 · Cache Hits: 13   36   49 · Page-Gen-Time: 0.019953s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI