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

    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)

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

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

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

  5. #5
    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!

  6. #6
    Join Date
    Dec 2006
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    Well, I thought I had it working, but ive just had chance to work on the project again and found that when submersed in the aquarium (waterproofed obviously!) the thermomitor temp (tube type) shows a steady 25 C, yet the sensor on my project is all over the place (even have it in a bag in case of water seepage etc) it varies from between 22 to 28 degrees! and in a large body of water, there is no way the water temp can fluctuate so wildly (roughly 150 UK gallons)

    So I am at a loss, as the code is based on other peoples posts and I thought it was working fine, but testing both sensors I still get the swings (Arghh!)

    I am seriously getting annoyed with these sensors but with both swinging so much, it leads me to think its something in either my code, or getting some errenous readins through the breadboard etc.

    Does anyone know if breadboards will cause these variations? as I have read somewhere that breadboards arnt exactly the greatest things etc.

    Any ideas would greatly be appreciated!

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


    Did you find this post helpful? Yes | No

    Default

    Where the leads from the probe connect to the bread board. Place a 22uf , or something close, capacitor between the signal return and ground. This should settle things down. Long wires going to the probe will cause fluctuations like this.
    Dave
    Always wear safety glasses while programming.

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