CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC10F322 - Internal Temperature Indicator
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
viki2000



Joined: 08 May 2013
Posts: 233

View user's profile Send private message

PostPosted: Wed Jul 29, 2015 6:44 am     Reply with quote

When I calculate the temperature I measure first time the VDD using FVR as suggested in AN1072 page 2:
http://ww1.microchip.com/downloads/en/AppNotes/01072A.pdf
If we look in the datasheet from 2011 page 171 of the PIC10F322 (I guess version A) we see the parameter D003 VADFVR as -7%...+6%
https://drive.google.com/file/d/0BwXmKaSw75eKaVNySl9FVHdKWVU/view?pli=1
Then in the datasheet from 2011-2014 (version B) page 159 there is no D003 parameter for FVR.
https://drive.google.com/file/d/0BwXmKaSw75eKU2hQRGdRTUFBemc/view?pli=1
http://ww1.microchip.com/downloads/en/DeviceDoc/40001585B.pdf
In the datasheet from 2011-2015 (version C) and the latest, on the page 159, the parameter D003 appears again as VFVR with +/-19% tolerance:
http://ww1.microchip.com/downloads/en/DeviceDoc/40001585C.pdf
What kind of voltage reference is that with such high tolerance?
Ttelmah



Joined: 11 Mar 2010
Posts: 20061

View user's profile Send private message

PostPosted: Wed Jul 29, 2015 8:21 am     Reply with quote

Seriously lots of 'voltage references', like Zener diodes have this sort of tolerance. It doesn't claim to be a _precision_ voltage reference.
viki2000



Joined: 08 May 2013
Posts: 233

View user's profile Send private message

PostPosted: Wed Jul 29, 2015 3:48 pm     Reply with quote

I tested 30 pieces PIC10F322 extended version (up to 125°C) in package SOT23-6 without calibration.
I had to change the offset in the code from 40 to 120 because the temperature readings were a lot under the expected negative values and were not sent correctly serial.
I used Microchip AC163020 programming adapter.
http://www.microchip.com/Developmenttools/ProductDetails.aspx?PartNO=AC163020
The test was quite fast, more difficult was to install and remove the PIC with the tweezers in the SOT23-6 socket.
I programmed each chip and in the next seconds I could see the ADCfvr, ADCti and Temperature on the display.
Here are the results:
https://docs.google.com/spreadsheets/d/1fKRiEQRW1PlvNmhArHVVosVSSOR7cu6wQtWIlS-2loM/edit?usp=sharing
The calculated temperature inside the PIC is close enough to the value calculated in Excel.
Here is graphic with the spread of the temperature measurements without calibration:
https://docs.google.com/spreadsheets/d/1fKRiEQRW1PlvNmhArHVVosVSSOR7cu6wQtWIlS-2loM/pubchart?oid=1237926541&format=interactive

http://i926.photobucket.com/albums/ad102/viki2000/Microchip/30x%20PIC10F322%20-%20Temperature%20Indicator_zpswymosuym.jpg

The FVR measurement used to calculate the VDD is very good and constant for all samples.
The temperature measurement without calibration is awful.
It shows differences of 50°C easy.
It make no sense to try it at different VDD voltages and different temperatures.
It would make sense such tests if we calibrate it at least in one point.
Ttelmah



Joined: 11 Mar 2010
Posts: 20061

View user's profile Send private message

PostPosted: Thu Jul 30, 2015 12:42 am     Reply with quote

Don't get me wrong, but they tell you this in the data sheet.

"The circuit may be used as a temperature threshold
detector or a more accurate temperature indicator,
depending on the level of calibration performed. A onepoint
calibration allows the circuit to indicate a
temperature closely surrounding that point. A two-point
calibration allows the circuit to sense the entire range
of temperature more accurately."

They couldn't be much clearer.

If the accuracy was 'good enough' to give +/-2 degrees (say) without calibration, then they would undoubtedly advertise this.

I know it is 'insane', but it is what the chip has.
It's dependant on so many factors (the current generated by the source, the actual geometry of the diode, and the drop across the enabling MOSFET), that hoping it'll be close is just that 'hope'....

The actual change for temperature is much better defined. It'll be between 2, and 2.5mV/C. With the 4 diodes used, 8 to 10mV/C.

Have a look at:
<http://electronicdesign.com/lighting/use-forward-voltage-drop-measure-junction-temperature>

Microchip say you need a minimum of a one point calibration, and this is right.
The problem is that the initial value is dependant on so many non-calibrated factors.

However the second calibration to get 'slope' is much less necessary. This depends primarily on the chemistry of the junction, so will not vary by vey much, except if you need 'extreme' values.

One suggestion:

Have the chips contain code that checks for a stored calibration constant. If it is not there, it immediately performs a calibration, assuming the temperature to be 20C.

All that is then needed is to ensure that the initial switch-on is done at a temperature close to 20C.
viki2000



Joined: 08 May 2013
Posts: 233

View user's profile Send private message

PostPosted: Thu Jul 30, 2015 8:56 am     Reply with quote

I repeated the test with the same code for PIC10F322, same setup, but this time using 30x PIC10F322 I/P industrial version up to 85°C and package PDIP-8.
The results are here:
https://docs.google.com/spreadsheets/d/1Sp4X8oMsgnUMJDDK9AYYJvSZA53hTQkXlefjshloK60/edit?usp=sharing
https://drive.google.com/open?id=0BwXmKaSw75eKT1ozMnJiLWdibUU
http://s926.photobucket.com/user/viki2000/media/PIC10F322_I_P_DIP8_Temperature_indicator_zpsp9iiwlcb.jpg.html

In my 1st case with SOT-23-6 PICs, the ADC result is between 107 and 126.
If we calculate back the junction voltage we get:
- for 107: (107*5/255)/4=0.5245, which gives (0.5245/0.5735-1)*100=-8.54% deviation compared with 1 device PIC16F1937 which has 0.5735V at 25°C
- for 126: (126*5/255)/4=0.6167, which gives (0.6167/0.5735-1)*100=+7.53% deviation compared with 1 device PIC16F1937 which has 0.5735V at 25°C
- The deviation of the junction voltage of the PIC10F322 SOT-23-6 compared with 1 device PIC16F1937 is then +7.5/-8.5%.
- The deviation range is +7.5%-(-8.5%)=7.5%+8.5%=16%
In my 2nd test with PDIP-8 PICs, the ADC result is between 120 and 140.
If we calculate back the junction voltage we get:
- for 120: (120*5/255)/4=0.5882, which gives (0.5882/0.5735-1)*100=+2.56% deviation compared with 1 device PIC16F1937 which has 0.5735V at 25°C
- for 140: (140*5/255)/4=0.6862, which gives (0.6862/0.5735-1)*100=+19.65% deviation compared with 1 device PIC16F1937 which has 0.5735V at 25°C
- The deviation of the junction voltage of the PIC10F322 PDIP-8 compared with 1 device PIC16F1937 is then +2.5/+19.6%.
- The deviation range is 19.6%-2.5%=17.1%
The deviation range is the almost the same for SOT-23-6 as for PIDP8, only that is shifted with an offset.

Do you know the typical tolerance of the silicone diode junction forward voltage?

There is an important difference between results obtained with SOT-23-6 and PDIP-8 packages. It is obviously an offset besides the spread of the results in a quite wide range when there is no calibration done.
Based on 30 device, we have for SOT-23-6 the temperature in the range -93….22°C and the ADCti in the range 107…126. That 115°C spread range.
Based on 30 device, we have for PDI-8 the temperature in the range -44…+39°C and the ADCti in the range 120…140. That is 83°C spread range.
The VDD was 4.99-5.00, detected by PIC10F322 with FVR sometimes 52 as 5.02V and sometimes 53 as 4.93V.
It is like a shifting/offset of the results for these 2 packages with 13-14 for ADCti, which corresponds to around 48-50°C.
I need to use SOT-23-6 anyway, but I made the test with PDIP-8 only to double check the possible errors.
The problem is what we get as offset for non-calibrated devices.

The conclusion after such analysis effort is that PIC10F322 gives a too wide range for the temperature measurement which cannot be used without calibration.

Your suggestion from last post above with auto calibration is good, but there are some limitations.
We speak about a big number of PICs which come with my code directly programmed by Microchip. The production site has no options to test, program or calibrate the PICs.
It remains only one option: the production site to ensure a constant known ambient temperature, let’s say 25°C and then after the PIC is assembled on its tiny board and the end product is tested for functionality, then at the 1st power up the PIC will calibrate itself as you suggested.
That means self-writing in 1 memory location of the PIC10F322 one time.
The procedure for self-writing is a bit described in the datasheet and was a discussion here about it:
http://www.ccsinfo.com/forum/viewtopic.php?t=48765
I never checked if and how it is working, but if I understood right it needs a lot of flash memory and may be bugs.
I have only 10-15%, maybe max. 20% flash memory left.

Any chance to estimate how much flash memory do I need to implement the self-writing for auto calibration?
Ttelmah



Joined: 11 Mar 2010
Posts: 20061

View user's profile Send private message

PostPosted: Thu Jul 30, 2015 2:05 pm     Reply with quote

If you are only writing once, and to one location, it gets a lot smaller. Key is that you can use 'erased' at the state to be tested for, and leave this location erased from the factory, so you don't need any erase code. 50% of the code then vanishes. Then if you look in this thread:
<http://www.ccsinfo.com/forum/viewtopic.php?t=54018>, you will see my version of the Microchip write code.
If you simplify that, by only transferring one integer to it, and writing to one fixed location, the size should only be perhaps 20 to 30 instructions.
viki2000



Joined: 08 May 2013
Posts: 233

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 1:24 am     Reply with quote

Here is AN1687 with explanations and code example for self-write, emulating EEPROM with HEF memory PIC10F/PIC12F:
http://ww1.microchip.com/downloads/en/AppNotes/00001687A.pdf
When I have time I will test that and to implement the auto-calibration.
Ttelmah



Joined: 11 Mar 2010
Posts: 20061

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 3:19 am     Reply with quote

Seriously you won't have the code/RAM space for this.

You have to realise that this is designed to use multiple pages, and to allow multiple read/writes. Each page, is space lost from your program (hence just use one). For multiple read/writes, you need erase code (you don't, so much less code space needed).

As I said, just use the simplified write code alone, to the already erased chip.

Just test if the byte is 0xFF. If it is, perform the calibration, and write one byte. Minimum space used.
temtronic



Joined: 01 Jul 2010
Posts: 9632
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 6:49 am     Reply with quote

This thread is a great example of doing a LOT of work for little reward( except for the journey). The OP has done days or work only to finally discover the PIC with internal temp sensor really isn't the 'perfect' choice.
Using the old analog LM34 you could have had small,compact code 'up and running' in 5-10 minutes.Even using a digital DS18B20 less than 1/2 hour though more ROM is used. As you've found out the internal sensor is not very accurate and needs a LOT of code space to 'read right'.
I'm not sure why Microchip added the sensor, to me it's one of those 'seems like a good idea, but poorly executed' peripherals.I'd rather have another UART or RTC or ? than the 'temp sensor'. easier to spend 50c on an external device ,mount over the PIC if you want the PICs temperature.
As for using diodes for temp. sensors, back in the 70's I used 4 in series. Design came from a paperback book about the TRS-80. Still have both on the shelf! will grab the book if asked for it.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 20061

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 8:00 am     Reply with quote

That's exactly the circuit in the PIC. Two or four diodes (switchable).

Problem with the PIC circuit, is not basically the diodes, but the 'support'. The voltage depends heavily on current, and so they use a constant current source, but this is as in-accurate as the Vref. Then the FET that enables the circuit also seems to have significant batch variation.

Don't take me back to the TRS-80...
viki2000



Joined: 08 May 2013
Posts: 233

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 8:12 am     Reply with quote

@Ttelmah
I will follow your advice, but then there is one more question.
The PICs come ready programmed by Microchip with my code.
If we define “calibration” the steps mentioned by you (test if the byte is 0xFF. If it is, perform the calibration, and write one byte), then:
- Is it the risk that the PIC will calibrate automatically right after programming at Microchip site?
If yes, then I have to add one more condition, in which the PIC will test if it is present on its board soldered, by measuring a signal at one pin and only then the calibration is performed.

@temtronic
There are several limitations/conditions imposed from beginning that maybe I did not mention:
- I am not allowed to add additional components to the board/PIC, not even a cheap one.
- The usage of internal temperature indicator is optional in my case, but it would be a good feature. My tests are only investigating the possibility to use that temperature sensor or not. It would be satisfactory for me to only know if it is very cold, cold, normal, hot, very hot – let’s say 20°C precision of measurement. If that is not achievable then I would be still OK with cold, normal, hot – let’s say 40°C precision.
- The tests done indicate that we cannot use that sensor without calibration. The error due to offset is too big.
Next logical step is auto-calibration in one point at 25°C with minimal code as described by Ttelmah and then to measure again the deviation at very low and high temperatures for a batch of PICs. Only at the end of such test we can say if there is a little reward (knowing how is it working) or maybe I will achieve my goal by using that internal sensor.
Ttelmah



Joined: 11 Mar 2010
Posts: 20061

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 8:33 am     Reply with quote

You need to ask Microchip. Explain that the unit does a temperature calibration on first power on, and ask if this will be clear.

However I'd say not. The chips would not normally be powered up after programming, unless you request testing.
temtronic



Joined: 01 Jul 2010
Posts: 9632
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 9:15 am     Reply with quote

Maybe look at it another way, since you only need 'really cold','really hot' or 'OK'.

Do a small study, say 10 PICs and average the ADC output for 'cold' and 'hot'. for sake of discussion, in 8 bit mode <_ 63 bits is 'cold', >_ 192 bits is 'hot', anything in between is OK.

It might be possible that this will work for you. If all of the PICs are the same batch, then the temp ind. sensors 'should' be similar,hopefully good enough for your project.

If you've kept track of your R&D time,at $100 /hr, you can see why I've used LM34s in the past and now DS18B30s.

Jay
viki2000



Joined: 08 May 2013
Posts: 233

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 1:34 pm     Reply with quote

This is for me a secondary task as R&D, near the official job, so I do it when I have time without any pressure.
The PICs cannot be from the same batch. We speak about up to 50K PICs per year.
temtronic



Joined: 01 Jul 2010
Posts: 9632
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 2:29 pm     Reply with quote

I finally read the specs for the 10F322, yeesh 512 words of program space !
So have to ask how much memory can you afford to use for the temperature feature?

Perhaps you could you program the PIC first with an 'temp. calibration' program and send the data to a PC host? It would have the 1 or 2 bytes needed for the slope.
Then erase the PIC and load in the 'real' program having modified it to contain the 1 or 2 bytes for the slope?

I know it's a time consuming method but it would allow every PIC to have it's own accurate temperature.

IF you had another PIC ( bigger !) there might be another way but you're really strapped for code space with this 322 !!

I'll keep thinking as I do like a challenge.

Jay
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group