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.
Experimental internal temperature macro
Moderator: Benj
-
Kenrix2
- Flowcode v5 User
- Posts: 211
- Joined: Tue Feb 19, 2013 9:51 pm
- Has thanked: 72 times
- Been thanked: 177 times
Re: Experimental internal temperature macro
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.
- cubitus54
- Flowcode v5 User
- Posts: 110
- Joined: Wed Jun 19, 2013 7:18 am
- Has thanked: 7 times
- Been thanked: 32 times
Re: Experimental internal temperature macro
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
Puls D8 = start
RS232 result

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 );RS232 result

Flowcode V6.1.2.0(11 05 2015)
- cubitus54
- Flowcode v5 User
- Posts: 110
- Joined: Wed Jun 19, 2013 7:18 am
- Has thanked: 7 times
- Been thanked: 32 times
Re: Experimental internal temperature macro
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

Flowcode V6.1.2.0(11 05 2015)
- cubitus54
- Flowcode v5 User
- Posts: 110
- Joined: Wed Jun 19, 2013 7:18 am
- Has thanked: 7 times
- Been thanked: 32 times
Re: Experimental internal temperature macro
The first image is a RIGOL MSO4014 oscilloscope, the second a GBF RIGOL DG4063
This is good material and I'm very happy
This is good material and I'm very happy
Flowcode V6.1.2.0(11 05 2015)
- cubitus54
- Flowcode v5 User
- Posts: 110
- Joined: Wed Jun 19, 2013 7:18 am
- Has thanked: 7 times
- Been thanked: 32 times
Re: Experimental internal temperature macro
€ 7700 is a TEKTRONIX. Yes it is beautiful 
It exists for the same reference Rigo
http://www.batronix.com/shop/oscillosco ... O4014.html
It exists for the same reference Rigo
http://www.batronix.com/shop/oscillosco ... O4014.html
Flowcode V6.1.2.0(11 05 2015)