M2 Internal Temperature Sensor

lbenson

Senior Member
This is no doubt a matter for testing, but with a good heat sink, how close a reading is readinternaltemp likely to give compared to a DS18B20 mounted on a circuit board a centimeter from the chip?

I read the warnings in the readinternaltemp command, but can you dissipate the heat well enough to provide a reading within 2-3 degrees C of ambient?

I eagerly await my new chips. The extended M2 series is very liberating.
 

Texy

Senior Member
As you've already stated, you've already read the manual, but to quote :
"This command is used to provide an indicator of the internal temperature of the
chip. It is designed to be used as a cooling failure warning threshold device, not
an accurate temperature sensor! For accuracy use a DS18B20 sensor and the
readtemp command instead"

Thanks for highlighting this new command, as I was not aware of it and it would of been useful in one of my current projects, alas the 18M2 is does not support it.
Rgds,

Texy
 

hippy

Technical Support
Staff member
This is one of those cases where Microchip don't put everything on all silicon so unfortunately it's not, as you note, available for the 18M2.

The internal Temperature Indicator Module ( Microchip call it an "indicator" rather than "sensor" ) works by measuring the voltage drop across internal diodes and that varies with temperature but is also affected by voltage and readings vary across chips.

There's a Microchip Application Note (AN1333) which provides much more detail ...

http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en550238

This voltage across the diodes is read using the standard ADC and Figure 4 shows typical readings across the temperature range, -40C to +85C = 120 to 156 (8-bit), = 480 to 624 (10-bit).

So, at 10-bits, that's a reading range of 244 to cover a range of 125C. Calibrated and doing the maths accurately it should theoretically be possible to obtain around 0.5C resolution. Uncalibrated and using the IT_5V0 etc supply voltage indicators in the command and it's accurate to a couple of degree C. However, also take note of Figure 8 - Abs Temperature Error.

Using the IT_RAW command options, calibrating and applying the equations in the datasheet would be the best way for best accurate determination of temperature.

For under and over-temperature detection it can be as simple as "If readValue > N", comparing with a determined level, actual units of measurement not being important.

Whether the internal temperature indicator can replace an external DS18B20 really depends on the project, what resolution and accuracy of temperature is needed, how much effort one's prepared to put in, but it's there if you need it and some projects will likely find it very useful.
 

hippy

Technical Support
Staff member
That's a good pick from the app note. Generally the slope and linearity is the same, the line is just shifted up or down ( what the offset in the READINTERNALTEMP command caters for ) but there are slight linearity differences which is what makes it hard to say exactly how accurate things will be.

Assuming good linearity, that graph, plus the one which shows the line slope pivoting (Figure 6 ), sums up the challenge of conversion and calibration; working out the offset and slope and fitting readings to that. The firmware ( in IT_5VO etc modes ) takes an typical case for those so it won't be as accurate as a device specific calibration and will vary from device to device.
 

manuka

Senior Member
Hippy: Apologies - I'd briefly deleted my graph comment posted between your own quick fire responses. My reflection was that irksome individual calibration & coding may be needed, making the DS18B20 still appealing.

But have you a 08M2 handy to conduct some simple tests? Wave perhaps a hot air gun over it, or just touch the PICAXE with a piece of (wrapped) ice. Many applications may only need such a good-bad-ugly thermal measure of course.
 

Attachments

Last edited:

westaust55

Moderator
As a first though on the concept;

The PIC chip internals generate heat and thus the internal semiconductor is warmer than the external surface as defined by the thermal resistivity of the package - unless the PIC is in an oven or other form of warm environment.
The internal temperature is also to some extent related to the load current passing through the PIC chip – the core itself using a relatively small current.

By comparison a DS18B20 nominally only operates when doing a temperature conversion. In the meantime the ambient temperature is permeating to the semiconductor at a rate defined by the package thermal resistivity.
If the DS18B20 is instructed to perform many temperature conversions in a relatively rapid succession the internal semiconductor will warm slightly leading to errors.

By comparison, for the PIC chip the direction of thermal heat transfer is generally outwards from the semiconductor, whereas for the DS18B20, the intended direction of thermal heat transfer is generally inwards to the semiconductor.

Thus at a simple level, without reference to the thermal resistivity data for either PICAXE or DS18B20, IMHO, for a given ambient temperature I might expect a PICAXE chip to give a slightly higher reading than a DS18B20 even if you apply heat sinking to the outside of the PIC chip package.
 

hippy

Technical Support
Staff member
But have you a 08M2 handy to conduct some simple tests? Wave perhaps a hot air gun over it, or just touch the PICAXE with a piece of (wrapped) ice. Many applications may only need such a good-bad-ugly thermal measure of course.
Tests were done on the new M2's, including various ambient tests, sitting the board in a fridge and standing a cup of tea on top of the chip. Not perfect nor scientific tests but compared to DS18B20 readings the results matched what the Application Note described.

I don't know if I have recorded results but recall they were within a degree or so of expected generally.
 

Dippy

Moderator
Yes, good points.
And it is potentially complicated by what your PICAXE is doing i.e. loads and clock speeds.

I guess if you know what is going on then it could give you a good ballpark figure but I think it's horses for courses. And I would assume it depends on your requirements and expectations. In any event, it is a useful option.


"The on-board temperature indicator can be used to
measure the device temperature, which will
correspond to the temperature in its environment with
some delay. The indicator is measured using the ADC
and can be used uncalibrated for coarse temperature
measurements. For more precise temperature
measurements, calibration is required to account for
device parameter variation. Depending on the
application, calibration measurements at one or two
temperatures may be required. Since the ADC results
are dependent on its provided references, the fixed
references need to be supplied either by using the
onboard fixed references, or by using a regulated
supply. Otherwise, the device supply voltage must be
calculated using the fixed voltage reference."
- Microchip.
 

lbenson

Senior Member
Thanks all for the responses. For my particular application, I just want to know if the wintertime temperature in my vacant but kept-above-freezing vacation home rises significantly above around 4C--which would indicate a stuck zone valve in the heating system. There's really no reason not to use a DS18B20 but for the purpose of a comparison and redundancy, I might try a bare 08M2 as well.
 

fernando_g

Senior Member
If you decide to go with the internal temp sensor route, try to use a surface mount version.
SMT packages usually have lower thermal resistance (which minimizes long term errors) and thermal mass (which minimize time lags) than a thru hole counterpart.
And you can almost always use a ground plane as the heatsink itself.
 

john2051

New Member
Internal sensor

If pic chips warm up as a result of too much current being drawn, could this
be used as a safety feature, ie put the output pins into a low current state.

regards john
 

westaust55

Moderator
If pic chips warm up as a result of too much current being drawn, could this be used as a safety feature, ie put the output pins into a low current state.
Yes, you could use READINTERNALTEMP and if a high temperature is detected use that to change outputs to inputs to reduce the current flow through the chip if the temp value is too high.
Could be useful during project development but if a project is well designed should not be needed in the final product.
For the concept to be successful, you need to ensure that the READINTERNALTEMP is executed at a sufficiently frequent interval (eg 1 second or less intervals).

Maybe tracking for temp changes as well as absolute temp. Higher importance to react if the temp change is rapid. Tracking would need more frequent use of READINTERNALTEMP to be useful.

Report the temp changes and, if to be useful, under what conditions, to the designer for consideration on design changes. Just having outputs shut down on a high temp without details as to why will likely leas to frustration.
 

Dippy

Moderator
I'm sure most things are possible with a little thought.

Isn't this a prime candidate for "suck it and see" ?
I reckon a pile of good trial & testing could have done in the time this thread has been going :rolleyes:
 

lbenson

Senior Member
> "suck it and see"

If I had my parts (ordered the day they came out), I'd be sucking it (in rural Nova Scotia).
 

srnet

Senior Member
If pic chips warm up as a result of too much current being drawn, could this
be used as a safety feature
But why would you want to ?

Rather than depend on alleged software tricks, which may cause more problems that they solve, why not design it so you dont need to check if its overheating in the first place ?
 

eclectic

Moderator
But why would you want to ?

Rather than depend on alleged software tricks, which may cause more problems that they solve, why not design it so you dont need to check if its overheating in the first place ?
Just for discussion.

Why do we have alarms / fuses / locks / interlocks / thermal cutouts ......?

Well, certainly in my case, 'cos things happen. :-(

If I'm blindly out on a limb, I'd like a safety net.

Another component to belt and braces is more than welcome.

Apologies for all the similies / metaphors and general rambling.

e
 
Last edited:

john2051

New Member
re:

Hi, mainly I was thinking out loud.
I thought it could be used as a failsafe, incase a fet or bjt goes short. But if you had to scan repeatedly it wouldnt really be workable.
I'm also building some metal hydride single cell chargers, and if these diodes could be an indicator of ambient temp then I could use a ds1820 on the cell.

regards john
 

westaust55

Moderator
if these diodes could be an indicator of ambient temp then I could use a ds1820 on the cell.
If you are thinking in terms of one DS18B20 per battery cell then obviously many 18B20’s needed and with an M2 PICAXE chip that can mean many inputs used.

As an alternative, with and X1 or X2 part, you can use the 1-Wire network scheme which needs only a single PICAXE input pin with many temps sensors. In addition to the DS18B20 there are then other chips designed by Maxim more specifically for battery cell monitoring including some with current and voltage ADC inputs such as the DS2438.
 

John West

Senior Member
For monitoring slowly fluctuating temperatures one might well get away with using the internal "indicator" circuit. Particularly if it is being used in one of those "shut everything down and make the batteries last forever" type applications, where the chip's internal temperature is essentially the same as ambient, and the fewer external loads, the better.
 

manuka

Senior Member
I've now some 08M2 in my hot little hands,and -warming to Rev. Ed's "save a cell" advice- have taken to powering assorted setups with just 2 x AAs. Although I'm an immense DS18B20 fan,these esteemed darlings need a good 3-5.5V,and annoyingly can be x2 the price of a 08M2. Frustratingly they may end up being tossed in with assorted bipolar lookalikes! The new readinternaltemp command certainly hence caught my eye- if only for convenience.

Coding followed a sample & proved sturdy enough,although I found placing the wait/pause before the reading allowed the hardware to settle & overcome glitched switch on readings. Simple calibration beside a mercury in glass lab. thermometer showed (at my 3 V supply) that merely subtracting 212 (suprise !) gave a SERTXD reading within a degree Celsius of true. This held pretty well for trials in the range 8 Celsius (local NZ winter night temp. outdoors) to mid 20s (indoors),although it was apparent offset tweaks would help. However it's either a senior moment,or the NZ winter slowing my brain, as I can't get a handle on insights shown in the 2nd Manual (P.175). I'm surely not the only one hazy about this?

The 08M2's 256 byte memory could allow readings to be taken (and then held internally) every hour for ~10 days. As current draw at 3V for the 08M2 here was only ~½mA, a 2 x AA supply wouldn't flag too badly over such a period. Of course SLEEP tweaks would bring battery drain to near shelf self discharge.
Code:
main:
       wait 60                       ' initial wait to allow 08M2 & battery settling after power up
       readinternaltemp IT_3V0,0,b1  ' a 2 x AA supply (close to 3V) was used  
       b2= b1-212                    ' correction factor for ~Celsius display (adjust to suit)
       sertxd (#b2,CR,LF)            ' show approx. Celsius temp on terminal screen
       goto main                     ' loop & continue readings every minute
There we go - the bones of a skinflint's single chip US$3 temperature data logger! Stan.
 
Last edited by a moderator:

manuka

Senior Member
Yes- worth knowing about! I'm actually pondering using the 08M2's I2C features for some decent datalogging work with the likes of a DS3231 temperature compensated RTC. This is sold as a "Chronodot" & could make quite a proessional device all up -the long established DS1307 is cheaper but not as accurate.
 

erco

Senior Member
Fantastic temp/datalogger idea, manuka. I like the way you think! I also subscribe to the "how can we do the most with the least" theory. I started with $50 BASIC Stamps, so $5 PicAxes seem almost free to me. Getting even more from their built-in features is just icing on the cake.
 

fernando_g

Senior Member
If there is an individual that can perform miracles with those tiny devices, it is Manuka.

I bow my head to thee, oh! great lord of the eight-pins!
 
Top