LM35DZ and 18F2455 settings


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Dec 2006
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    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.

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


    Did you find this post helpful? Yes | No

    Default

    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.

  3. #3
    Join Date
    Dec 2006
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    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)

  4. #4
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91


    Did you find this post helpful? Yes | No

    Default LM34 with 16F876 also for an Aquarium

    I use two LM34s with a 16f876 and it's been rock solid with the following snippetts....
    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
    I know you're using a different micro but maybe this will help some.

  5. #5
    Join Date
    Dec 2006
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    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.

  6. #6
    Join Date
    Dec 2006
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    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 mix lol!

  7. #7
    Join Date
    Dec 2006
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    Boy do I feel a bit dumb lol!

    Decided to have one more go this morning with the sensor and just displaying the result of all the samples added together with NO adjustments etc.

    on the LCD it was showing something like 462 and putting the meter on the Gnd pin and the Vout pin on the sensor the meter was reading 231, so it then dawned on me that I dont need to do all the division stuff by the number of samples etc just simply divide by 2 to get the result!!!!!! DOH! and that way, I get the reading with the fractional degree's also!

    Oh, and just using the VDD as the voltage reference.

    One happy bunny!

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