NTC thermistor temperature sensing


Closed Thread
Results 1 to 37 of 37

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi,

    I'm somewhat affraid ...


    0 < Tb0 < 1024 ... ok ?

    1024 - 16170 = ??? - 15146 !!!
    so, tb1 is NEGATIVE ...

    and PBP do not deal with negative numbers .... but " read " it as 65536 -15146 = ???

    a hole in the somewhere ???

    Alain
    Well, the ADC range is not 0-1024, but 0-65535...
    (verified with a display of the raw ADC value).

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by pxidr84 View Post
    Well, the ADC range is not 0-1024, but 0-65535...
    (verified with a display of the raw ADC value).
    Alain never said the ADC range was 0 - 65535.
    He was telling you how the value would be acted on.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,651


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by pxidr84 View Post
    Well, the ADC range is not 0-1024, but 0-65535...
    (verified with a display of the raw ADC value).
    You should place a patent on this one ...

    Hurry up !!!

    Alain

    PS you do not display Tb0 ( as the ADC result ) , but Tb0 ( after - false - calculations done ! ) ....
    Last edited by Acetronics2; - 15th January 2011 at 15:01.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    You should place a patent on this one ...
    In case you are wondering why, the ADC is 10 bit, so clearly you can't have 16 bit result from the ADC
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  5. #5


    Did you find this post helpful? Yes | No

    Default



    It's weird. I got a 16-bit result. Why? Code :

    Code:
    define OSC 20
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3  
    DEFINE ADC_SAMPLEUS 10
    DEFINE LCD_DREG PORTC
    DEFINE LCD_RSREG PORTC
    DEFINE LCD_EREG PORTC
    DEFINE LCD_EBIT 5 
    DEFINE LCD_COMMANDUS 10000'Command delay time in us 
    DEFINE LCD_DATAUS 1000 'Data delay time in us
     
    ntc VAR WORD
    
    TRISA=%11111111     
    ADCON1=%10000010   
    
    PAUSE 4000
    
    lp:
    
    ADCIN 1,ntc
     
    PAUSE 100
     
    Lcdout $fe,$c0,#ntc
    
    goto lp
    you do not display Tb0 ( as the ADC result ) , but Tb0
    And what are the differences between Tb0 and Tb0? I didn't understand your answer.
    Last edited by pxidr84; - 15th January 2011 at 15:36.

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


    Did you find this post helpful? Yes | No

    Default

    Never trust a sim.
    Try it in real life and come back.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,651


    Did you find this post helpful? Yes | No

    Default

    ADCIN 1,tb0
    tb1=tb0-16170
    tb1=tb1*tb3
    tb2=Div32 634
    tb0=tb2/100
    tb1=tb2//100
    see any difference between Tb0 value @ line 1 and Tb0 Value @ line 5 ???

    really no ?

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Never trust a sim.
    Try it in real life and come back.
    In real life with the same code:


    Quote Originally Posted by Acetronics View Post
    see any difference between Tb0 value @ line 1 and Tb0 Value @ line 5 ???

    really no ?

    Alain
    My updated code :

    Code:
    define OSC 20
    DEFINE ADC_BITS 10
    DEFINE ADC_SAMPLEUS 10
    DEFINE LCD_DREG PORTC
    DEFINE LCD_RSREG PORTC
    DEFINE LCD_EREG PORTC
    DEFINE LCD_EBIT 5 
    
    ntc VAR WORD
    tb0 VAR WORD
    tb1 VAR WORD
    tb2 VAR WORD
    
    TRISA=%11111111     
    ADCON1=%10000010   
    
    PAUSE 4000
    
    lp:
    
    ADCIN 1,ntc
    tb0=ntc
    if tb0>=16170 then
    tb1=tb0-16170 
    ELSE 
    tb0=0
    ENDIF
    tb1=tb1*100                                      
    tb2=Div32 634
    tb0=tb2/100   
    tb1=tb2//100    
               
    PAUSE 100
    
    Lcdout $fe,$c0,"ITS: ",DEC (tb0 DIG 1),DEC (tb0 DIG 0),".",DEC (tb1 DIG 1),"°C"
    
    goto lp
    I was surprised because the previous code worked good.

  9. #9
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Never trust a sim.
    But this time I think the sim is correct. I think you ment to set ADCON2, not ADCON1. ADCON 2 sets right or left justified. Default is left justified.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  10. #10


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cncmachineguy View Post
    But this time I think the sim is correct. I think you ment to set ADCON2, not ADCON1. ADCON 2 sets right or left justified. Default is left justified.
    How do you right-justify bits?
    tb0=ntc>>8?

    Or there is an another command?

  11. #11
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Code:
    From your code:
    
    ADCIN 1,ntc
    tb0=ntc
    if tb0>=16170 then
    tb1=tb0-16170 
    ELSE 
    tb0=0
    ENDIF
    Since ntc could be 0 or 1023 maximum, the condition if tb0>=16170 then is always false so tbo will be always zero and tb1 will be never setted with your required calculation tb1=tb0-16170.

    Cheers

    Al.
    Last edited by aratti; - 15th January 2011 at 17:19.
    All progress began with an idea

  12. #12
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,651


    Did you find this post helpful? Yes | No

    Default

    Sorry ...

    But my Easy Pic5 outputs " ITS : ...00.00°C " with all the processor settings I gave you in previous code, but 10 bits ADC ... ( Whistle and Bells ... )

    I also asked for printing ntc Value ...

    comprised between 0 and 1023 ...

    try this :


    ntc VAR WORD
    tb0 VAR WORD
    tb1 VAR WORD
    tb2 VAR WORD
    TRISA=%11111111

    PAUSE 700
    LCDOUT $fe,1

    lp:
    ADCIN 1,ntc
    tb0 = ntc
    if tb0 >= 16170 then
    tb1 = tb0-16170
    ELSE
    tb1 = 0
    ENDIF
    tb1 = tb1*100
    tb2 = Div32 634
    tb0 = tb2/100
    tb1 = tb2//100

    LCDOUT $FE,2,DEC4 ntc
    Lcdout $FE,$C0,"ITS: ",DEC3 tb0,".",DEC2 tb1,"°C"
    goto lp
    so ... take your own conclusions !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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