This may be a dumb/begginer question, but I'm having trouble to understand what exactly happens when we connect a real capacitor directly with a battery.
In my understanding, theoretically, when an uncharged capacitor is connected directly to a battery of, let's say, 9 volts, instantly the capacitor will be charged and its voltage will also become 9V. This will happen because there is no resistance between the capacitor and the battery, so the variation of current by time will be infinite. Obviously, this is true when talking about ideal components and non-realistic circuits.
I thought that doing it in real life would cause sparks, damaged components, explosions, or whatever. However, I saw some videos and people usually do connect batteries directly with capacitors. Also, the current that flows from the battery to the capacitor is somehow of low magnitude, since it takes some considerable time to make the capacitor have the same voltage as the battery.
I would like to know why this happens, thanks.
This is an example of the circuit I talked about:
Both the battery and the capacitor have an internal resistance.
Your capacitor looks a bit like this on the inside:
simulate this circuit – Schematic created using CircuitLab
Of course, I don't know your capacitor, so I don't know the exact internal resistance, but 3Ohm will be a close enough approximation.
The same happens in your battery, so in fact you are doing this:
simulate this circuit
So now for a tiny amount of time the current will be maximum, but it is only about 0.9A
Of course when you put a capacitor onto a battery like that, you will not make great contact, so there will be some extra resistance there as well, so it might even be 0.7A.
The reason it now takes time, is that when the capacitor charges, the voltage across the resistors decreases, so the current decreases as well, so the voltage on the capacitor will increase more slowly, and so on and so on, so it will actually approach the battery voltage slower and slower.
The larger the resistors or the capacitors the more time it will take.
The moment it is at 67% can be calculated by R * C.
So in the example that is: t(67%) = R * C = 10 * 220u = 2.2ms.
But if the capacitor is 22000uF (= 22mF) then the RC-time, as it is called, will be 220ms, or 0.22s for it to charge with a total resistance of 10Ohm. But with a capacitor that size it might also have a slightly higher resistance, so that'll make it even slower.
And then it's only at 67%. The next 30% will take much more time.
EDIT: Note; increased the 9V-bat resistance as per Nick's comment.