Temperature Indicator Usage


+ Reply to Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103

    Default Temperature Indicator Usage

    Hello ;

    I'm trying to use the built in temperature sense function of PIC16F1827 but so far I haven't had any luck with that .. All I have tried to do is reading the RAW ADC value of the silicon die operating temperature value but I don't get anything meaningful ...

    I have a potentiometer connected to RB1 (analog channel 11) and the other adc reading is performed on analog channel 29 which is supposed to give me the result of the raw temperature reading of the silicon die .. When I rotate the potentiometer I see what I must see which is the actual expected raw adc reading result coming from the ADC channel 11 but the temperature reading I'm trying to get changes too while I rotate the pot and works dependent to the ADC value that I get from my potentiometer ...

    I was so exciting with the idea of reading the chip temperature without any external component but It's been a total frustration ...

    Code:
    '****************************************************************
    '*  Name    : PIC16F1827.BAS                                    *
    '*  Author  : BURAK GÜNAY                                       *
    '*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 27.4.2014                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : PIC16F1827                                        *
    '*          :                                                   *
    '****************************************************************
    
    #header
      errorlevel -303  ; suppress Program word too large
    #ENDHEADER
    
    
    #config
     __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF 
     __CONFIG _CONFIG2, _WRT_OFF & _PLLEN_ON & _STVREN_OFF & _BORV_19 & _LVP_OFF
    #ENDCONFIG
    '-------------------------------------------------------------------------------
    'define OSC 4
    'DEFINE OSC 16
    define OSC 32
    
    
    'OSCCON=%01101010    'OSC is @ 4 MHZ
    'OSCCON=%01111000    'OSC is @ 16 MHZ
    OSCCON=%11110000    'OSC is @ 32 MHZ  --- PLLEN MUST BE ENABLED
    
    
    '------------- LCD DEFINES ------------------------
    DEFINE LCD_DREG PORTB 'LCD data port 
    DEFINE LCD_DBIT 4 'LCD data starting bit 0 or 4 
    
    
    DEFINE LCD_RSREG PORTA 'LCD register select port 
    DEFINE LCD_RSBIT 7 'LCD register select bit
    
    
    DEFINE LCD_RWREG PORTA   ' LCD read/write port
    DEFINE LCD_RWBIT 5   ' LCD read/write pin bit  
    
    
    DEFINE LCD_EREG PORTA 'LCD enable port 
    DEFINE LCD_EBIT 6 'LCD enable bit
    
    
    DEFINE LCD_BITS 4 'LCD bus size 4 or 8 
    DEFINE LCD_LINES 4 'Number lines on LCD
    
    
    DEFINE ADC_BITS 10     ' ADCIN resolution  (Bits)
    DEFINE ADC_CLOCK 6     ' ADC clock source  (Fosc/64)
    DEFINE ADC_SAMPLEUS 20 ' ADC sampling time (uSec)
    
    
    '------------- LCD DEFINES -------------------------
    
    
    '-------------------------------------------------------------------------------
    PORTA=%00000000     :      PORTB=%00000000
    TRISA=%00000000     :      TRISB=%00000010 
    ANSELA=%00000       :      ANSELB=%00000010
    ADCON0=%00000001    :      ADCON1=%11100000
    FVRCON=%00110000
    '-------------------------------------------------------------------------------                     
    
    
    value       var word    :   value=0
    rawtemp     var word    :   rawtemp=0
             
    lcdout $fe,1
    pause 500
      
    MAIN:
    
    
    adcin 11,VALUE
    adcin 29,rawtemp
    
    
    LCDOUT $FE,$80,"      ",DEC5 rawtemp,"     "
    LCDOUT $FE,$C0,"      ",DEC5 VALUE,"     "
    
    
    GOTO MAIN
    Where do I make mistake ?

    I'm expecting your helps , there must be at least a couple others that might have been interested in this function of such MCUs ... Thanks in advance
    Last edited by gunayburak; - 26th July 2015 at 18:16.
    - Ipsa scientia potestas est -

  2. #2

    Default Re: Temperature Indicator Usage

    Hi

    had a quick at the datasheet, looks like an interseting device. But did you see the errata, oh dear.

    You certainly need to set ADCON0 = x11101xx (x - not relevant) Fig16.1 "Temp indicator" input to ADC multiplexor

    You need to turn on TSEN (which you have done)

    And as the datasheet says
    The temperature sense circuit is integrated with the Fixed Voltage Reference (FVR) module
    maybe you need to turn that on as well,
    so FVRCON = 1x1xxxxx

    George
    Last edited by towlerg; - 26th July 2015 at 23:17.

  3. #3
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229

    Default Re: Temperature Indicator Usage

    Also the DS refers to a separate Application Note regarding this. AN1333
    Regards,
    TABSoft

  4. #4
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103

    Default Re: Temperature Indicator Usage

    Quote Originally Posted by Tabsoft View Post
    Also the DS refers to a separate Application Note regarding this. AN1333
    The application note is but a general calibration and formulation for pic families that posses such a function , there is no information in that A.N. regarding configuration of the module ...
    - Ipsa scientia potestas est -

  5. #5
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103

    Default Re: Temperature Indicator Usage

    Quote Originally Posted by towlerg View Post
    You certainly need to set ADCON0 = x11101xx (x - not relevant) Fig16.1 "Temp indicator" input to ADC multiplexor
    I've seen the published ERRATA for 1827 thus the missing TSEN - TSRNG bits in the original datasheet yet what you suggest with the sentence that starts with "certainly" is completely wrong .. Is it not the point why we use a compiler language that connects the holding capacitor to the "Analog Channel " / and the automatic control of the GO/DONE bit and those all other things that is required for a proper operation of an ADC conversion in a single line with single command for us ? AKA ADCIN? As you may know the usage of the ADCIN command we have to first select a channel and state a variable for the incoming result to be stored , in this manner which is the channel 29 which I've already put in the code .. Configuring the ADCON0 CHS<4:0>bits doesn't do any favor to us except stalling the MCU for one more instruction cycle ..

    Second of all about your idea of setting the FVRCON.7 enable bit doesn't make any sense , If you've observed the original datasheet page 137 the temperature indicator module's positive power supply can not be chosen and uses the VDD directly ...
    Name:  asdad.PNG
Views: 488
Size:  14.0 KB

    But thanks for your approaches anyway ...
    - Ipsa scientia potestas est -

  6. #6

    Default Re: Temperature Indicator Usage

    I've seen the published ERRATA for 1827 thus the missing TSEN - TSRNG bits in the original datasheet yet what you suggest with the sentence that starts with "certainly" is completely wrong .. Is it not the point why we use a compiler language that connects the holding capacitor to the "Analog Channel " / and the automatic control of the GO/DONE bit and those all other things that is required for a proper operation of an ADC conversion in a single line with single command for us ? AKA ADCIN? As you may know the usage of the ADCIN command we have to first select a channel and state a variable for the incoming result to be stored , in this manner which is the channel 29 which I've already put in the code .. Configuring the ADCON0 CHS<4:0>bits doesn't do any favor to us except stalling the MCU for one more instruction cycle ..
    Sorry, I've read this twice and I still don't understand. The multiplexer feeds the ADC with which ever input you select. You use ADCON0 to select the required input to the multiplexor.

    Name:  ADC.png
Views: 575
Size:  30.5 KB

    My suggestion that the FVR module may need to be enabled has nothing to do with Vdd - the manual states that the temperature indicator is part of the FVR module and FVREN controls the FVR module (FVREN is FVRCON.7)



    Sadly, I think this is ultimately a waste of time, without 2 point calibration the indicated temperature is "all over the place" and really only suitable as an overheat warning - just my 2 cents.

    George

  7. #7
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103

    Default Re: Temperature Indicator Usage

    Quote Originally Posted by towlerg View Post
    Sorry, I've read this twice and I still don't understand. George
    What you do by configuring the ADCON0 CHS<4:0> bits is already done by the number written in bold format ---> ADCIN 29,VAR [29 refers to Temperature Indicator Already]
    According to your claim : Each time you would like to get an ADC operation on different channels you first have to change the ADCON0 ? The answer is A NO ..
    Because the PicBasic command does it for us ...

    Have you seen anything associated in the diagram below that has anything to do with the configuration of the module except TSEN - TSRNG bits ? If there was there would be other registers shown out there ...

    Sadly, I think this is ultimately a waste of time, without 2 point calibration the indicated temperature is "all over the place" and really only suitable as an overheat warning - just my 2 cents.
    I don't think it is a waste of time at all and that's why I'm craving to solve this issue ...
    - Ipsa scientia potestas est -

  8. #8

    Default Re: Temperature Indicator Usage

    Aw well, each to his own.

    George

  9. #9
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103

    Default Re: Temperature Indicator Usage

    Anyone has an idea ?
    - Ipsa scientia potestas est -

  10. #10
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103

    Default Re: Temperature Indicator Usage

    Apparently no one has ever been interested in this temp. indic. module Well I hope someday somebody deals with it then
    - Ipsa scientia potestas est -

  11. #11
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,283

    Default Re: Temperature Indicator Usage

    Hi,
    You're giving up to easily.... I don't have a 16F1827 but I have a 16F1825 which also have the temp indicator module. If you can't get it going I will bread-board it and give it a go but I have my own Projects as well and I'd rather work on those at the moment :-)

    One thing I see when Reading the datasheet is this:
    To ensure accurate temperature measurements, the
    user must wait at least 200us after the ADC input
    multiplexer is connected to the temperature indicator
    output before the conversion is performed. In addition,
    the user must wait 200us between sequential
    conversions of the temperature indicator output.
    You have set an acqusition time of 20us, 10 times less than what's required. Try DEFINE ADC_SAMPLEUS 200 and see what happens.

    /Henrik.

  12. #12
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103

    Default Re: Temperature Indicator Usage

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    You're giving up to easily.... I don't have a 16F1827 but I have a 16F1825 which also have the temp indicator module. If you can't get it going I will bread-board it and give it a go but I have my own Projects as well and I'd rather work on those at the moment :-)

    One thing I see when Reading the datasheet is this:

    You have set an acqusition time of 20us, 10 times less than what's required. Try DEFINE ADC_SAMPLEUS 200 and see what happens.

    /Henrik.
    Brilliant rebound Henrik ! I was really really about to give it up I'll let you know what I get after I try what you suggest ...
    You're the one "again"
    - Ipsa scientia potestas est -

  13. #13
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103

    Default Re: Temperature Indicator Usage

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    You're giving up to easily.... I don't have a 16F1827 but I have a 16F1825 which also have the temp indicator module. If you can't get it going I will bread-board it and give it a go but I have my own Projects as well and I'd rather work on those at the moment :-)

    One thing I see when Reading the datasheet is this:

    You have set an acqusition time of 20us, 10 times less than what's required. Try DEFINE ADC_SAMPLEUS 200 and see what happens.

    /Henrik.
    Hello Henrik ;

    Sorry for the long delay , I had health issues and I return back to my RE-DE table as quick as possible after a quick recovery ...

    I've done as you suggested and now I don't have that dependent ADC result changing problem/madness at 500 us acqusition time setting and quickly tried to get the silicon die temperature of two different pic16f1827 and I got almost the same values (one of them reads 496 and the other 497 at the very beginning of the power up..) ... Right after that I started to observe the formulas on AN1333 published by Microchip , I applied the obtained values to the formulas but I get a result which is both good and bad with raw 496 under 10 bits conversion and high range mode(4) ..

    According to the formulas I get -28.59 degrees ... Well , now ...
    ---------------------------------------------------------------

    *The good thing about this reading is that it would be an almost right conversion result if it were a positive value Because when I measure the top surface temperature of the PIC with an infrared thermometer in "object measuring mode" , I get 27.12 C' ... NOT BAD when considered the die temp. must be a little more than that !!!

    *The bad thing as mentioned above is that its being a negative value

    By the way there is a strange thing I keep seeing during I read the application note .. The value 0.00132 is written as 0.0132 in other forms of the calculations ...

    However ;
    I don't know if it is a victory or a half victory or maybe a coincidence but perhaps there is an entirely different calibration formula for this PIC ...

    I'm so curious about your and all others' approaches to this problem who are interested in this built in temp. sensor module ..

    Regards
    Last edited by gunayburak; - 5th August 2015 at 15:26.
    - Ipsa scientia potestas est -

  14. #14
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,283

    Default Re: Temperature Indicator Usage

    Hi,
    I'm glad you're feeling better. As I said previously I don't have any experience in using the temp sense module in these PICs, all I'm doing is reading the datasheets.

    First, lets see if a raw reading 496 makes sense.
    Let's, for the exercise, say that Vt for your device matches that of the device in the App note, somewhere around 0.574V at 27C.
    Vtemp, ie the voltage that the ADC measures is, in high range mode, Vdd-4*Vt or for a 5V Vdd: 5-(4*0.574)=2.704.
    The RAW ADC reading is 2.704/5*1023=553.'

    You're getting a value of 496 so I guess that's reasonable. I don't quite understand the values shown in Figure 4, perhaps that's using 8bit conversion, I don't know.

    That's basically how far I've got as of now and I'm running out of time right now. Hopefully someone else will step in.

    /Henrik.

Similar Threads

  1. One of 33 LED output Indicator
    By SOTASOTA in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 5th December 2012, 18:26
  2. About the replacement of the indicator with BASIC.
    By apollo21 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 8th June 2008, 04:56
  3. Interrupt usage
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 20th April 2008, 16:20
  4. Serin usage?
    By champion in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 24th January 2007, 01:57
  5. Temp. Indicator.
    By PIC Coder in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 28th April 2005, 06:10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts