1
\$\begingroup\$

I am using Atmega328P to read temperature from LM35 and display it on the LCD (along with few several things it does).

I want to understand the capacitor and connections for the AVR itself and AVcc.

I read stuff online, about decoupling, bursts, under-power and such, but I did not understand what I should connect to do it right.

Some said I need to connect 10uF electrolytic cap to Vcc and ground, and to AVcc and ground.

Others said I need to connect ceramic 0.1uF to Vcc and GND and AVcc and GND. Some said both.

I am confused, really confused :)

Also, I am starting to think I need to recheck my LM1117 3.3V regulator caps, I am using 2 10uF caps (Input V and GND, and 3.3V and GND).

Can you help please?

\$\endgroup\$
  • \$\begingroup\$ I'm also confused. Do you need help with understanding how to properly decouple and filter your AVcc and Vcc? Are you also having problem reading your LM35? \$\endgroup\$ – Dejvid_no1 Apr 8 '14 at 19:51
  • \$\begingroup\$ It looks like the LM35 reading a bit low than the actual temperature, But I also want to understand the capacitors needs and what is needed to get better "guerd" of the AVR and ADC stable reading.. Thanks. \$\endgroup\$ – gabi Apr 8 '14 at 20:00
  • \$\begingroup\$ follow manufacturer guidelines.....there are lots of app notes regarding decoupling capacitor selection and placement in web... \$\endgroup\$ – user19579 Apr 9 '14 at 5:22
4
\$\begingroup\$

I will first talk about decoupling capacitors, and then specifically the options the Atmel 328P has for it's AVCC and AREF pins.

Decoupling capacitors are used to provide short bursts of energy during digital switching circuits (they go from zero to full voltage in a very short amount of time, they need energy and available current source nearby to do this) and as a general value everybody just puts 100nF (0.1uF) capacitors at the power pins of every single IC used in their boards. This is a safe and good strategy. It is not, however, strictly needed unless your system is large and complex. If you have a regulator (with it's own capacitors) very close to your Atmega you will be fine with out them.

Your regulator is fine with a 10uF capacitor on the input and output, you do not need to change those. In the future though, you should ALWAYS consult your regulator's datasheet. Some regulators cannot use high "ESR" capacitors as they can cause unstable operation, and likewise some regulators cannot handle ultra-low ESR capacitors like Ceramic capacitors because they will "ring" and ripple uncontrollably (overshoot constantly) among other hilarious power control system challenges.

AVCC is the analog voltage supply used internally by the ADC and is most commonly internally connected to the AREF pin, used directly as the reference for ADC readings. You can either filter and decouple AREF, or VCC, but the one that matters most depends on what you actually want for your ADC. The Atmel328P has internal Vref (2.56V or other ones) you can select, for exampl. You can also provide your own reference voltage at the AREF pin, and other than power supply ripple your AVCC becomes less important in terms of filtering. You might have bought a precision 3V reference IC, and followed it's datasheet guidelines for suggested circuit, and then put the Vout into the AREF pin of the AVR. In this case, AVCC can be left with either:

  • direct connection to VCC
  • or a simple decouple 0.1uF cap to help with local noise filtering
  • with an inductor or ferrite bead in series from VCC into the AVCC for AC current ripples, and if you put a capacitor to ground here as well (AFTER the inductor), it becomes a current AND voltage ripple filter - nice and clean!

AREF could be left unconnected, and merely filter VCC. Often if the AREF pin is un-used and AVCC And AREF are internally connected, you can put a 0.1uF capacitor on the AREF pin, which will have the same effect as putting the capacitor on AVCC due to the internal connection. Maybe this can assist with circuit layout?

If you have a slow, steady state error on your temperature sensor, I bet you it's not related at all to ADC or power supply filtering - I bet that the error is within tolerances given by the datasheet (usually +-15% which is quite a lot!). You almost always need to (usually only once) 'calibrate' your ADC readings by getting a known (working) thermometer at ambient temperature nearby, and adjust the offset of readings to make it line up with expectations. The sensor's rate of change (mV/Degrees celcius) should still be fine, it's just the 'steady state error' inherent to low tolerance manufacturing.

\$\endgroup\$
1
\$\begingroup\$

The left side of the image shows how to interface ATmeaga664. However, the principle is the same for the 328 model, I believe:

enter image description here

If you do not have any other power consumption except your microcontroller, you might not need a 10uF cap. But I would suggest to use both 10uF and 100nF in parallel. I had a similar question here. Notice, that analog AVCC is connected to supply through an inductor. Do not know what it is for. Look at the datasheet, I they might have some examples.

Edit: According to LM1117 the datasheet, there should be a 10uF on the input and the output. Then do so.

\$\endgroup\$
1
\$\begingroup\$

I suggest that you head over to Atmels site and search for their application notes on ADC or power supply considerations. Although application note Atmel AVR32837 is for a totally different CPU it as some explanatory pictures of capacitor values and connections. Application not Atmel AVR042 might be good for you also.

Check your LM35 with a voltmeter and check if it there is a difference with your reading.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.