Arduino Uno - What is the purpose of capacitor C5?

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
elin05
 
Posts: 78
Joined: Tue Jun 11, 2013 4:27 pm

Arduino Uno - What is the purpose of capacitor C5?

Post by elin05 »

http://arduino.cc/en/uploads/Main/Ardui ... ematic.pdf

The cap in question sits between pin 13 on the ATMega16U2 and the reset pin on the ATMega328P.

User avatar
easternstargeek
 
Posts: 347
Joined: Mon Dec 13, 2010 1:39 pm

Re: Arduino Uno - What is the purpose of capacitor C5?

Post by easternstargeek »

C5 couples the transition of the '1602 CTS line (high to low) to the '328P's /RESET input.

Resetting the '328P remotely via the CTS is the way the Arduino Bootloader is activated so that you can load sketches from the Arduino IDE. When communications are first established, the CTS line is toggled in order to trigger a reset.

C5 is necessary because the CTS will remain LOW for a longer period of time than would be desirable to hold the '328P in a reset state.
The capacitor will pass only the edges of the signal so that the reset only happens at the moment the CTS output goes low.

We all learned that "Only AC can pass through a capacitor" but that's an overly simplistic explanation. A more accurate picture of what happens in a case like this is the following:

i = C*dv/dt, where i is the current flowing through the capacitor, C is the capacitance and dv/dt is an expression that describes the time rate-of-change of the voltage across the capacitor. You also have to consider another property, which is q=C*V.

In plain English, if a capacitor is less than fully charged, and a voltage is impressed across it through a resistance, a current will flow through it, but that current will decrease as the capacitor "fills up." When it can hold no more charge, the current will fall to zero.

In the case of this reset circuit, the empty capacitor presents a very low impedance (practically a short-circuit) that "pulls down" the logic level of the '328P reset input for a few milliseconds until the cap charges through the pull-up resistor on the reset input. When the CTS line goes back to the HIGH state, the capacitor will discharge through the pullup resistor, readying it for the next falling edge of CTS.

If you want to learn more about the math behind the inner workings of capacitors, you can start here:
https://en.wikipedia.org/wiki/Capacitance

User avatar
elin05
 
Posts: 78
Joined: Tue Jun 11, 2013 4:27 pm

Re: Arduino Uno - What is the purpose of capacitor C5?

Post by elin05 »

Thanks for the reply!

After some additional research, this is the explanation that I understand best:

The voltage across a capacitor cannot change instantaneously.

So, assuming the voltage across the cap is initially 0V (5V on CTS and 5V on RESET), when CTS drops to 0V, RESET must drop to 0V as well to prevent a discontinuity in voltage across the cap. RESET then charges back up smoothly to 5V via the pull-up resistor. However, this brings up two more questions:

1.) When CTS goes from 0V to 5V, RESET should jump up momentarily to 10V. Wouldn't this damage the 5V supply and/or the RESET pin?
2.) More of an observation: RESET is only pulled down very briefly (you say on the order of milliseconds). I'm surprised this short pulse is long enough to trigger the reset pin

User avatar
easternstargeek
 
Posts: 347
Joined: Mon Dec 13, 2010 1:39 pm

Re: Arduino Uno - What is the purpose of capacitor C5?

Post by easternstargeek »

When CTS goes from 0V to 5V, RESET should jump up momentarily to 10V. Wouldn't this damage the 5V supply and/or the RESET pin?
The reset voltage will indeed do that, at least at first. A better design would be to add a clamp diode between the reset input and +5V, Cathode to +5V.
More of an observation: RESET is only pulled down very briefly (you say on the order of milliseconds). I'm surprised this short pulse is long enough to trigger the reset pin
That's why Data Sheets are our friend! The Reset pulse-width requirement is published by Atmel.

User avatar
elin05
 
Posts: 78
Joined: Tue Jun 11, 2013 4:27 pm

Re: Arduino Uno - What is the purpose of capacitor C5?

Post by elin05 »

I was going to create a new thread for this question, but you've been a great help so I hope you don't mind me asking it here:

What purpose do resistors RN4A and RN4B serve? They connect the serial TX/RX between the 8U2 and the 328P. (http://arduino.cc/en/uploads/Main/ardui ... ematic.pdf)

Thanks!

User avatar
easternstargeek
 
Posts: 347
Joined: Mon Dec 13, 2010 1:39 pm

Re: Arduino Uno - What is the purpose of capacitor C5?

Post by easternstargeek »

The resistors are used to couple the two UARTS together in such a way that the one in the 16U2 won't be damaged if one chooses to use the IO-0 and IO-1 terminals of the '328 for other purposes than communicating to the 16U2.

This is because the outputs at the pins of both chips are of a totem-pole configuration. If you tied two together without such a resistor, a direct short across the power supply rails will occur if the two outputs happen to be in opposite logical states.

Similarly, an externally applied signal to IO-0 or IO-1 could get pulled-up or pulled-down by the 16U2 without the resistor. Even if the 16U2 pins went to a tri-state high-impedance state when not in use, it would still be smart to include protection in case someone accidentally left something connected to the pins when the UART becomes active. The resistors are probably more for goof-proofing than anything else.

Thou shalt never connect two totem-pole outputs directly together!
Last edited by easternstargeek on Tue Aug 13, 2013 2:51 pm, edited 1 time in total.

User avatar
elin05
 
Posts: 78
Joined: Tue Jun 11, 2013 4:27 pm

Re: Arduino Uno - What is the purpose of capacitor C5?

Post by elin05 »

I see. Does that mean it might be more difficult to drive circuits - say, an LED (w/ current-limiting resistor) - using the IO-0 and IO-1 pins, since RN4A/RN4B could be diverting some of the current? Similar to how Arduino UNO pin D13 is more difficult to drive with because of the attached LED?

User avatar
easternstargeek
 
Posts: 347
Joined: Mon Dec 13, 2010 1:39 pm

Re: Arduino Uno - What is the purpose of capacitor C5?

Post by easternstargeek »

Probably not. Under worst-case conditions, (a pin on the 16U2 in an opposite state as the '328) the 1K resistor will sink less than 5mA from the sourcing pin, which should leave enough left over to drive an LED. Many modern LEDS can be driven to blinding intensity with less than 10mA, and the '328 can safely sink or source 30mA.

The problem with D13 is when it is used as an input. If you either activate the internal pullup or use an external one, it will feed the LED circuit, making it light dimly. Chances are, the LED circuit will also hold the logic state to LOW, depending on the value of the Pullup.

A similar phenomenon can happen if you are trying to use D0 as an input, if the 16U2 TXD happens to be LOW, especially if your pullup is greater than 2K or so. Most folks use 4.7K to 10K pullups, so that can cause some mischief.

I believe, however, that the 16U2 TXD goes to a high-impedance state when the UART is not being used, so in that case, it shouldn't matter. At least, if there were to be a contention, nothing will get hurt, even if it doesn't behave the way you expect it to.

User avatar
westfw
 
Posts: 2008
Joined: Fri Apr 27, 2007 1:01 pm

Re: Arduino Uno - What is the purpose of capacitor C5?

Post by westfw »

if the 16U2 TXD happens to be LOW
Note that the standard for "async serial communications" leaves the transmitter signals HIGH when "idle." (at the logic-level. If you have an rs232 driver, there is an additional level of inversion.)

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”