Having trouble with SERIN command and MAX6675


Closed Thread
Results 1 to 40 of 40

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    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

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    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

  3. #3
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    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: 2146
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: 1937
Size:  98.7 KB
    Where is the truth?
    Last edited by flotulopex; - 16th April 2017 at 12:42. Reason: typo
    Roger

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    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

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    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

  6. #6
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    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

  7. #7
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    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

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    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

Members who have read this thread : 0

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