NTC thermistor temperature sensing


Closed Thread
Results 1 to 37 of 37

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    One more thing ...

    The compiler doesn't like " ° " ( "Maj" + "=" ) character ...

    better use

    Code:
    Lcdout $FE,$C0,"ITS: ",DEC3 tb0,".",DEC2 tb1, 223, "C"
    where 223 ( sometimes 178 ) is supposed to be the ASCII code of " ° " ...

    That said ... ADC value NEVER is > 1023 ...

    from your firsts explanations ( post #1) ... I get That : ( 16F877A on EasyPic5 )

    Code:
     
    DEFINE ADC_BITS 10      ' Set number of bits in result
    DEFINE LCD_DREG PORTB       ' Set LCD Data port
    DEFINE LCD_DBIT 0           ' Set starting Data bit (0 or 4) if 4-bit bus .7
    DEFINE LCD_RSREG PORTB      ' Set LCD Register Select port
    DEFINE LCD_RSBIT 4          ' Set LCD Register Select bit 
    DEFINE LCD_EREG PORTB       ' Set LCD Enable port
    DEFINE LCD_EBIT 5           ' Set LCD Enable bit i.e, PORTE.4
    DEFINE LCD_BITS 4           ' Set LCD bus size ot 4 bit Upper Nibble (4 or 8 bits)
    DEFINE LCD_LINES 2         ' Set number of lines on LCD to 4 Lines
     
    TRISA  = %11111111
    TRISB  = 0
    TRISC  = 0
     
    CMCON  = 7
    ADCON0 = %11000001
    ADCON1 = %10000100   
     
    ntc VAR WORD
    tb0 VAR WORD
    tb1 VAR WORD
    tb2 VAR WORD
     
    PAUSE 700
    LCDOUT $fe,1
    lp:
    ADCIN 1,ntc
    tb0 = ntc * 33 /92 
    tb1 = tb0*721                                     
    tb2 = Div32 255
    tb2 = tb2 - 64
    tb0 = tb2/10   
    tb1 = tb2//10    
     
    PAUSE 200
     
    LCDOUT $FE,2,DEC4 ntc
    Lcdout $FE,$C0,"ITS: ",DEC3 tb0,".",DEC1 tb1,178,"C"
    goto lp
    Gives me a 0 - 100°C scale for adc = 67 to 1023 ...

    so, i suppose it to be " not so bad , but to confirm "
    Alain
    Last edited by Acetronics2; - 15th January 2011 at 20:08.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    One more thing ...

    The compiler doesn't like " ° " ( "Maj" + "=" ) character ...

    better use

    Code:
    Lcdout $FE,$C0,"ITS: ",DEC3 tb0,".",DEC2 tb1, 223, "C"
    where 223 ( sometimes 178 ) is supposed to be the ASCII code of " ° " ...

    That said ... ADC value NEVER is > 1023 ...

    from your firsts explanations ( post #1) ... I get That : ( 16F877A on EasyPic5 )

    Code:
     
    DEFINE ADC_BITS 10      ' Set number of bits in result
    DEFINE LCD_DREG PORTB       ' Set LCD Data port
    DEFINE LCD_DBIT 0           ' Set starting Data bit (0 or 4) if 4-bit bus .7
    DEFINE LCD_RSREG PORTB      ' Set LCD Register Select port
    DEFINE LCD_RSBIT 4          ' Set LCD Register Select bit 
    DEFINE LCD_EREG PORTB       ' Set LCD Enable port
    DEFINE LCD_EBIT 5           ' Set LCD Enable bit i.e, PORTE.4
    DEFINE LCD_BITS 4           ' Set LCD bus size ot 4 bit Upper Nibble (4 or 8 bits)
    DEFINE LCD_LINES 2         ' Set number of lines on LCD to 4 Lines
     
    TRISA  = %11111111
    TRISB  = 0
    TRISC  = 0
     
    CMCON  = 7
    ADCON0 = %11000001
    ADCON1 = %10000100   
     
    ntc VAR WORD
    tb0 VAR WORD
    tb1 VAR WORD
    tb2 VAR WORD
     
    PAUSE 700
    LCDOUT $fe,1
    lp:
    ADCIN 1,ntc
    tb0 = ntc * 33 /92 
    tb1 = tb0*721                                     
    tb2 = Div32 255
    tb2 = tb2 - 64
    tb0 = tb2/10   
    tb1 = tb2//10    
     
    PAUSE 200
     
    LCDOUT $FE,2,DEC4 ntc
    Lcdout $FE,$C0,"ITS: ",DEC3 tb0,".",DEC1 tb1,178,"C"
    goto lp
    Gives me a 0 - 100°C scale for adc = 67 to 1023 ...

    so, i suppose it to be " not so bad , but to confirm "
    Alain
    Ok, my problem is largely solved, and if change my PIC, I'll be warn of ADC values. I think my PIC is a special case.
    Thanks everyone.

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


    Did you find this post helpful? Yes | No

    Default

    Epilog ...

    for general knowledge ... a look at Microchip AN 942 may be valuable ...

    Ok, my problem is largely solved


    I think my PIC is a special case.


    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