I have not used the 18F2455 but when using a 18F4320 with a LM34 I have to put a 22uf cap from VREF to ground and a 22uf cap from the sensor output to ground to get things working accurately.
I have not used the 18F2455 but when using a 18F4320 with a LM34 I have to put a 22uf cap from VREF to ground and a 22uf cap from the sensor output to ground to get things working accurately.
Dave
Always wear safety glasses while programming.
I'll give that a try when I get a chance and see how it goes.
At the mo, the only reason I used this chip is because I have a couple laying around here, and also I thought that in the future when I see about adding other things to the project etc, I can then use the USB functionality of the PIc to communicate to the PC for things like datalogging etc (not for a long while yet though lol! as just getting my head around the ADCON settings is hurting my brain lol!)
Hopefully, if it is the ADCON's and we get it working right etc, at least this will hopefully help others out using these PIC's as there dosnt seem to be a lot of info from the searches ive done so far as with the 18's been a strange beast compared to the normal PIC's people use etc, so I presume it kind of keeps peopple away from trying to use them more etc.
I am starting to like the 18F4320, made my head hurt at first.
I am working on a pyrometer with a K type thermo-couple and a LM34 for a reference. Have not looked at the data sheet for the PIC you are using, may or may not be close to the 4320. If it is, here is the pyrometer code so far, might give you some ideas.
As you can see I do not use ADCIN. I am a control freakCode:DEFINE OSC 8 OSCCON=%01111000 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 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 RUN: HIGH PORTD.2 PAUSE 100 LOW PORTD.2 PAUSE 100 gosub getT1 GOSUB getT2 T1 = temp1 LCDOUT $FE,1,"LM34 ",#T1 lcdout $FE,$C0,"TC ",#TXIU GOSUB D_INDEX GOTO RUN getT1: ADCON0= %00000001 ADCON2.7 = 0 gosub getAD temp1 = ADRESH return getT2: ADCON0= %00000101 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 '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 '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![]()
Dave
Always wear safety glasses while programming.
No luck,
Tried adding the caps and no difference, and also tried your way of getting the AD values but still off, so i'm at a loss at the mo!
will try another sensor JUST on the offchance that its that thats gone awry etc.
Maybe Darrel or Bruce will come to the rescue.
Dave
Always wear safety glasses while programming.
Hope so, as im quite attached to my hair lol!!
Runs fine when using the VDD as the Vref source, just cant seem to get the fractional digit at all.
Been running it using the VDD for about 5 mins, and it sits at around 22C which at a guess is our room temp lol, and when I hold the sensor inbetween my fingers the temp rises nicely, and when put down again it drops and settles again at 22.
It is just when I try to use the Vref+ (AN3) it goes toes up (not the usual saying, but kiddy friendly)
For a generic temp reader, it would be fine as it is, but for a marine aquarium, I want to be able to get finer readings so that I can use the fans to reduce the temp if the water level rises say 0.5C as stability is the key in marine keeping etc.
Not sure if you can get the 0.5 with this. If you do you will have to do a floating point routine or some other trick. +- 1 degree for these LM34s is the rating(I think).
Have you seen this?
http://www.rentron.com/PicBasic/LM34.htm
Dave
Always wear safety glasses while programming.
Bookmarks