Having trouble with SERIN command and MAX6675


Closed Thread
Results 1 to 40 of 40

Hybrid View

  1. #1
    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 05:24.

  2. #2
    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.

  3. #3
    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 14:19.

  4. #4
    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

  5. #5
    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 16:03.

  6. #6
    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

  7. #7
    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

Members who have read this thread : 2

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