ATtiny24V - temperature measurement

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

Hello All,

I am pretty new to using Atmel devices and this is only my second small project so please bear with me. I'm curently using an ATtiny24V and I want to use the onboard temperature measurement.

I am already using the ADC to measure a few voltages in the circuit and it 'appears' to work perfectly - wheee :) However, while the temp measurement does respond to the temperature of the IC, it is wildly effected by the supply voltage. As I am measuring the supply voltage I could always build in a fudge factor and take it out in S/W, but I'd rather know if I am screwing up the temp measurement and fix it properly.

I am selecting the int 1v1 ref, could it be that ADC8 is differential ? Anyway the relevant bit of test code is :

*****

ADMUX = 0xA2; // 10 10 0010
// ADC ip of temperature x1 + (1v1 int ADC_Vref_def)

ADCSRA |= (1<<ADEN)|(1<<ADSC);
// Turn on ADC cct + start conversion

while((ADCSRA & 1<<ADSC) !=0){};
//wait for conv complete

ADC_data = ADCL;
ADC_data |= (ADCH<<8 );
// done seperately to ensure that ADCL always read first

ADCSRA &= ~(1<<ADEN);
// clear enable ADC bit

****

Any thoughts + suggestions greatly appreciated.

All the best

Dren

<º))))><

I am only one lab accident away from becoming a super villain.

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

Two things:

1) You enable the ADC, do a conversion, save the result and disable the ADC. It is however recommended to throw away the first conversion after the ADC is enabled, as the result may be inaccurate. So, enable the ADC, do a dummy conversion and just ignore the result. Then do a "real" conversion. If you leave the ADC enabled between conversions, you need to do this only before the first conversion. If you disable the ADC between each conversion, you should do a dummy conversion every time.

2) None of the ADPS bits (in ADCSRA) is set, meaning that the ADC clock is half the main clock. Which again means that this setting is suitable only for main clocks in the range 100-400kHz (the ADC clock should be between 50-200kHz to achieve maximum resolution). So, unless you're really running the MCU at a quite low frequency, you should probably use a higher ADC clock prescaler.

All this is relevant whenever using the ADC, but inaccuracies may be more noticable when doing temperature measurements. Since 1LSB corresponds more or less to 1 degree celsius, small variations in voltage correspond to significant variations in temperature readings.

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

Hey thanks,

I had already tried (1)(doing the dummy read) but it didn't seem to improve the temp measurement dependance on the voltage.

(2) Is something for me to try, as I'm running from the int 8MHz osc and not dividing it down - oops ! Excellent - I'll give that a go this afternoon.

(3) Hmm, it seems a bit too dependant on the supply voltage. Though as I measure the voltage I can come up with a 'frig' to correct it out.

I'll try putting the the dummy read back + clocking the ADC a tad slower than 4MHz !

Thanks again for your suggestions - I'll let you know what happens

<º))))><

I am only one lab accident away from becoming a super villain.

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

Hey hey hey - it's working !

The dummy conversion didn't seem to make any difference to the measurement (but I've left it in to be safe). Changing the clock to div 1/128 (I'm in no rush) now means that the temp measurement appears to be independant of the supply voltage... it's nice and stable too.

Thanks so much for taking the time - you've cracked it !

<º))))><

I am only one lab accident away from becoming a super villain.

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

That's good. I've never gotten around to test the onboard temperature sensor, but it seems like a useful thing to have around.

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

You should be aware that the on-chip temp sensor will be a LITTLE bit warmer than ambient. Whether or not this is an issue for you is up to you.

This temperature rise is directly proportional to on-chip power consumption. So, anything you do to reduce one will improve the other. For example, if you run it at 4MHz instead of 8MHz, you halve the power consumption and (approximately) halve the temperature rise. Running the processor most of the time in one of the low power modes also reduces power consumption and temperature rise.

Jim

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

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

Its a good point about the ambient temp, MPU temp vs MPU speed.

I was just looking for a ballpark temperature, which is a good job given that the data sheet says it's something like +/-10C ambient after one point of calibration.

Anyway, that bit works (allbeit crudely) and it's onto the next problem.

Thanks for all help / suggestions

Dren

<º))))><

I am only one lab accident away from becoming a super villain.