Is this a K Type sensor?


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default finally got around to it

    Hi Steve,

    It took some time but I finally got around to trying to get the sensor up and running but I'm not having any success. I'm pretty sure I have everything configured ok with your code. Could you please have a look and see if there's something that you can see that I've done wrong here? Any help from anyone would be very much appreciated. I included the schematics I used in an attachment here.

    Thanks
    jessey

    Code:
    '**************************************************************************
    '* Name    : Furnace Temperature Probe                                    *
    '* Author  : Jessey Montgomery                                            *
    '* Includes: Byte_Butchers code to read temperature using a MAX6675       *  
    '* Date    : April 24/th 2009                                             *
    '* Version : Using PicBasic Pro Ver 2.50, MPASM Ver 5.20, Using MicroCode *
    '*         : Studio 3.0.0.5, PICkit 2 programmer - Application Version    *
    '*         : 2.50.02 - Device File Version 1.5100 - OS Firmware Version   *
    '*         : 2.30.01. Using a Pic16F688-I/P 04470AY.                      *
    '**************************************************************************
    
    '(1) Comments & Objectives
    '   =====================
    ' this program is used to display the temperature from a K type sensor using a
    ' MAX6675 interface...
    
    '------------------------------------------------------------------------------'
    
    'Connections for the PICKIT 2 Programmer for a 16F688
    'Pickit 2 pins                   16f688 pins
    '=============                   ===========
    '     1 ...... Connect to ...... pin 4       RA3/MCLR/VPP
    '     2 ...... Connect to ...... pin 1       VDD (positive)
    '     3 ...... Connect to ...... pin 14      VSS (ground)
    '     4 ...... Connect to ...... pin 13      RA0/AN0/C1IN+/ICSPDAT/ULPWU
    '     5 ...... Connect to ...... pin 12      RA1/AN1/C1IN-/VREF/ICSPCLK
    '     6......................................no connection
    '*Note
    'Put a 0.1mf capicator on pin 1 of 16f688 to ground
    
    '------------------------------------------------------------------------------'
    
    '                               --------------
    '                               |   16f688   |
    '                   VDD+ (--->) |1         14| (<---) VSS-
    '                               |            |
    '   RA5/TICKI/OSC1/CLKIN (<-->) |2         13| (<-->) RA0/AN0/C1IN+/ICSPDAT/ULPWU 
    '                               |            |
    'RA4/AN3/TIG/OSC2/CLKOUT (<-->) |3         12| (<-->) RA1/AN1/C1IN-/Vref/ICSPCLK 
    '                               |            |
    '            RA3/MCLR/Vpp(--->) |4         11| (<-->) RA2/AN2/TOCKI/INT/C1OUT
    '                               |            |
    '              RC5/RX/DX (<-->) |5         10| (<-->) RC0/AN4/C2IN+
    '                               |            |
    '        RC4/C2OUT/TX/CX (<-->) |6          9| (<-->) RC1/AN5/C2IN-
    '                               |            |
    '                RC3/AN7 (<-->) |7          8| (<-->) RC2/AN6
    '                               |            |
    '                               --------------
    
    '------------------------------------------------------------------------------'
    ' --------------------------------------------------------------------------------
     
    
    '                            Configuration Of Pins
    '                            =====================
    '                                ------------
    '                                |  16f688  |
    '                           VDD+ |1       14| VSS-
    '                                |          |
    '                       Not Used |2       13| Clock output for 6675 to pin 5     
    '                                |          |
    '                       Not Used |3       12| Chip Select output for 6675 pin 6              
    '                                |          |
    '                       Not Used |4       11| Serial input from 6675 to pin 7      
    '                                |          |
    '  Blue/White.........Enable bit |5       10| Data bit 4...............Blue
    '                                |          |
    '  Orange/Black..Register select |6        9| Data bit 5..............White
    '                                |          |
    '  Orange.............Data bit 7 |7        8| Data bit 6..............Green
    '                                |          |
    '                                ------------
    
    '------------------------------------------------------------------------------'
    
    '                               --------------
    '                               |  MAX6675   |
    '                        -5 VSS |1          8| No Connection
    '                               |            |
    '          T- Alumel Lead (Red) |2          7| Serial Output to 688 pin 11  
    '                               |            |
    '       T+ Chromel Lead (yellow)|3          6| Chip Select input to 688 pin 12        
    '                               |            |
    '                        +5 VDD |4          5| Serial Clock in from 688 pin 13 
    '                               --------------
    
    
    '(2) PIC Config Fuse Definitions for 16f688
    '   ======================================
     @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF & _BOD_ON   
     @ ERRORLEVEL -306; ' turns off cross page boundary message alerts after compile
    
    '(3) PIC Hardware Definitions (ie Pin-Out & Port Assignments)
    '   ========================================================
     DEFINE LCD_RSREG PORTC' LCD Register Select Port  
     DEFINE LCD_RSBIT 4    ' LCD Register Select 
     DEFINE LCD_EREG PORTC ' LCD Enable Port  
     DEFINE LCD_EBIT 5     ' LCD Enable      
     DEFINE LCD_DREG PORTC ' LCD Data Port 
     DEFINE LCD_DBIT 0     ' LCD data starting bit 0 or 4 
     
    '------------------------------------------------------------------------------'
    '------------- Clear Each Port Before Setting The TRIS Registers --------------'
    '------------------------------------------------------------------------------'
                                    
     Clear   ' Set all ram registers to zero
     PORTA = 0
     PORTC = 0                           
    
    '--------------------------- VSS VDD MCLR Ect. Pins ---------------------------'
     
    'VDD +       '(pin 1)
    'VSS -       '(pin 14)
     
     '------------------- SET THE TRIS  ------------------'               
     
     '-------------------- PORTA PINS --------------------' 
    
     TRISA.0 = 0 '(pin 13) ...................................... MXSCLK VAR PORTA.0   
     TRISA.1 = 0 '(pin 12) .........................................MXCS VAR PORTA.1   
     TRISA.2 = 1 '(pin 11) .........................................MXSO VAR PORTA.2               
     TRISA.3 = 1 '(pin 4)  ............... NOT USED VAR PORTA.3      
     TRISA.4 = 1 '(pin 3)  ............... NOT USED VAR PORTA.4      
     TRISA.5 = 1 '(pin 2)  ............... NOT USED VAR PORTA.5   
    
     '-------------------- PORTC PINS --------------------'
     TRISC.0 = 0 '(pin 10) Blue........... Lcd Data bit 4   
     TRISC.1 = 0 '(pin 9)  White.......... Lcd Data bit 5 
     TRISC.2 = 0 '(pin 8)  Green.......... Lcd Data bit 6              
     TRISC.3 = 0 '(pin 7)  Orange......... Lcd Data bit 7  
     TRISC.4 = 0 '(pin 6)  Orange/Black... Lcd Register select     
     TRISC.5 = 0 '(pin 5)  Blue/White..... Lcd Enable bit 
    
     ANSEL = %00000000  ' set all adc pins to digital
     CMCON0 = 7         ' turn off comparators 
    
    'Alias pins - MAX6675 temp sensor
     MXSCLK   var     PORTA.0   'pin 13 of 16f688 (Clock) to pin 5 of MAX6675
     MXCS     var     PORTA.1   'pin 12 of 16f688 (Chip Select) to pin 6 of MAX6675
     MXSO     Var     PORTA.2   'pin 11 of 16f688 (Serial) to pin 7 of MAX6675   
    
     'Allocate MAX6875 Variables
     MXTemp  var     word    'raw data from 6675/type K sensor
     TempC   var     word    'converted to degrees C 
     a VAR BIT ' a always equals zero, used in IF-THEN's instead of using GOTO's
     a = 0
    
     INCLUDE "modedefs.bas"     
    
    '5. Actual Program Start (usually a "Goto MainLoop" jump)
    '   =====================================================
     Pause 1000 ' Pause for LCD to initialize
    
        LCDOut $fe, 1, "Temp 6675 Laptop"
    PAUSE 2500
    
     IF a = 0 THEN MainLoop
    
    '------------------------------------------------------------------------------'
    MainLoop:
    
    '-----------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 data 5 places to get degrees C (in data sheet)
    LCDOut $fe, 1,"Temp = ", DEC TempC, " C  "  'Spit it out on an LCD 
    
    PAUSE 100                                   'reduce lcd flicker
    
    IF a = 0 THEN MainLoop ' a always equals zero, use instead of GOTO... 
    
    End
    Attached Images Attached Images  

  2. #2


    Did you find this post helpful? Yes | No

    Default Very timely thread! Can I also ask about the wiring?

    I'm trying to do a similar thing just now with the MAX6675 and the breakout board from Sparkfun (at least I think it's the MAX6675, I'm at work now). It's not clear to me if the wires from the female thermocouple socket to the MAX6675 breakout also need to be K type or is copper OK? At what point is it OK to switch to copper? Could the thermocouple lead be soldered right to the breakout board for prototyping?

    Thanks for your help. Sorry if I should be starting a new thread.

    DD.

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


    Did you find this post helpful? Yes | No

    Default

    Anyplace the wire material changes you need a reference temperature and calcs. A couple exceptions here and there though.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    May 2005
    Location
    Ne ohio
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    I'm writing some code for this device also. I'm wondering why the shift of 5 places to the right when in the data sheet it looks like only 3 shifts right should put the Temperatures lsb in the correct location.

    At least that's how my initial coding is. I'll try it tonight.
    I also use MSBPOST=2 :

    Get6675_Raw:
    LOW NCS:PAUSEUS 1
    Shiftin SO, SCK, MSBPOST, [raw1\16] ' Read 16 bit temperature register
    raw1 = raw1>>3
    HIGH NCS
    RETURN

    Brian

  5. #5
    Join Date
    May 2005
    Location
    Ne ohio
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    OK so I tried the code. Now I see you guys are right with the 5 bit shift.
    The device is capable of 12bits or 0.25 deg resolution if shifted only 3 times.

    Brian

Similar Threads

  1. Need a cheap touch sensor idea.. here it is
    By mister_e in forum Code Examples
    Replies: 20
    Last Post: - 16th April 2016, 22:42
  2. Ultrasonic distance sensor with PIC16F84A
    By MrRoboto in forum mel PIC BASIC
    Replies: 3
    Last Post: - 29th June 2009, 09:01
  3. PICBASIC PRO-coding for wireless sensor node
    By syazila in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th February 2009, 00:05
  4. Replies: 6
    Last Post: - 18th January 2008, 08:17
  5. RH/Temp Sensor Example Code
    By Bruce in forum Code Examples
    Replies: 7
    Last Post: - 15th June 2006, 15:55

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