Measure AVR temp by checking RC osc freq

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's my program that prints out deg C and deg F of the AVR by measuring the RC osc freq. Hotter -> slower. This runs on a mega32 16mhz, 38400 baud. Put the hair dryer on it and see if it seems about right?

Attachment(s): 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am not sure that I would count on any particular temperature coefficient.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wonder about that. I was thinking it would be fairly consistent. The internal R and C should have pretty consistent temperature coefficients, right? So to first order I would guess part to part will be very similar. You'd have to calibrate each unit to its clock performance.

I guess it depends on how accurate you want to be and what other mechanisms affect Fosc.

Presumably if you wanted to be accurate you'd buy a temp sensor so maybe this would work?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Presumably if you wanted to be accurate you'd buy a temp sensor so maybe this would work?

Or go for the middle of the road accuracy, and use an AVR with an internal temp sensor...

Still, an interesting experiment Bob has performed.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vcc variations affect Osc?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah, the graphs show osc vs temp, and osc vs vcc, but I have a good solid 5V vcc, just need to know the temp. How about someone compile it and run it and tell us if it spits out the right temperature?

Imagecraft compiler user

Last Edited: Sat. Sep 19, 2009 - 07:11 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I once tested an ATMega13 by cycling the temperature and measuring the frequency output from a timer pin.

ATMega 13 use internal "calibrated" RC osc to run, it has no X-tal oscillator.

The temperature range was 6 to 29.7 degree C and the frequency had a range of 485 to 519 kHz. This test was not very accurate, using cheap tools.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

stevech wrote:
Vcc variations affect Osc?

A lot.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Mega32 (does anyone still use them?) datasheet indicates a nearly flat change between -40 and 0, about -1% from 0 to 40, and another -1% from 40 to 80. That isn't very pronounced.

Now, what clock source is the Mega32 using to determine the change in the internal oscillator? How much that change with the temperature change being measured, and in what direction?

On the other hand, a Mega640 (family) shows about a 5% change over -40 to +80 (in the opposite direction of the Mega32) and no real flat spots. IN ADDITION the watchdog shows about a 10% change >>in the opposite direction<<. Now we are getting somewhere--something to work with, and two clock sources on the same chip, and the watchdog interrupt to compare against.

The Mega164 family (why would anyone use a M32 that is more expensive and has less features?) has the same characteristics as the '640 family.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The automotive parts are much better as far as stability.

VCC does affect the oscillator (and also has a temp co-ff).

You also can't can't count on the co-eff being the same from lot to lot.

Quote:
The Mega32 (does anyone still use them?) datasheet indicates a nearly flat change between -40 and 0, about -1% from 0 to 40, and another -1% from 40 to 80. That isn't very pronounced.
Some of the tinys do this also

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yap yap yap. How about someone stick this program in a chip and tell us if the temperature it reports seems about right?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

yap yap yap.

I'm sure glad that I spend a number of minutes to research my answer above.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.