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

    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 04: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 05: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 05: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.

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