Attiny2313 Bandgap for VCC ref

I done this before on the 328p but it looks like the registers are different. Has anyone done this on the Attiny2313. The datasheet does say it has the bandgap VCC ref and the Analog Comparator. So this should be possible but none of the examples work. I am using Tiny Core with the Arduino IDE and it doesn't like setting ADMUX.

I found two examples

and this one which I have used before

http://jeelabs.org/2012/05/04/measuring-vcc-via-the-bandgap/

Thanks for the help!

Datasheet for 2313

I would assume it would be the same for the Attiny2313A which I may be using as well.

MobileWill:
http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/

...is not going to work because the t2313 does not have an analog-to-digital converter (with the Tiny Core analogRead always returns zero).

» Measuring VCC via the bandgap » JeeLabs

Ditto.

So is there a way to get the bandgap reading?

After setting the Analog Comparator configuration to use the Bandgap Reference for AIN0, you could adjust the voltage on AIN1 until the comparator tripped. You would need a way to provide an accurate variable voltage to AIN1.

Hmm, I am starting to think I should of just stuck with a 328p.

Uh oh. That doesn't sound good. Does your project require an analog-to-digital converter?

Not really, I just need to get the voltage level. So much easier on the 328p but trying to keep cost down. I could use a voltage divider but then need ADC so then should just use the 328p as the next cheapest option with enough GPIO's.

Op amp? Dual slope converter?

ATtiny 84 ?

Paul__B:
Op amp? Dual slope converter?

Wouldn't that still need an ADC?

Docedison:
ATtiny 84 ?

I thought about it but I need more pins for driving 10 LEDs.

So I was thinking easier to just slap a 328p at the problem lol. The answer to the universe and everything.

84 and 2 TPIC6B595's? high current driver...

Doc

MobileWill:
I thought about it but I need more pins for driving 10 LEDs.

So I was thinking easier to just slap a 328p at the problem lol. The answer to the universe and everything.

It's not a bad thing. All up your BoM will be around the same cost as an ATTiny with additional supporting ICs, and if you only need 8MHz it can run on the internal clock as quickly as an ATTiny85 with a few more pins for whatever your scope-creep can come up with. It's an ATTiny85 with just 20 more legs to solder is all :slight_smile:

Geoff