DS2760 Thermocouple Kit from Parallax in PicBasicPro


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2008
    Posts
    2

    Lightbulb DS2760 Thermocouple Kit from Parallax in PicBasicPro

    Hi everyone this is my first post to the forum. First off im trying to connect the Parallax DS2760 1 Wire Thermocouple Kit to a PIC mcu. I can get the PIC to communicate with the DS2760 using OWIN & OWOUT. I can read the Cold Junction temp sensor, and the Seebeck voltage. My problem is that in order to calculate the temperature at the thermocouple probe, a table containing cold junction compensation voltages needs to be used...I think the table is too big. Im using the DATA command to store it in the internal memory, but the BASICStamps memory is larger I think than most PICS. I receive an "Address exceeds maximum Range for this Processor". The main program has an INCLUDE file that hold the table information. This is what it looks like:
    Code:
    T000    DATA    Word 00000,Word 00039,Word 00078,Word 00117,Word 00156,Word 00195,Word 00234,Word 00273,Word 00312,Word 00352
    
    T010    DATA    Word 00391,Word 00431,Word 00470,Word 00510,Word 00549, Word 00589, Word 00629, Word 00669, Word 00709, Word 00749
    
    T020    DATA    Word 00790, Word 00830, Word 00870, Word 00911, Word 00951, Word 00992, Word 01032, Word 01074, Word 01114, Word 01155
    
    T030    DATA    Word 01196, Word 01238, Word 01279, Word 01320, Word 01362, Word 01403, Word 01445, Word 01486, Word 01528, Word 01570
    
    T040    DATA    Word 01612, Word 01654, Word 01696, Word 01738, Word 01780, Word 01822, Word 01865, Word 01908, Word 01950, Word 01993
    
    T050    DATA    Word 02036, Word 02079, Word 02121, Word 02165, Word 02208, Word 02250, Word 02294, Word 02338, Word 02381, Word 02425
    
    T060    DATA    Word 02468, Word 02512, Word 02556, Word 02600, Word 02643, Word 02687, Word 02732, Word 02776, Word 02819, Word 02863
    
    T070    DATA    Word 02909, Word 02952, Word 02998, Word 03043, Word 03087, Word 03132, Word 03177, Word 03222, Word 03266, Word 03312
    
    T080    DATA    Word 03358, Word 03403, Word 03447, Word 03494, Word 03539, Word 03584, Word 03631, Word 03677, Word 03722, Word 03768
                                                                               
    T090    DATA    Word 03814, Word 03859, Word 03907, Word 03953, Word 03999, Word 04046, Word 04092, Word 04137, Word 04185, Word 04232
    
    T100    DATA    Word 04278, Word 04325, Word 04371, Word 04419, Word 04466, Word 04512, Word 04561, Word 04608, Word 04655, Word 04701
    
    T110    DATA    Word 04750, Word 04798, Word 04844, Word 04892, Word 04940, Word 04988, Word 05036, Word 05084, Word 05131, Word 05179
    
    T120    DATA    Word 05227, Word 05277, Word 05325, Word 05373, Word 05421, Word 05469, Word 05519, Word 05567, Word 05616, Word 05665
    
    T130    DATA    Word 05714, Word 05762, Word 05812, Word 05860, Word 05910, Word 05959, Word 06008, Word 06057, Word 06107, Word 06155
    
    T140    DATA    Word 06206, Word 06254, Word 06304, Word 06355, Word 06403, Word 06453, Word 06504, Word 06554, Word 06604, Word 06653
    
    T150    DATA    Word 06703, Word 06754, Word 06804, Word 06855, Word 06905, Word 06956, Word 07006, Word 07057, Word 07107, Word 07158
                                                                                
    T160    DATA    Word 07209, Word 07259, Word 07310, Word 07360, Word 07411, Word 07463, Word 07515, Word 07565, Word 07617, Word 07668
    
    T170    DATA    Word 07719, Word 07770, Word 07823, Word 07874, Word 07926, Word 07977, Word 08028, Word 08080, Word 08133, Word 08185
    
    T180    DATA    Word 08237, Word 08288, Word 08340, Word 08393, Word 08445, Word 08496, Word 08550, Word 08602, Word 08653, Word 08707
                                                                                
    T190    DATA    Word 08759, Word 08811, Word 08865, Word 08916, Word 08970, Word 09022, Word 09076, Word 09128, Word 09182, Word 09234
    
    T200    DATA    Word 09288, Word 09341, Word 09394, Word 09448, Word 09500, Word 09554, Word 09608, Word 09662, Word 09714, Word 09769
    
    T210    DATA    Word 09822, Word 09875, Word 09929, Word 09984, Word 10038, Word 10092, Word 10146, Word 10200, Word 10253, Word 10307
    
    T220    DATA    Word 10362, Word 10416, Word 10471, Word 10525, Word 10580, Word 10634, Word 10689, Word 10743, Word 10798, Word 10852
    
    T230    DATA    Word 10907, Word 10961, Word 11016, Word 11072, Word 11127, Word 11182, Word 11237, Word 11291, Word 11346, Word 11403
    
    T240    DATA    Word 11458, Word 11512, Word 11569, Word 11624, Word 11679, Word 11734, Word 11791, Word 11846, Word 11902, Word 11958
    
    T250    DATA    Word 12012, Word 12069, Word 12125, Word 12181, Word 12237, Word 12293, Word 12349, Word 12405, Word 12461, Word 12518
    
    T260    DATA    Word 12573, Word 12630, Word 12686, Word 12743, Word 12798, Word 12855, Word 12912, Word 12968, Word 13025, Word 13082
    
    T270    DATA    Word 13139, Word 13195, Word 13253, Word 13310, Word 13365, Word 13423, Word 13480, Word 13537, Word 13595, Word 13652
    
    T280    DATA    Word 13708, Word 13766, Word 13823, Word 13881, Word 13938, Word 13995, Word 14053, Word 14109, Word 14168, Word 14226
    
    T290    DATA    Word 14282, Word 14341, Word 14399, Word 14455, Word 14514, Word 14572, Word 14630, Word 14688, Word 14746, Word 14804
    
    T300    DATA    Word 14862, Word 14919, Word 14977, Word 15035, Word 15095, Word 15153, Word 15211, Word 15269, Word 15328, Word 15386
    
    T310    DATA    Word 15445, Word 15503, Word 15562, Word 15621, Word 15679, Word 15737, Word 15797, Word 15855, Word 15913, Word 15973
    
    T320    DATA    Word 16032, Word 16091, Word 16149, Word 16208, Word 16268, Word 16327, Word 16387, Word 16446, Word 16504, Word 16564
    
    T330    DATA    Word 16623, Word 16682, Word 16742, Word 16801, Word 16861, Word 16920, Word 16980, Word 17039, Word 17100, Word 17158
    
    T340    DATA    Word 17219, Word 17278, Word 17338, Word 17399, Word 17458, Word 17518, Word 17577, Word 17638, Word 17698, Word 17759
    
    T350    DATA    Word 17818, Word 17879, Word 17939, Word 17998, Word 18059, Word 18120, Word 18179, Word 18240, Word 18301, Word 18362
    
    T360    DATA    Word 18422, Word 18483, Word 18542, Word 18603, Word 18664, Word 18725, Word 18786, Word 18847, Word 18908, Word 18969
    
    T370    DATA    Word 19030, Word 19091, Word 19152, Word 19213, Word 19274, Word 19335, Word 19396, Word 19457, Word 19518, Word 19579
    
    T380    DATA    Word 19641, Word 19702, Word 19763, Word 19824, Word 19885, Word 19946, Word 20009, Word 20070, Word 20132, Word 20193
    
    T390    DATA    Word 20255, Word 20317, Word 20378, Word 20440, Word 20501, Word 20563, Word 20625, Word 20687, Word 20748, Word 20810
    
    T400    DATA    Word 20872
    If the PIC internal memory is too small what solutions might be available...I think if I could preprogram an external EEPROM with the table that might work...I cant seem to figure out how to load that into a 1wire flash eeprom. Any help would be greatly appreciated. I also attached the sample code from the Paralax site (That is where i got the table). There is three tables included but I am only using the one for a type "T" thermocouple. Thanks again.
    Sean
    [email protected]
    Attached Files Attached Files
    Last edited by seanharmon; - 7th July 2008 at 20:15. Reason: add files

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    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 " !!!
    *****************************************

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

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