Page 1 of 1

Experimental internal temperature macro

Posted: Thu Feb 06, 2014 1:14 am
by Kenrix2
I wrote some code for the internal temperature unit and thought I would share.

To use this macro within Flowcode select Macro>Import..., select the macro name and open.
Then drag a macro icon into your program and click on the macro name.

Re: Experimental internal temperature macro

Posted: Fri Feb 28, 2014 7:36 pm
by cubitus54
Hello

It is a good idea and a good job: D

I just tested on a PIC 16F1847, I have about 530 for 23 °.

Re: Experimental internal temperature macro

Posted: Fri Feb 28, 2014 7:52 pm
by Kenrix2
Glad it worked for you. I use the value from the macro to adjust the osctune register. When using the internal oscillator the clock frequency will change depending on the die temperature. This keeps the frequency drift in check.

Re: Experimental internal temperature macro

Posted: Fri Feb 28, 2014 8:38 pm
by cubitus54
I tried to optimized the conversion:

The PIC runs at 32MHz

The recommeded in the documentation time is 200μs, I made ​​20μs

fosc
fosc/2 : result : 1023 wrong
fosc/4 : result : 536
fosc/8 : result : 532
fosc/16 : result : 531
fosc/64 : result : 531
Time of conversion 980µs

Chargetime, temperature, time conv
255 , 531 , 980µs
128 , 529 , 864µs
064 , 520 , 796µs
032 , 497 , 768µs
016 , 464 , 752µs

Code: Select all

fvrcon=(fvrcon | 0b00110000);
delay_us(20);
FCL_CHARGETIME=200;
adcon1=0x50;
set_bit(adcon1,ADFM);
adcon0=0b01110101;
while(FCL_CHARGETIME>0)FCL_CHARGETIME--;//charge adc capacitor
adcon0.1=1;//start adc conversion
while (adcon0 & 0x02);//wait till conversion is complete
adcon0=0x00;//turn off adc module
FCR_RETVAL = adresl | ( adresh << 8 );
Puls D8 = start
RS232 result
Image

Re: Experimental internal temperature macro

Posted: Sat Mar 01, 2014 9:23 am
by cubitus54
Kenrix2 wrote:Glad it worked for you. I use the value from the macro to adjust the osctune register. When using the internal oscillator the clock frequency will change depending on the die temperature. This keeps the frequency drift in check.

I tried the frequency variation with ostune.
It is a good idea! :)

Variation of 0-64 on 16F1847 @32Mhz
Max = 8,23MHz
min = 7,78MHz

Image

Re: Experimental internal temperature macro

Posted: Tue Mar 18, 2014 2:44 pm
by Mathy
Hello,

what is your oscilloscope reference ?
It seems to have a nice IHM :)

Re: Experimental internal temperature macro

Posted: Thu Mar 20, 2014 8:47 am
by cubitus54
The first image is a RIGOL MSO4014 oscilloscope, the second a GBF RIGOL DG4063
This is good material and I'm very happy :D

Re: Experimental internal temperature macro

Posted: Thu Mar 20, 2014 9:08 am
by Mathy
Hello,

Thank you for your answer but 7700+€ for the MSO4014B is a little bit more than my budget :mrgreen:

Thank again and have fun :)

Re: Experimental internal temperature macro

Posted: Fri Mar 21, 2014 7:07 am
by cubitus54
€ 7700 is a TEKTRONIX. Yes it is beautiful :)

It exists for the same reference Rigo
http://www.batronix.com/shop/oscillosco ... O4014.html