NTC thermistor temperature sensing


Results 1 to 37 of 37

Threaded View

  1. #4


    Did you find this post helpful? Yes | No

    Default

    Well, sorry for these newbie questions...

    The precision for my thermoter is not critical, is just a temperature sensor for security purposes. But I want to keep the code for current and voltage sensing purposes (linear curves), so in these cases I need more precision...

    I've read many exemples given... I've modified my code in consequence, I can read the integer part (like 23.00 °C), but not the float part...

    Here's my code :
    Code:
    define OSC 20
    DEFINE ADC_BITS 8      ' Set number of bits in result
    DEFINE ADC_CLOCK 3     ' Set clock source (rc = 3)
    DEFINE ADC_SAMPLEUS 10 ' Set sampling time in microseconds 
    DEFINE LCD_DREG PORTC 'LCD data port
    DEFINE LCD_RSREG PORTC 'LCD data port
    DEFINE LCD_EREG PORTC
    DEFINE LCD_EBIT 5 
    DEFINE LCD_BITS 4 'LCD bus size 4 or 8 
    DEFINE LCD_LINES 2 'Number lines on LCD 
    DEFINE LCD_COMMANDUS 10000'Command delay time in us 
    DEFINE LCD_DATAUS 1000 'Data delay time in us 
    
    AD_AN1_VALUE VAR WORD
    B0 VAR WORD
    B1 VAR WORD
    B2 VAR WORD
    B3 VAR WORD
    
    TRISA = %11111111     
    
    ADCON1 = %10000010   
    
    PAUSE 4000
    
    lp:
    
    ADCIN 1, AD_AN1_VALUE
    
    B0 = AD_AN1_VALUE*129   
    B1 = B0-8143                                      
    B2 = B1/319
    PAUSE 100
                          
    LCDOUT $fe,1
    LCDOUT #AD_AN1_VALUE
    Lcdout $fe,$c0,"Temp.: ",DEC (B2 DIG 0),DEC (B2 DIG 1),".",DEC (B2 DIG 2),DEC (B2 DIG 3),"°C"
    
    goto lp
    I like to have XX.Y °C (23.2 °C for example).
    I know that is a very common problem, but I've spend many hours to try solve this, so...

    Example of my calculation :
    AD_AN1_VALUE=137
    B0=137*129=17673
    B1=17673-8143=9530
    B2=9530/319=29,874 °C

    But here I only get 29,00 °C...
    Last edited by pxidr84; - 14th January 2011 at 18:56.

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