Max31855 Thermocouple Temperature Reading


Closed Thread
Results 1 to 6 of 6
  1. #1
    Lefteris's Avatar
    Lefteris Guest

    Smile Max31855 Thermocouple Temperature Reading

    I was looking hard to find a picbasic code for the new MAX31855 from Maxim but I could't find anywhere.
    This is a nice chip to read temperature from -210 up to 1300 C for many types of thermocouples with internal ColdJuction and faults report!!.
    Here is datasheet for details : http://datasheets.maximintegrated.co...s/MAX31855.pdf

    Thermocouples are using for high temperatures, so I am not interesting for negative sign !!!
    I send data to PC using Hyperterminal at 9600 bauds.
    Brown out detect is disable So I can use 3.3 Volts supply on my pic16f877A
    I hope this code is usefull for you as is for me!

    Code:
    define OSC 20
    @ DEVICE PIC16F877A,HS_OSC,WDT_ON,MCLR_OFF,BOD_Off,LVP_OFF,PROTECT_OFF
    include "modedefs.bas"
    
    
    '----- Data Output To Pc Without MAX232 at 9600bauds reverse ----
    
    DataTx var portc.6  'TX serial data to PC 
    BaudTx con 16468     '9600 bauds reverse
    
    
    
    'Alias pins - MAX31855 temp sensor
           MXSCLK      var     PORTD.0   'MAX31855 Clock 
           MXCS        var     PORTD.1   'MAX31855 Chip Select 
           MXSO        Var     PORTD.3   'MAX31855 Serial Data  
           '--Variables----------------------- 
           TCtemp       var     word    'raw data from MAX31855
           tempC       var     word    'temperature in degrees C 
           tempF       var     word    'temp C converted to degrees F  
           CJtemp       var     word    'raw data from MAX31855
           tempcjC       var     word    'temperature ColdJuction in degrees C 
           tempcjF       var     word    'ColdJuction C converted to degrees F  
         
    
    
      '-----------Read and display temperature from MAX31855----------- 
      
           main: 
      
           'Read Temp of Thermocouple
           
           LOW MXCS                            'chip select low     
           shiftin MXSO, MXSCLK, 0, [TCtemp\16] 'shift in the data     
           HIGH MXCS                           'chip select high     
          tempC =   TCtemp >> 4              'side shift to ditch the stuff to the right of the decimal point and just show whole degrees)       
          tempF = ((tempC * 18)/10) + 32      'convert C to F             
         
         '--------- Send Temp To PC ------------------
          if TempC.bit11 = 0 then        'Positive Sign of Temperature
          SEROUT2 DataTx,BaudTx, ["Theromocouple ",dec tempc ," degrees C  ",dec tempF," degrees F  " ,10,13 ] 'display the data on PC     
           PAUSE 1000
           else 
            SEROUT2 DataTx,BaudTx, ["OUT of Range ",10,13 ]
            pause 1000
                 endif
           
          'Read Temp of ColdJuction 
           LOW MXCS                            'chip select low     
           shiftin MXSO, MXSCLK, 0, [CJtemp\32] 'shift in the data     
           HIGH MXCS                           'chip select high     
          tempcjC  =   CJtemp>> 8                 'side shift to ditch the stuff to the right of the decimal point and just show whole degrees)       
          tempcjF  = ((tempcjC * 18)/10) + 32      'convert C to F             
         
          
          
          '--------- Send Cj Temp To PC ------------------
          SEROUT2 DataTx,BaudTx, ["ColdJuction ",dec tempcjc ," degrees C  ",dec tempcjF," degrees F  " ,10,13 ] 'display the data on PC    
           pause 1000
         
         
         'Check Thermocouple Status
          IF CJtemp.bit0=1  THEN
          SEROUT2 DataTx,BaudTx, [" NO CONNECTION  " ,10,13 ] 'display the data on PC    
               pause 1000  
           ENDIF
       
         IF CJtemp.bit1=1  THEN
          SEROUT2 DataTx,BaudTx, [" SHORT to GND " ,10,13 ] 'display the data on PC 
              pause 1000  
           ENDIF
    
            IF CJtemp.bit2=1  THEN
          SEROUT2 DataTx,BaudTx, [" SHORT to VCC   " ,10,13 ] 'display the data on PC  
        PAUSE 1000 
           ENDIF 
           
           goto main    
           end
    Last edited by Archangel; - 21st January 2015 at 03:55.

  2. #2
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: Max31855 Thermocouple Temperature Reading

    Thank you!
    Thanks and Regards;
    Gadelhas

  3. #3
    Join Date
    Jan 2013
    Posts
    1


    Did you find this post helpful? Yes | No

    Default Re: Max31855 Thermocouple Temperature Reading

    Thank you, I modify your code to work with PIC16F690 and to display temperature on serial 20x4 LCD and it works great.

  4. #4
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Max31855 Thermocouple Temperature Reading

    I have also tried to modify this code for LCD, but I'm getting very low readings in C. and also, they change strangely - when I heat thermocouple, they start to increase, than at some point (always different), will decrease by 5-10C and then again increase.

  5. #5
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Re: Max31855 Thermocouple Temperature Reading

    Thanks Lefteris - this was very helpful. Not clear why you shift the data right by 4 bits, but it works great. Thanks for posting this!
    "Do or do not, there is no try" Yoda

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Max31855 Thermocouple Temperature Reading

    Code:
    @ __config _HS_OSC & _WDT_ON & _PWRTE_ON &_BODEN_OFF & _LVP_OFF & _CPD_OFF
    Appears orig. config was for PB compiler AND NOT for 16F877a as stated as there is NO MCLR or PROTECT
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts