Experimental internal temperature macro

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times

Experimental internal temperature macro

Post 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.
Attachments
ChipTempV5.fcm
(6.2 KiB) Downloaded 405 times

User avatar
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

Post 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 °.
Flowcode V6.1.2.0(11 05 2015)

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

Post 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.

User avatar
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

Post 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
Flowcode V6.1.2.0(11 05 2015)

User avatar
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

Post 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
Flowcode V6.1.2.0(11 05 2015)

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times

Re: Experimental internal temperature macro

Post by Mathy »

Hello,

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

User avatar
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

Post 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
Flowcode V6.1.2.0(11 05 2015)

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times

Re: Experimental internal temperature macro

Post 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 :)

User avatar
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

Post 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
Flowcode V6.1.2.0(11 05 2015)

Post Reply