changing analogReference on ATtiny84

Quick question. I have a sensor whose analog output is less than 1v max, so is it possible to change the analog reference voltage on the ATtiny chips? Having it stuck at 5v doesn't give me very much resolution.

Or should I just use an opamp and do it in hardware?

BTW, I'm using this method to program the Tiny chips with arduino code. http://hlt.media.mit.edu/?p=1695

-Tony

Hi Tony

According to the datasheet you'll find AREF on pin 13 of the ATtiny84.

Cheers ! Geoff

Doh! I thought I looked though that thoroughly, I guess not enough. :blush:

So I can just use a voltage divider to set the voltage on that pin and call analogReference(EXTERNAL) once in the setup of the code?

Thanks

I've done that with success. Be sure to include a 0.1uF bypass capacitor connected to VCC and GND.

[quote author=Coding Badly link=topic=113474.msg853919#msg853919 date=1341855837]

I've done that with success. Be sure to include a 0.1uF bypass capacitor connected to VCC and GND.

[/quote]

Why is that capacitor necessary? I think it'll have one anyway with the 5v regulator.

RacerX89: Why is that capacitor necessary?

Reduce electrical noise within the processor. The analog-to-digital converter in the ATmega328 processor, for example, is internally separated from the rest of the processor which helps to reduce interference from internal sources. The ATtiny processors are not structured that way so other measures, like a bypass capacitor, are, in my experience, more significant and more important.

I think it'll have one anyway with the 5v regulator.

You will not. The capacitors on the regulator serve a different purpose.

In case you have doubts, I refer you to the ATtiny85 datasheet...

17.9 Noise Canceling Techniques ... • Place bypass capacitors as close to VCC and GND pins as possible. ... A good system design with properly placed, external bypass capacitors does reduce the need for using ADC Noise Reduction Mode

Place bypass capacitors as close to VCC and GND pins as possible.

Oh okay gotcha. Thank you for clearing that up. :)

So in the code I just call analogReference(EXTERNAL) in the setup?

In general, yes.

It depends on the core you are using. analogReference in older version of the MIT Core is not implemented correctly.

RacerX89: Quick question. I have a sensor whose analog output is less than 1v max, so is it possible to change the analog reference voltage on the ATtiny chips? Having it stuck at 5v doesn't give me very much resolution.

-Tony

The ATtiny84 has an internal 1.1v reference that would be very appropriate for your sensor.

RacerX89: Doh! I thought I looked though that thoroughly, I guess not enough. :blush:

So I can just use a voltage divider to set the voltage on that pin and call analogReference(EXTERNAL) once in the setup of the code?

Thanks

While you can use a voltage divider (or Vcc for that matter) for an analog reference, it isn't the best solution if you want accurate measurements. Both Vcc and consequently a voltage divider reference will exhibit a lot of noise on the line, which will adversely affect the accuracy of your measurements. You need to decide if that is a problem for your specific needs.