DS2760 Thermocouple Kit from Parallax in PicBasicPro


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    Why not use the Microchip recommended method ???

    use much less than those 400 Words for the table ( What an horror ! ) and make a linear interpolation between two consecutive table values.

    As the seebeck coeff is quite constant over wide temp ranges ... it seems obvious !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    I do not know if this will help, but you are welcome to it.

    It uses to tables in code space.

    This uses a LM34 for the cold junction and a "K" type thermo-couple.
    10 degree F resolution from 510 to 2500. The TC is ran through an op amp.
    Even does a little data logging.

    Code:
    '*  Date    : 09/01/2007                                                                                                                                 
    '*  Pic   :  18F4320   
    
       DEFINE OSC 20
    
    DEFINE LCD_DREG     PORTC
    define LCD_DBIT     0
    DEFINE LCD_RSREG    PORTD
    DEFINE LCD_RSBIT    1
    DEFINE LCD_EREG     PORTD
    DEFINE LCD_EBIT     0
    DEFINE LCD_BITS     4
    DEFINE LCD_LINES    2
    DEFINE LCD_COMMANDUS    2000
    DEFINE LCD_DATAUS   50
    
    ADCON1= %00011011  '13 'AN0 and AN1      
    CMCON = 7
    TRISC = %10111111
    
    temp1        var byte
    temp2        var byte
    T1			 var byte
    T2           var byte
    
    TC	VAR	WORD
    TCT	VAR	WORD
    TX	VAR WORD
    TXI	VAR WORD
    TXIU	VAR WORD
    TXIU = 500
    T_T	 VAR WORD
    A_T VAR WORD
    
    DL	VAR	WORD
    BCNT	VAR	WORD
    CNT	VAR	WORD
    BL		VAR	WORD
    CNT = 0
    BL = 0
    D_C		VAR	WORD
    
    INTCON2.7 = 0
    T0CON = %11010111
    INTCON = %10100000 'Enable INTE interrupt
    On interrupt goto myint 
    
    START:
        pause 1000
        LCDOUT $FE,1,"MACKRACKIT CONTROLS" 
        lcdout $FE,$C0,"PYROMETER V2"
         pause 5000
    
    INTCON.2=0
    
    RUN:
    gosub getT1
    GOSUB getT2
    
    T1 = temp1 
    A_T = T1 - 30
    T_T = A_T + TXIU
    LCDOUT $FE,1,"LM34 ",#T1," A_T ",#A_T
    
    lcdout $FE,$C0,"TC ",#TXIU," T_T ",#T_T
    GOSUB D_INDEX
    IF TXIU < 1760 THEN M_H
    IF PORTD.3 =1 THEN E_D
    	GOTO RUN
    
    M_H:
    LCDOUT $FE,1,"MORE HEAT "
    PAUSE 50
    GOTO RUN
    
    getT1:
    	ADCON0= %00000001  '$1  '%00000001 AN0
    ADCON2.7 = 0
    	gosub getAD
    	temp1 = ADRESH
    	return
    	
    getT2:
    	ADCON0= %00000101   '$5  '%00000101 AN1
    ADCON2.7 = 1
    	gosub getAD
    	TC.highbyte = ADRESH
    	TC.lowbyte = ADRESL
    	return
    
    getAD:
    	pause 50
    	ADCON0.1 = 1
    	pause 50
    	return
    
    	END
    
    
    D_INDEX:
    TX = TC 
    'THERMO STEPS
    LOOKDOWN2 TX,>[898,895,892,889,886,883,879,876,873,870,867,863,860,857,854,850,_
    847,844,841,838,835,832,828,825,822,819,815,812,809,805,802,799,795,792,788,785,_
    782,778,775,772,769,765,762,758,755,751,748,744,741,737,734,731,727,724,721,717,_
    713,710,706,703,699,696,692,689,685,682,678,675,671,667,664,660,656,653,650,646,_
    643,639,635,632,628,624,620,617,614,610,606,603,599,595,592,588,584,580,577,573,_
    570,566,562,558,555,551,547,544,540,536,532,529,525,521,517,513,509,506,502,498,_
    495,491,487,483,479,475,471,468,464,460,456,453,449,445,441,437,433,429,426,422,_
    418,414,410,406,402,398,395,391,387,383,379,375,371,367,363,360,356,352,348,344,_
    340,336,332,328,324,321,317,313,309,305,301,297,293,290,286,282,278,274,270,267,_
    263,259,255,252,248,244,240,236,232,229,224,221,217,213,209,206,202,198,194,190,_
    187,183,180,176,173],TXI
    
    
    
    'THERMO TEMPERATURES
    LOOKUP2 TXI,[2500,2490,2480,2470,2460,2450,2440,2430,2420,2410,2400,2390,2380,2370,_
    2360,2350,2340,2330,2320,2310,2300,2290,2280,2270,2260,2250,2240,2230,2220,2210,2200,_
    2190,2180,2170,2160,2150,2140,2130,2120,2110,2100,2090,2080,2070,2060,2050,2040,2030,_
    2020,2010,2000,1990,1980,1970,1960,1950,1940,1930,1920,1910,1900,1890,1880,1870,1860,_
    1850,1840,1830,1820,1810,1800,1790,1780,1770,1760,1750,1740,1730,1720,1710,1700,1690,_
    1680,1670,1660,1650,1640,1630,1620,1610,1600,1590,1580,1570,1560,1550,1540,1530,1520,_
    1510,1500,1490,1480,1470,1460,1450,1440,1430,1420,1410,1400,1390,1380,1370,1360,1350,_
    1340,1330,1320,1310,1300,1290,1280,1270,1260,1250,1240,1230,1220,1210,1200,1190,1180,_
    1170,1160,1150,1140,1130,1120,1110,1100,1090,1080,1070,1060,1050,1040,1030,1020,1010,_
    1000,990,980,970,960,950,940,930,920,910,900,890,880,870,860,850,840,830,820,810,800,_
    790,780,770,760,750,740,730,720,710,700,690,680,670,660,650,640,630,620,610,600,590,_
    580,570,560,550,540,530,520,510,_
    500],TXIU
    
    RETURN
    
    '*****Interrupt Handler *****
    Disable 'No interrupts pass this point
    myint:
    	CNT = CNT + 1
    SEROUT2 PORTE.2,16468,[DEC CNT,13,10]
    	IF CNT => 1045 THEN   '1830 = 1m 45 s - 10457 = 10 m- 1045 = 1 m
    	HIGH PORTD.2
    	PAUSE 100
    	LOW PORTD.2
    	PAUSE 100
    	CNT = 0
    SEROUT2 PORTE.2,16468,[DEC 11,13,10]
    GOSUB	W_D
    		ENDIF
    
    'PIR1.0=0
    INTCON.2 = 0 'clear interrupt flag
    resume 'return to main program
    
    enable
    
    
    W_D:
    INTCON = %10000000 'DIS-Enable INTE interrupt
    FOR BCNT = 1 TO 10
    	HIGH PORTD.2
    	PAUSE 100
    	LOW PORTD.2
    	PAUSE 100
    NEXT
    BCNT = 0
    READ 200, DL.BYTE0
    READ 201, DL.BYTE1
    'DL = DL + 2
    WRITE 200, DL.BYTE0
    WRITE 201, DL.BYTE1
    WRITE DL, TXIU.BYTE0
    WRITE DL+1, TXIU.BYTE1
    INTCON = %10100000 'Enable INTE interrupt
    RETURN
    
    
    E_D:
    INTCON = %10000000 'DIS-Enable INTE interrupt
    	FOR BL = 1 TO 100
    READ 0, D_C.BYTE0
    READ 1, D_C.BYTE1
    	HIGH PORTD.2
    	PAUSE 100
    	LOW PORTD.2
    	PAUSE 100
    
    LCDOUT $FE,1,"TXIU  ",#D_C
    
    SEROUT2 PORTE.2,16468,["MACKRACKIT ",DEC D_C,"  ",DEC DL,13,10]
    NEXT
    INTCON = %10100000 'Enable INTE interrupt
    GOTO RUN
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2008
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Linear Approximation

    Im an idiot. I overlooked the Microchip application note that Alain mentioned.

    I found a larger table for thermocouple type K.(I originally used the type T table because it was smaller) http://srdata.nist.gov/its90/download/type_k.tab
    A large portion of the table can be removed because eventually I plan to measure temps in the range of 30Fto700F. With the decimal place shifted it should work in PBP?

    Its been years since Ive taken calculus, and was wondering what would be the easiest route to take in making the table smaller and then using linear approximation to figure the in between values. I understand that it uses floating point math which PBP doesnt do normally.

    Any help would be greatly appreciated.

    Once again thanks Alain and Dave. (im getting there...slowly)
    Last edited by seanharmon; - 8th July 2008 at 23:28.

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