ATTiny861A Analog Reference

Hi, I'm using the ATTiny861A for a battery voltage measurement system. My power source for the ATTiny chip is the battery itself. I have used voltage dividers to drop down the voltages within my range (I am measuring solar panel voltages too which are more than my battery voltage). I have made calculations in my program regarding the ADC values as 2.56 VREF for the ADC since the datasheet says 2.56 is available for internal ADC Reference voltage.

My questions:

  1. Is using analogReference(INTERNAL2V56); enough from my software to set it as 2.56 internal reference?
  2. I have my AREF pin (PB3) configured as a digital output pin, will that be a problem or since this is internal reference voltage, it will be alright?
  3. I have my AVCC tied up to my normal VCC and AGND to normal GND. Is that fine?

Snippet of my schematic:



upld.PNG

Are you using a resistor divider to power the ATTiny? You should never do that, use a proper regulator instead.
Your schematic is missing too many details to be helpful. It is missing the decoupling caps, it doesn't show how any of the pins are actually connected.
What Tiny core are you using? That will determine how you set up the internal reference for the ADC.

BJHenry:
Are you using a resistor divider to power the ATTiny? You should never do that, use a proper regulator instead.
Your schematic is missing too many details to be helpful. It is missing the decoupling caps, it doesn't show how any of the pins are actually connected.
What Tiny core are you using? That will determine how you set up the internal reference for the ADC.

No, I am not using a reistor divider or a regulator. My battery voltage fluctuates from 3.2-3.7V, ATTiny861A can work well at those ranges.

Decoupling caps, yes I seem to have missed that while designing. Also, i regret that I cannot share the entire schematic due to some privacy issues. Please let me know if there are certain parts which you'd like to check

I am using this particular core: GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8

Thank you for the response.

Mahip_KC:
No, I am not using a reistor divider or a regulator. My battery voltage fluctuates from 3.2-3.7V, ATTiny861A can work well at those ranges.

Gotcha, that should work fine then. I assume you're planning on using the internal 8MHz resonator?

Mahip_KC:
Decoupling caps, yes I seem to have missed that while designing. Also, i regret that I cannot share the entire schematic due to some privacy issues. Please let me know if there are certain parts which you'd like to check

No worries, I just won't be able to give too much help with anything I can't see.

Mahip_KC:
I am using this particular core: GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8

Great. Since you still want to use the AREF pin as an output you'll need to use the INTERNAL2V56_NO_CAP option so that you don't have to use an external decoupling capacitor on AREF.

BJHenry:
Gotcha, that should work fine then. I assume you're planning on using the internal 8MHz resonator?
No worries, I just won't be able to give too much help with anything I can't see.

I actually have an external XTAL connected as shown in the snippet.

Is 100nF decoupling fine for VCC& GND? It says so in different forums.

BJHenry:
Great. Since you still want to use the AREF pin as an output you'll need to use the INTERNAL2V56_NO_CAP option so that you don't have to use an external decoupling capacitor on AREF.

Got it! I'll try that now. So, AVCC is tied up to my VCC (Battery). AGND is tied with normal GND. AREF can be used as a GPIO pin after setting INTERNAL2V56_NO_CAP in the analogReference();. Did I miss anything?

upld.PNG

Mahip_KC:
Is 100nF decoupling fine for VCC& GND? It says so in different forums.

Absolutely, 100nF for each VCC and AVCC pin, as close to the pins as possible.

Mahip_KC:
Got it! I'll try that now. So, AVCC is tied up to my VCC (Battery). AGND is tied with normal GND. AREF can be used as a GPIO pin after setting INTERNAL2V56_NO_CAP in the analogReference();. Did I miss anything?

Nope, that should do it.

Great! Will update on this.

Nope, Can't get any logic clearly. Set the de-coups, checked the program, checked whether the chip is working or not. Checked if the XTAL is working or not. All seem to be good. Just the ADC isn't working as of now. Using this test code.

ADC_Test_Emsys.ino (485 Bytes)

Please check the 'How To Use This Forum' sticky to see how to post code properly so that we can all see it.

This may also be an option for measuring the voltage at VCC...
https://forum.arduino.cc/index.php?topic=38119.0