LM35DZ + Temp


Closed Thread
Results 1 to 14 of 14

Thread: LM35DZ + Temp

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Default LM35DZ + Temp

    I have the code below to show the temperature on LCD
    The code works but i want to show on Lcd and the decimal value,
    but i cann't
    Like this : Temp=25.6C
    Code:
    ' **Setting for ADC of 16F88**
    
        Define ADC_BITS 10          ' 10-bit ADC used
        Define ADC_CLOCK 3          ' Internal clock used
        Define ADC_SAMPLEUS 50      ' Sample timing
    
        Samples var word            ' Samples
        Sample var byte             ' Sample
        Vin var Word                ' Vin is variable
    
        Samples=0
    
    ADCloop:
    
        For Sample=1 to 10          ' Take 10 samples
        ADCIN 2, Vin                ' Read ADC ch-2 and save in Vin
                                    ' (range 0-1023)
        Samples=Samples + Vin
        Pause 200                   ' Wait for LCD to startup
                                    ' Seems to be appropriate.
        Next sample
        
        Vin=Samples/10              ' Mean of 10 Vin values
        Vin=(Vin*/500)>>2
    
        Lcdout $fe, 1               ' Clear LCD
        LCDOUT $FE,2              
        Lcdout "Temp=",Dec2 Vin,"C" 
    
        Samples=0
    
        goto ADCLoop
    Last edited by savnik; - 3rd March 2007 at 19:02.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    ' **Setting for ADC of 16F88**
    Define ADC_BITS 10 ' 10-bit ADC used
    Define ADC_CLOCK 3 ' Internal clock used
    Define ADC_SAMPLEUS 50 ' Sample timing
    Samples var word:Sample var byte:Vin var Word:Samples=0
    ADCloop:
    For Sample=1 to 10:ADCIN 2,Vin:Samples=Samples + Vin:Pause 200 Next sample
    Vin=Samples/10:Vin=(Vin*/500)>>2:Lcdout $fe, 1:LCDOUT $FE,2
    Lcdout "Temp=",DEC (Vin DIG 2),DEC (Vin DIG 1),".",DEC (Vin dig 0),"C"
    Samples=0:goto ADCLoop

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    ' **Setting for ADC of 16F88**
    Define ADC_BITS 10 ' 10-bit ADC used
    Define ADC_CLOCK 3 ' Internal clock used
    Define ADC_SAMPLEUS 50 ' Sample timing
    Samples var word:Sample var byte:Vin var Word:Samples=0
    ADCloop:
    For Sample=1 to 10:ADCIN 2,Vin:Samples=Samples + Vin:Pause 200 Next sample
    Vin=Samples/10:Vin=(Vin*/500)>>2:Lcdout $fe, 1:LCDOUT $FE,2
    Lcdout "Temp=",DEC (Vin DIG 2),DEC (Vin DIG 1),".",DEC (Vin dig 0),"C"
    Samples=0:goto ADCLoop
    It's not show corect.
    I try the code below and work but the decimal change every 0.5C
    How change to have resolution every 0.1C
    Code:
    	Quanta		Con	1250  
    
        ADCIN 2,AD_Result			' Place the conversion of channel0 into AD_RESULT    
    	Volts = (AD_RESULT*10) */ Quanta
    	Lcdout $FE,1
        Lcdout "Temp : ",dec1 Volts DIG 3,DEC1 Volts DIG 2,".",DEC1 Volts DIG 1,DEC1 Volts DIG 0,"C"
                                    ' So as to display like "23.4C"

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    It's not show corect.
    I try the code below and work but the decimal change every 0.5C
    How change to have resolution every 0.1C
    Ok, forget all the math and displaying for the moment...

    What is the output on the LCD if you only read the A/D converter with the LM35DZ connected... no averaging, no multiple samples, no nothing, just one saple, one display...pause, one sample, one display, and so on...
    Get a good reading that seems to make sense, then we can work on displaying it correctly...

  5. #5
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Ok, forget all the math and displaying for the moment...

    What is the output on the LCD if you only read the A/D converter with the LM35DZ connected... no averaging, no multiple samples, no nothing, just one saple, one display...pause, one sample, one display, and so on...
    Get a good reading that seems to make sense, then we can work on displaying it correctly...
    The output on the LCD is 44-46 (Vin = 44~46)
    The temperature is about 22C in room

  6. #6
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    I change to :
    Code:
    ADCloop:
    
        ADCIN 2,Vin
        Pause 200 
        Vin=(Vin* 10)/2
        Lcdout $fe, 1
        LCDOUT $FE,2
        Lcdout "Temp=",DEC (Vin DIG 2),DEC (Vin DIG 1),".",DEC (Vin dig 0),"C"			          
        goto ADCLoop
    and believe is right
    The LCD now show : Temp=22.5C

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The LM35 puts out 10mv/°C.
    1 "Step" of 10-bit A/D is 4.88mv.
    So each "step" equals ~0.5°C

    If you use a Vref of 2.5V, you could get 0.25°C resolution.

    With an op-amp you might get down to 0.1°C res. if you don't need the full +150°C range.

    Or you could use a DS18B20. That'll get 0.0625°C.
    <br>
    DT

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    The LM35 puts out 10mv/°C.
    1 "Step" of 10-bit A/D is 4.88mv.
    So each "step" equals ~0.5°C

    If you use a Vref of 2.5V, you could get 0.25°C resolution.

    With an op-amp you might get down to 0.1°C res. if you don't need the full +150°C range.

    Or you could use a DS18B20. That'll get 0.0625°C.
    <br>
    Good call DT! I thought the datasheet said 1mv/C.

  9. #9
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    The LM35 puts out 10mv/°C.
    1 "Step" of 10-bit A/D is 4.88mv.
    So each "step" equals ~0.5°C

    If you use a Vref of 2.5V, you could get 0.25°C resolution.

    With an op-amp you might get down to 0.1°C res. if you don't need the full +150°C range.

    Or you could use a DS18B20. That'll get 0.0625°C.
    <br>
    Thank you for answer
    I have use this schematic
    Attached Images Attached Images  
    Last edited by savnik; - 4th March 2007 at 19:52.

  10. #10
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    The LM35 puts out 10mv/°C.
    1 "Step" of 10-bit A/D is 4.88mv.
    So each "step" equals ~0.5°C

    If you use a Vref of 2.5V, you could get 0.25°C resolution.

    With an op-amp you might get down to 0.1°C res. if you don't need the full +150°C range.

    Or you could use a DS18B20. That'll get 0.0625°C.
    <br>
    I want to measure from 0 - 100C

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    I want to measure from 0 - 100C
    So what's the problem? The answer has already been given to you twice in the posts above, even if other parts of the code were wrong, if you'd take a few seconds to look over the display part of the above code, you'd find your answer, between that and the PBP manual, which does describe what you need...

  12. #12
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    I want to measure from 0 - 100C
    I answer , don't ask

  13. #13
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    what happened in your first example?

    If you used DEC3, what was the results...apart that the decimal point was missing?

    Now, i have set ADCON1 register to produce Right Justified results (ADCON1.7=1) and used this
    Code:
    ADCloop:
        For Sample=1 to 10          ' Take 10 samples
            ADCIN 0, Vin                ' Read ADC ch-2 and save in Vin
                                        ' (range 0-1023)
            Samples=Samples + Vin
            Next sample
        
        Vin=Samples/10              ' Mean of 10 Vin values
        Vin=(Vin*/500)>>2
    
        Lcdout $fe, 1               ' Clear LCD
        LCDOUT $FE,2              
        Lcdout "Temp=",DEC Vin DIG 2, DEC Vin DIG 1,".", DEC1 VIN,"C" 
    
        Samples=0
        PAUSE 100
        goto ADCLoop
    it worked.

    EDIT: ARGH!
    Last edited by mister_e; - 4th March 2007 at 19:43.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  14. #14
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    what happened in your first example?

    If you used DEC3, what was the results...apart that the decimal point was missing?

    Now, i have set ADCON1 register to produce Right Justified results (ADCON1.7=1) and used this
    Code:
    ADCloop:
        For Sample=1 to 10          ' Take 10 samples
            ADCIN 0, Vin                ' Read ADC ch-2 and save in Vin
                                        ' (range 0-1023)
            Samples=Samples + Vin
            Next sample
        
        Vin=Samples/10              ' Mean of 10 Vin values
        Vin=(Vin*/500)>>2
    
        Lcdout $fe, 1               ' Clear LCD
        LCDOUT $FE,2              
        Lcdout "Temp=",DEC Vin DIG 2, DEC Vin DIG 1,".", DEC1 VIN,"C" 
    
        Samples=0
        PAUSE 100
        goto ADCLoop
    it worked.

    EDIT: ARGH!
    The LCD show Temp=02.5C
    but the right is Temp=25C

Similar Threads

  1. Graphic LCD with PICbasic pro
    By amindzo in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th November 2012, 11:45
  2. Stuck with 85C temp on ds18b20
    By revelator in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 3rd April 2009, 19:50
  3. Random Numbers
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 18th December 2008, 08:47
  4. help with write command
    By cphillips82 in forum General
    Replies: 9
    Last Post: - 20th April 2008, 23:49
  5. LM35DZ and 18F2455 settings
    By Mark J in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 25th January 2008, 08:31

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