Ηandling MAX6675 Cold-Junction-Compensated K-Thermocouple to Digital Converter

2014-02-11
2014-02-14
  • Dimitris Katsaounis

    The MAX6675 performs cold-junction compensation and digitizes the signal from a type-K thermocouple.
    The data is output in a 12-bit resolution, SPI™-like, read-only format.
    How it works:
    Force CS pin low to output the first bit on the SO pin. A complete serial interface read requires 16 clock cycles. Read the 16 output bits on the falling edge of the clock. The first bit, D15, is a dummy sign bit and is always zero. Bits D14–D3 contain the converted temperature in the order of MSB to LSB. Bit D2 is normally low and goes high when the thermocouple input is open. D1 is low to provide a device ID for the MAX6675 and bit D0 is three-state.
    My code:

    sub MAX6675(Out Temp , Out D2bit)
    Temp=0
    'Force CS low to output the first bit on the SO pin
    Set CS off
    'Cycle the clock for dummy bit 15
    Set SCK on
    Set SCK off
    'Read bits 14-3 from MAX6675
    For i=1 to 12
    Set SCK on
    wait 1 ms
    if SO=on Then
    Temp=[word]Temp+1
    else
    Temp=[word]Temp+0
    End if
    Rotate Temp Left Simple
    Set SCK off
    Next i
    'Read D2 Bit.
    'Bit D2 is normally low and
    'goes high when the thermocouple input is open
    Set SCK on
    wait 1 ms
    if SO=on then
    D2Bit=1
    else
    D2Bit=0
    end if
    Set SCK off
    'Force CS High to stop transmition
    Set CS on
    Temp=[word]Temp/8
    end sub

     
    Last edit: Dimitris Katsaounis 2014-02-11
  • Anobium

    Anobium - 2014-02-14

    Great posting.

    Can we publish as an include file? See attached. Do you have time to update and test? And, could you document an example call to the method in the attached file? What are the requirements to make this work? Is it just SCK and CS? And, then, could you test be deleting your call to the original function and test using the new device.h file as an <include> file?

    Great job.

     
    Last edit: Anobium 2014-02-14

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks