Having trouble with SERIN command and MAX6675


Closed Thread
Results 1 to 40 of 40
  1. #1
    Join Date
    Dec 2010
    Posts
    48

    Default Having trouble with SERIN command and MAX6675

    Hello again. I'm trying to have a 16f630 receive serial data from a MAX6675. I read the SERIN section in the help topic but I still can't understand how to set it up. here are the datasheets for the chips and my code as well:

    http://www.datasheetarchive.com/pdf-...-301/8892.html

    http://pdf1.alldatasheet.com/datashe...IP/16F630.html

    Code:
    INCLUDE "modedefs.bas"
    
    'Setup MAX6675 - Thermocouple
    MAXData	var    porta.5   ' MAXpin7
    MAXcs	var    porta.4	' MAXpin6
    MAXClock  var    porta.2  ' MAXpin5
    
    MAXResult var word
    THC	var word	' degrees Celsius (* power of 10)
    THF	var word    'stores degrees F
    
    Main:
    
      low MAXcs	' select chip
      serin maxdata, N2400,maxclock, [MAXResult\16]	' get data
      high MAXcs	' start new data apture
       
    THC= (MAXResult/32) ' Deg. C
    THF= (((THC*18)/10)+32) 'Conversion to Deg. F
    
    lcdout $fe, 1
    lcdout "Temperature: ", dec THF, "F"] 'display temp. on LCD
    
    pause 20 'give time between read cycles for MAX6675 to work right
    
    goto Main
    Last edited by emerson; - 10th December 2010 at 05:32.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Wrong type of serial. This shows how to read it
    http://www.picbasic.co.uk/forum/show...1178#post71178
    And if you want degrees F add this bit
    TempF = ABS(TempC) */ 461
    TempF = TempF + 32
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Wrong type of serial. This shows how to read it
    http://www.picbasic.co.uk/forum/show...1178#post71178
    And if you want degrees F add this bit
    TempF = ABS(TempC) */ 461
    TempF = TempF + 32
    I tried the code and when I compile I get a "Invalid RAM location specified". How can I fix this?

    Also, all I see on the LCD is a line of black boxes across the top row. Is this a timing problem?
    The same circuit setup works with my other lcd program so I know it's not a wiring error.

    I still need to change the ports...whoops
    Last edited by emerson; - 10th December 2010 at 06:03.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Normally black boxes are a contrast problem, but is the LCD cod is the same as on another project...

    Post your whole current code and config setup so we can have a look.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Normally black boxes are a contrast problem, but is the LCD cod is the same as on another project...

    Post your whole current code and config setup so we can have a look.
    This is what I have so far:

    Code:
     INCLUDE "modedefs.bas"
    
    define    OSC 4
    
    'Alias pins - MAX6675 temp sensor
    MXSCLK  var     PORTA.5   'Clock
    MXCS     var     PORTA.2    'Chip Select
    MXSO     Var     PORTA.4   'Serial out
    
     'Allocate MAX6875 Variables
    MXTemp   var     word    'raw data from 6675/type K sensor
    TempC   var     word    'converted to degrees C
    
    
    '-----------Read and display temperature from MAX6675-----------
    MXCS = 0  'Chip select low
    shiftin MXSO, MXSCLK, 0, [MXTemp\16]   'read the data to MXTemp
    MXCS = 1    'Chip select high
    TempC = MXtemp >> 5   'right shift the data 5 places to get degrees C (Read the Data sheet)
    LCDOUT $fe,2,"Temp = ", DEC TempC, "degrees C "  ' Spit it out on an LCD
    The contrast on the LCD is alright I have it adjusted properly. What does "Invalid RAM location specified" mean?
    Last edited by emerson; - 10th December 2010 at 06:24.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    What does "Invalid RAM location specified" mean?
    In this case it means you are compiling a LCDOUT command without having LCD defines.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    In this case it means you are compiling a LCDOUT command without having LCD defines.
    Alright, I put my LCD defines into the code and i get a readout of 32 degrees F (the temp probe on my multimeter reads the room is 70 degrees F), but the temperature didn't change when I put a lighter to the temp probe. I added a main loop to cycle through the program but that didn't help. Is it something with the SHIFTIN command or could I have fried the surface mount chip when soldering leads to it?
    And thank you for your help. I've been working on this for weeks with no turnout.

    Here is my current code:

    Code:
    INCLUDE "modedefs.bas"
    
    define    OSC 4
    
    'Define LCD registers and bits
    DEFINE LCD_DREG PORTC 'Define PIC port used for LCD Data lines
    DEFINE LCD_DBIT 0 'LCD Data Starting Bit = Bit 0 or 4
    DEFINE LCD_EREG PORTC 'Define PIC port used for E line of LCD
    DEFINE LCD_EBIT 5 'Define Port pin used for E connection
    DEFINE LCD_RSREG PORTC 'Define PIC port used for RS line of LCD
    DEFINE LCD_RSBIT 4 'Define Port pin used for RS connection
    DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD
    DEFINE LCD_LINES 2 'Define using a 2 line LCD
    DEFINE LCD_COMMANDUS 2000 'Define delay time between sending LCD commands
    DEFINE LCD_DATAUS 50 'Define delay time between data sent.
    
    Pause 500 ' Wait for LCD to startup
    
    'Alias pins - MAX6675 temp sensor
    MXSCLK  var     PORTA.5   'Clock MAX pin 5
    MXCS     var     PORTA.2    'Chip Select MAX pin 6
    MXSO     Var     PORTA.4   'Serial out MAX pin 7
    
     'Allocate MAX6875 Variables
    MXTemp   var     word    'raw data from 6675/type K sensor
    TempC   var     word    'converted to degrees C
    TempF     var   word
    
    
    '-----------Read and display temperature from MAX6675-----------
    
    Main:
    
    MXCS = 0  'Chip select low
    shiftin MXSO, MXSCLK, 0, [MXTemp\16]   'read the data to MXTemp
    MXCS = 1    'Chip select high
    TempC = MXtemp >> 5   'right shift the data 5 places to get degrees C (Read the Data sheet)
    TempF = ABS(TempC) */ 461
    TempF = TempF + 32
    lcdout $fe, 1
    LCDOUT $fe,2,"  Temperature "
    lcdout $fe, $c0, " Faren=", DEC Tempf, " Cel=", dec tempc ' Spit it out on an LCD
    pause 500
    
    goto main
    Last edited by emerson; - 10th December 2010 at 15:19.

  8. #8
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    You want to read each bit on the falling edge of the clock so use mode 2. And you only need to shift MXtemp >> 3. Not 5.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  9. #9
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    You want to read each bit on the falling edge of the clock so use mode 2. And you only need to shift MXtemp >> 3. Not 5.
    I changed both but there's still no response? On the datasheet it says the MAX6675 serial clock frequency is 4.3MHz, and I'm running my pic at 4MHz, will this effect data communication?
    Last edited by emerson; - 10th December 2010 at 17:03.

  10. #10
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    If you have an O-scope check the data out pin. That will at least let you know if it's responding.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  11. #11
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    If you have an O-scope check the data out pin. That will at least let you know if it's responding.
    the O-scope test checked out alright

  12. #12
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    I just disabled the comparators in the chip but it still won't. I even replaced the thermocouple and the MAX76675 but i get the same response. I have no idea what could be wrong with this. Any ideas?
    Last edited by emerson; - 10th December 2010 at 18:44.

  13. #13
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Have you tried sending the raw value received 'without modifying it' to your LCD while heating or cooling the part?

    Something like: lcdout $fe, $c0, BIN16 MXtemp

    Does it change when heated?

    Edit: Since you're using the internal osc on this one, place Define OSCCAL_1K 1 in the top section. Not sure it that will fix it, but it will for sure affect timing.
    Last edited by Bruce; - 10th December 2010 at 18:48. Reason: Define OSCCAL_1K 1
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  14. #14
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Have you tried sending the raw value received 'without modifying it' to your LCD while heating or cooling the part?

    Something like: lcdout $fe, $c0, BIN16 MXtemp

    Does it change when heated?

    Edit: Since you're using the internal osc on this one, place Define OSCCAL_1K 1 in the top section. Not sure it that will fix it, but it will for sure affect timing.
    I just tried it and there is no change

  15. #15
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    What's the 16-bit value shown?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  16. #16
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    What's the 16-bit value shown?
    0000 0000 0000 0000

    zeros across the board with no change to heat

  17. #17
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Is the thermocouple a K type?
    The code given in the link I gave works.
    Check the hardware. Bad connections or backwards connection on the thermocouple or wrong type will cause problems.
    Dave
    Always wear safety glasses while programming.

  18. #18
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Did you look at the data output pin on the MAX chip with your O-scope to see if it's changing the value sent?

    If you send 16 clocks, and the data line stays at ground, I would think there's a problem with the MAX IC. If you see transitions on the data line, there's something going on with the PIC side.
    Last edited by Bruce; - 10th December 2010 at 20:30.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  19. #19
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Is the thermocouple a K type?
    The code given in the link I gave works.
    Check the hardware. Bad connections or backwards connection on the thermocouple or wrong type will cause problems.
    Both the thermocouples I have are K type and are connected properly. The ground lead on the thermocouple is tied to ground as well as the negative input on the MAX6675 as demonstrated in the datasheet. I did a continuity test on all wires coming from the chip and they're all good.

  20. #20
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    is the code you gave specifically for the 16f630?

  21. #21
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    No. The code shows how to use the MAX chip.
    Dave
    Always wear safety glasses while programming.

  22. #22
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    i found in this post (http://www.picbasic.co.uk/forum/show...1178#post71178) that you stated you need a temperature
    reference for every time the wire material from the thermocouple changes.

    Anyplace the wire material changes you need a reference temperature and calcs. A couple exceptions here and there though.
    I had copper wire soldered to the terminals on my thermocouple. I disconnected the copper wires but it didn't help
    Last edited by emerson; - 10th December 2010 at 21:47.

  23. #23
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Do you have pin #6 (CS) on the MAX6675 pulled low? I use a 10K to the zero rail on mine.
    Dave
    Always wear safety glasses while programming.

  24. #24
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    MAX6675 need more than 200 millisecs for the temperature convertion. You are polling too fast so you don't get any response. Place a delay of 250 msecs to allow convertion.

    edit:My note was reffered to code seen in post#5. I just see that you added delay 500 in your code in post #7, so my answer is obsolete.
    My new suggestion are :

    add INCLUDE "modedefs.bas" on top of your code
    and modify your SHIFTIN command adding:

    shiftin MXSO, MXSCLK, MSBPRE, [MXTemp\16] 'read the data to MXTemp

    and see if it works.



    Al.
    Last edited by aratti; - 11th December 2010 at 12:51.
    All progress began with an idea

  25. #25
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default it's working... but bit-shifting not clear to me :-(

    Hi,

    It's my first time using a MAX6675 k-type thermocouple converter and got it to work thanks to (99%) of the info in this thread .

    AAMOF, I had to modify one info found above and it is about bit shifting.

    First, my working code (and hopefully correct) is:
    Code:
    ' ====== FUSES ====================================================================================
    ' PIC 16F690
    @ __Config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_INTRC_OSC_NOCLKOUT &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF 
    
    ' ====== REGISTERS ================================================================================
    '             76543210
    OPTION_REG = %10000000 ' PORT A&B Pull-Ups disabled (see WPUA & WPUB)
    OSCCON     = %01100000 ' Internal RC set to 4Mhz - not to be used with XTal
    ANSEL      = %00000000 ' Analog inputs Channels Bit<0>=0 to Bit<7>=7
    ANSELH     = %00000000 ' Analog inputs Channels Bit<0>=8 to Bit<3>=11 
    ADCON0     = %00000000 ' A/D Module OFF 
    CM1CON0    = %00000000 ' Comparator1 Module is OFF
    CM2CON0    = %00000000 ' Comparator2 Module is OFF
    INTCON     = %00000000 ' INTerrupts CONtrol
    PORTA      = %00000000 ' Ports High/Low (0 to 5)
    TRISA      = %00000000 ' Set Input/Output (0 to 5)
    PORTB      = %00100000 ' Ports High/Low (4 to 7) B5=MAX6675-CS
    TRISB      = %00010000 ' Set Input/Output (4 to 7) B4=MAX6675-SDO
    PORTC      = %00000000 ' Ports High/Low (0 to 7)
    TRISC      = %00000000 ' Set Input/Output (0 to 7)
    
    ' ====== DEFINES ==================================================================================
    DEFINE OSC 4
    
    DEFINE SHIFT_PAUSE 250  'for MAX6675 conversion time
    
    DEFINE LCD_DREG PORTC   'LCD data port 
    DEFINE LCD_DBIT 0       'LCD data starting bit 0 or 4 on µC 
    DEFINE LCD_RSREG PORTC  'LCD Register Select port 
    DEFINE LCD_RSBIT 4      'LCD Register Select bit 
    DEFINE LCD_EREG PORTC   'LCD Enable port 
    DEFINE LCD_EBIT 5       'LCD Enable bit 
    DEFINE LCD_BITS 4       'LCD bus size 4 or 8 
    DEFINE LCD_LINES 2      'Line number on LCD 
    
    ' ====== VARIABLES ================================================================================
    MAX6675_SDO var PORTB.4
    MAX6675_CS  var PORTB.5
    MAX6675_SCK var PORTB.6
    
    RawTemp     var word
    RawTemp     = 0
    Temp        var byte
    Temp        = 0
    TempUnit    var byte
    TempUnit    = 0
    TempDec     var byte
    TempDec     = 0
    
    ' ====== PROGRAM ==================================================================================
    
    PAUSE 500   ' time for LCD to settle
    
    MAX6675_READ:    
    
      MAX6675_CS = 0
      shiftin MAX6675_SDO,MAX6675_SCK,0,[RawTemp\16] 'mode is MSBPRE
      MAX6675_CS = 1
      
      Temp = RawTemp >> 2
    
      TempUnit = Temp / 10 'get temperature Units for display
      TempDec =  Temp MOD 10 'get temperature Decimals for display
      lcdout $FE, $80,"BIN ", BIn16 Rawtemp
      lcdout $FE, $C0,"Tmp ", DEC TempUnit,".",dec TempDec," C"
      
      PAUSE 1000
      
    GOTO MAX6675_READ
    END
    According to the MAX6675 datasheet: "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".

    If I get it well, when reading the termocouple, I get 16 bits and I need to "keep" bits 14 to 3.
    Name:  2017-04-15 21_53_35-MAX6675K-Type Thermocouple IC.pdf - SumatraPDF.jpg
Views: 1084
Size:  21.4 KB

    So, to get the (what I hope is correct) right value, why do I have to shift by "2" instead of what has been said above (shift by 3) or even shift by 1 since bit 14 is the second bit to start with?
    Roger

  26. #26
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: it's working... but bit-shifting not clear to me :-(

    Unless you are trying to get the fractional part of the reading 10 bits is all you need.
    Dave
    Always wear safety glasses while programming.

  27. #27
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: it's working... but bit-shifting not clear to me :-(

    Quote Originally Posted by mackrackit View Post
    Unless you are trying to get the fractional part of the reading 10 bits is all you need.
    I don't get it, Dave...
    Roger

  28. #28
    Join Date
    May 2013
    Location
    australia
    Posts
    2,380


    Did you find this post helpful? Yes | No

    Default Re: Having trouble with SERIN command and MAX6675

    why do I have to shift by "2" instead of what has been said above (shift by 3) or even shift by 1 since bit 14 is the second bit to start with?
    the data can be read in msb first by shiftin but it is then translated to a normal binary representation so bit 14 is read as bit 14.

    shifting by 2 is incorrect , as dave indicated
    Temp = RawTemp >> 5
    will get the high 10 bits of the 12bit reading ,resulting in the integer component of the reading

    or

    Temp = RawTemp >> 3
    int_part=temp/4
    fract_part=(temp//4)*25

    lcdout $FE, $C0,"Tmp ", #int_part,".",dec2 fract_part," C"
    Warning I'm not a teacher

  29. #29
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: Having trouble with SERIN command and MAX6675

    This is confusing to me.

    My code gives me almost exactly what my home thermometer shows:
    Name:  K640_20170416_132314.JPG
Views: 1124
Size:  80.3 KB

    This code
    Code:
    Temp = RawTemp >> 3
    int_part=temp/4
    fract_part=(temp//4)*25
    lcdout $FE, $C0,"Tmp ", #int_part,".",dec2 fract_part," C"
    display this:
    Name:  K640_20170416_132716.JPG
Views: 982
Size:  98.7 KB
    Where is the truth?
    Last edited by flotulopex; - 16th April 2017 at 13:42. Reason: typo
    Roger

  30. #30
    Join Date
    May 2013
    Location
    australia
    Posts
    2,380


    Did you find this post helpful? Yes | No

    Default Re: Having trouble with SERIN command and MAX6675

    for a start your temp var is a declared as byte , how can 12 bit reading fit in that ?
    Warning I'm not a teacher

  31. #31
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: Having trouble with SERIN command and MAX6675

    I corrected my code just after I sent it - couldn't edit the post anymore, should have mentionned it, sorry
    Roger

  32. #32
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: Having trouble with SERIN command and MAX6675

    Anyway, I understand the calculation to get the temperature value BUT why do I have around 5°C diffrence between the thermocouple and my home thermometer?

    Must a thermocouple be kind of "adjusted" (correct the result in the code) or something like that?
    Roger

  33. #33
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: Having trouble with SERIN command and MAX6675

    My actual code is:
    Code:
    ' ====== FUSES ====================================================================================
    ' PIC 16F690
    @ __Config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_INTRC_OSC_NOCLKOUT &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF 
    
    ' ====== DEFINES ==================================================================================
    DEFINE OSC 4
    
    DEFINE SHIFT_PAUSE 250  'for MAX6675 conversion time
    
    DEFINE LCD_DREG PORTC   'LCD data port 
    DEFINE LCD_DBIT 0       'LCD data starting bit 0 or 4 on µC 
    DEFINE LCD_RSREG PORTC  'LCD Register Select port 
    DEFINE LCD_RSBIT 4      'LCD Register Select bit 
    DEFINE LCD_EREG PORTC   'LCD Enable port 
    DEFINE LCD_EBIT 5       'LCD Enable bit 
    DEFINE LCD_BITS 4       'LCD bus size 4 or 8 
    DEFINE LCD_LINES 2      'Number lines on LCD 
    
    ' ====== REGISTERS ================================================================================
    '             76543210
    OPTION_REG = %10000000 ' PORT A&B Pull-Ups disabled (look WPUA & WPUB)
    'OSCCON     = %01100000 ' Internal RC set to 4Mhz - not to be used with XTal
    ANSEL      = %00000000 ' Analog inputs Channels 0 to 7
    ANSELH     = %00000000 ' Analog inputs Channels 8 to 11
    ADCON0     = %00000000 ' A/D Module is OFF
    CM1CON0    = %00000000 ' Comparator1 Module is OFF
    CM2CON0    = %00000000 ' Comparator2 Module is OFF
    INTCON     = %00000000 ' INTerrupts CONtrol / RA2 is ON
    PORTA      = %00000000 ' Ports High/Low (0 to 5)
    TRISA      = %00000000 ' Set Input/Output (0 to 5)
    PORTB      = %00000000 ' Ports High/Low (4 to 7)
    TRISB      = %00000000 ' Set Input/Output (4 to 7)
    PORTC      = %00000000 ' Ports High/Low (0 to 7)
    TRISC      = %00000000 ' Set Input/Output (0 to 7)
    
    ' ====== VARIABLES ================================================================================
    MAX6675_SDO var PORTB.4
    MAX6675_CS  var PORTB.5
    MAX6675_SCK var PORTB.6
    
    Temperature var word
    Temperature = 0
    
    ' ====== PROGRAM ==================================================================================
    
    MAX6675_READ:
        
        MAX6675_CS = 0
        shiftin MAX6675_SDO,MAX6675_SCK,0,[Temperature\16]
        MAX6675_CS = 1
    
        Temperature = Temperature >> 3
        
        lcdout $FE,2,DEC Temperature/4,",",DEC (Temperature//4)*25," C"
        
        PAUSE 1000
    
    Goto MAX6675_READ:
    
    END
    Roger

  34. #34
    Join Date
    May 2013
    Location
    australia
    Posts
    2,380


    Did you find this post helpful? Yes | No

    Default Re: Having trouble with SERIN command and MAX6675

    if you have cheap ebay sourced k type probes a reading of 5 -+ is typical , they seem more accurate [precise anyway] at higher temps >200c
    but there is still a fair spread of variation in the readings

    how to interpret reading
    Attached Images Attached Images  
    Warning I'm not a teacher

  35. #35
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: Having trouble with SERIN command and MAX6675

    Thanks Richard,

    With your calculation example you gave me above, I could understand how to read my result.

    Do you know if thermocouples are "qualified" according to their precision?

    PS: yup, mine has made the travel from China
    Roger

  36. #36
    Join Date
    May 2013
    Location
    australia
    Posts
    2,380


    Did you find this post helpful? Yes | No

    Default Re: Having trouble with SERIN command and MAX6675

    Do you know if thermocouples are "qualified" according to their precision?
    not cheapies on ebay .

    a more likely source of some probes with actual specs would be rs components ,farnel/element14 ,digikey or similar
    but they will cost more.

    I have never had the need for real absolute accuracy and just add or subtract a suitable offset to compensate for error,
    so far it works acceptably for my 3d printer [precision being more important]
    Warning I'm not a teacher

  37. #37
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Having trouble with SERIN command and MAX6675

    And I will add... Take extra care with your cold junctions. The 6675 does a good job compensating if the junction is close and in the same environment as it is. As do not have the cold junction on the outside of an enclosure and the 6675 on the inside. And noise that can be picked up from breadboard connections can be trouble.
    Dave
    Always wear safety glasses while programming.

  38. #38
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: Having trouble with SERIN command and MAX6675

    Quote Originally Posted by mackrackit View Post
    ...As do not have the cold junction on the outside of an enclosure and the 6675 on the inside.
    How do you mean this?
    Roger

  39. #39
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Having trouble with SERIN command and MAX6675

    The MAX6675 has cold junction compensation built in, but only works if the cold junction is close to the MAX6675.
    This article explains cold junction compensation in detail. https://www.maximintegrated.com/en/a...ex.mvp/id/4026
    Dave
    Always wear safety glasses while programming.

  40. #40
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Thumbs up Re: Having trouble with SERIN command and MAX6675

    Nice and very interresting.

    Thanks a lot
    Roger

Members who have read this thread : 1

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

Posting Permissions

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