Maybe Darrel or Bruce will come to the rescue.
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.
yeah I have read through that a few times, and it helped me in the first place with the sensor etc, also read the link above in my first post as Savnik was trying to do the same thing but with a 16F chip and a couple of guys helped him to sort it out, which is the base for mine, but obviously on that thread, they dont say how they are using it (ie VDD or a Vref pin)
I use two LM34s with a 16f876 and it's been rock solid with the following snippetts....
I know you're using a different micro but maybe this will help some.Code:DEFINE LOADER_USED 1 DEFINE OSC 4 DEFINE ADC_BITS 8 ' Set A/D for 8-bit operation DEFINE ADC_CLOCK 3 ' Set A/D clock DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS '((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))) 'Subroutine to get room temperature '((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))) roomdegrees: FOR sample = 1 TO 20 ' Take 20 samples ADCIN 2, roomtemp ' Read channel 2 into temp variable samples = samples + roomtemp ' Accumulate 20 samples NEXT sample roomtemp = samples/20 samples = 0 ' Clear old sample accumulator SerOut2 PORTC.6,SPbaud, [$00, $80, $29,roomtemp] 'update siteplayer with room temperature if r7sched = 0 then return 'manual control = 0, auto control = 1 if roomtemp >= roomspt + 1 then SerOut2 PORTC.6,SPbaud, [$00, $80, $3C,1] 'update siteplayer with exhaust status on checkrelays = 1 endif if roomtemp <= roomspt - 1 then SerOut2 PORTC.6,SPbaud, [$00, $80, $3C,0] 'update siteplayer with exhaust status off checkrelays = 1 endif return '((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))) 'Subroutine to get tank temperature '((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))) tankdegrees: FOR sample = 1 TO 20 ' Take 5 samples ADCIN 4, watertemp ' Read channel 4 into watertemp variable samples = samples + watertemp ' add 5 samples NEXT sample watertemp = samples/20 samples = 0 ' Clear old samples SerOut2 PORTC.6,SPbaud, [$00, $80, $28,watertemp] 'update siteplayer with water temperature if r8sched = 0 then return 'manual control = 0, auto control = 1 if watertemp > waterspt then serOut2 PORTC.6,SPbaud, [$00, $80, $3D,0] 'update siteplayer with heater status off checkrelays = 1 endif if watertemp <= waterspt - 1 then SerOut2 PORTC.6,SPbaud, [$00, $80, $3D,1] 'update siteplayer with heater status on checkrelays = 1 endif return
Thanks ronjodu,
Do you have it display with fractional degrees c? ie 25.4C or just straight values ie 25.
Also noticed that the pic chip your using and also the one on the link I have in my post both use 8 bit ADC_BITS, wheras the 18F's use 10, so not sure if that might have something to do with it also as it could be because im basing the reading/loop/convertion on an 8 bit value.
Just done a couple of tests.
Set the Vref back to AN3 and just simply did ADCIN 0,VAL and then print it out to the LCD with a DEC5 just to see if I was missing anything without any fiddling with the ADCIN result.
the reading is just constantly at 00255 (once in a blue moon it shows 511 then goes back to 255) on the LCD whether I hold the sensor or not, so somehing is seriously wrong with the way im setting it up, but I just cant for the life of me see what it is!
Same test with VDD as ref, I get values around 00046 - 00050 and when I hold the sensor, it rises.
Hope that may give some ideas as im all out now and I dont think tears and electronics mixlol!
Bookmarks