Understand ground and ceramic non polarized capacitor

simulate this circuit – Schematic created using CircuitLab

I'm trying to learn some basics of electronics. I want to build a circuit for my raspberry with main components to use in programming.

An LED, a button and an analog thermistor reading and an analog photoresistor reading , all controlled separately. I learn on the Falstad website but I do not understand the flow of current between the two unpolarized capacitors and the ground on my schematic and I do not know if my schematic is good or not. I do not know if the current can charge (from the ground) non-polarized capacitors. I also have a negative voltage on OUT (GPIO18) when I simulate GPIO states and I do not understand why the voltage is negative when I unload and read the value for this pin and not for OUT (GPIO04) from my low electronic level. I'm learning analog reading with this site: building-raspberry-controllers-pi-part-5-read-analog-data-with-a-rpi. So, yes, to solve my problem, I can simply separate all the parts with its own ground but this will use an extra pin for 'ground' or '0V' and I want to understand my current schema.

I suppose with polarized electrolytic capacitors the current could not 'go up' but here the allaboutcircuit site advocates non-polarized ceramic capacitors.Can I use the same ground pin for my two analog reading pins? What's happening on the two capacitors and ground when, for example, one LED is in HIGH state ... Any help is welcome. Thank you

• What are the white symbols that look like a strange switch on each 'out'? – Transistor May 1 '19 at 20:50
• A simple switch ... not really necessary I grant you. (I put this because one pin take two states) – Ephemeral May 1 '19 at 20:51
• You've managed to put the article link text into both the displayed text and the link. It's broken. I think your diagram would be a lot clearer without the switches and changing the labels to IN4, OUT3, etc. At the moment it's hard to tell what you are doing and what you are asking. What are the two circles at the bottom? – Transistor May 1 '19 at 20:54
• You can add a clearer schematic using standard symbols using the CircuitLab button on the editor toolbar. Double-click a component to edit its properties. 'R' = rotate, 'H' = horizontal flip. 'V' = vertical flip. Note that when you use the CircuitLab button on the editor toolbar an editable schematic is saved in your post. That makes it easy for us to copy and edit in our answers. You don't need a CircuitLab account, no screengrabs, no image uploads, no background grid. Use a SPDT switch to switch between GND and 3.3 V. – Transistor May 1 '19 at 20:56
• Polarized capacitors do not block current depending on the polarity of the applied DC voltage. They are called "polarized capacitors" because if you connect them with the wrong polarity they die. You seem to be imagining them as some kind of combination of diode and capacitor. – JRE May 1 '19 at 21:52

The truth is that the current is always flowing in the closed loop path. Which means that what's "left" (leave) the positive terminal of a voltage source must return to the negative one.

And if we have more devices connected to the same voltage source the same is true.

The blue current $$\I_1\$$ mus be equal to the sum of individual currents ($$\I_2\$$ and $$\I_3\$$).

Now the Ground We can pick any point on the circuit and call it the ground potential. We can then reference the electric potential (the Voltage) at every point in the circuit with respect to this ground potential.

How to find Voltage based on reference nodes?

Therefore, for example, if we have this circuit:

As you can see I simplified the schematic by placing the ground symbol at each device terminal.

Note that all terminals connected to ground are likewise connected to each other. But we do not show this connection "directly" on a schematic.

Now we can try to analyze your circuit.

The capacitor charging current is flowing in this way:

And during the charging phase, the capacitor voltage is rising from 0V to 3.3V.

And now during the discharge phase at the beginning, the capacitor voltage is 3.3V, so now the capacitor will act just like a voltage source. And we connect this voltage (the capacitor voltage) directly across $$\1k\Omega\$$ resistor. And discharge current will start to flow.

And each individual current from another part of a circuit will do not affect each other despite the common ground connection. The ground current will be simply the sum of each individual current from another part of a circuit.

• Thank you very much for all this information that I read carefully, I read the information of everyone and try to answer little by little. I thank you again for your help. – Ephemeral May 1 '19 at 22:48
• Excuse me, I think finally understand the beginning part but I don't understand the last picture and how and why the current start from (1st) ground go trough the capacitor and then go to my 0v (or ground) GPIO INPUT pin ... I known electrons flow is the inverse of conventional flow of current If I learn correctly on Internet, Would there be a link ? – Ephemeral May 1 '19 at 22:57
• Just before the discharge phase begins, you set you GPIO pin as an output pin with a low state (GND = 0V) at the output. / GPIO.setup(b_pin, GPIO.OUT) GPIO.output(b_pin, False) / – G36 May 1 '19 at 23:04
• The 100nF was previously charged to 3.3V. And now during the discharge phase, the capacitor itself provide this 3.3V across the 1k resistor hence the current can flow in the direction I drew (from + to - , conventional flow). – G36 May 1 '19 at 23:13
• Thank you, Yes but the capacitor is charged to positive (plan?) , have isolator, and other plan (negatively charged) and connected to the ground ? 0V (GND) to 0V (CAP) if I understand but then I don't understand why your arrow start from GND go trough cap plan (negative), pass trough the cap and go to GPIO INPUT. It is just a representation , ground charge the plan to negative and nothing happens current level because even potential? – Ephemeral May 1 '19 at 23:15

The basic idea is very simple: we're going to see how long how long it takes to charge up a fixed capacitor through a resistance whose value changes with incident light or temperature.

• C will be discharged initially.
• When the charging pin is switched high C will charge at a rate determined by RC (where R is the sum of R1 and the photoresistor). After RC s it will have charged to 63% of the supply voltage.
• The discharge pin, meanwhile, is configured as an input and is monitoring the voltage on C. (R3 doesn't affect this because as an input the pin is drawing negligible current.)
• The logic 1 threshold voltage of the input pin will be about 2/3 supply and this fits nicely with our RC time constant at 63%. When the pin detects the '1' the measurement counter can now stop.
• At some stage we'll need to reset the circuit and discharge C. To do this we'll reconfigure the discharge pin as an output, switch it low (0 V) and give enough time for C1 to discharge through R3. R3 limits the current to a safe value - 5 mA max on a 5 V supply - so that we don't damage the GPIO. We would need to allow 5RC (where R is 1k this time) to discharge by 99% from the peak voltage.
• Once discharge is complete we can disable the output, switch it back to an input and start all over again.

I do not know if the current can charge (from the ground) non-polarized capacitors.

They're probably recommending non-polarized capacitors as these can be more stable and tighter tolerance than electrolytics. Also, electrolytics don't come in < 1 μF usually.

I also have a negative voltage on OUT (GPIO18) when I simulate GPIO states ...

You should never see negative voltages with this circuit. (GND is zero, not negative.)

... and I do not understand why the voltage is negative when I unload and read the value for this pin and not for OUT (GPIO04).

This part isn't clear.

Let's look at a quick simulation. (You can copy it into your question to try it out in CircuitLab's simulator.)

simulate this circuit – Schematic created using CircuitLab

Figure 1. A simplified schematic. Here Q1 is simulating the discharge function.

Figure 2. Note the slow charge and the rapid discharge of the capacitor.

Note that in Figure 2 that the capacitor never discharges fully. This is because the GPIO_OUT is always at 5 V in my simulation so it is charging C1 while DISCH is discharging it.

• Thank's you very much, I work around your answer and I go back. – Ephemeral May 1 '19 at 22:31
• For negative voltage, either it was an error on my part or it was a bug in the falstad site. sorry for that. – Ephemeral May 1 '19 at 23:09
• That is not a 🐜 on Falstad’s site. It computes exactly what you see simulated there. If you export the link , you can paste the tiny URL here or save as a TXT file for future personal use or use the full URL in your question I can explain. Don’t worry about uV undershoots. – Tony Stewart EE75 May 2 '19 at 6:21

The capacitors you have in your schematic diagram (non-polarized 100nF) are fine.

This (crude) analog to digital converter doesn't depend on anything you would need a polarized capacitor for.

Polarized capacitors aren't some kind of combination of diode and capacitor. They don't block current flow depending on the polarity of the applied DC voltage. They block DC in general (just like all capacitors.) Due to a necessity of making large capacitors in small volumes, polarized capacitors can't withstand long term DC in a particular direction. They die if used backwards. In some cases violently. Tantalum capacitors in particular tend to die spectacularly (bang and flames.)

So, your non-polarized capacitors are fine.

The "direction of flow of current" where all your gadgets come together is the same for all of them - the current flows to ground.

Don't drive your LEDs that way. Would you rather save a couple of cents on a transistor and a resistor to do it right, or would you rather have to replace the Pi because you abused its GPIO pins?

The Pi isn't designed to drive loads directly. It is meant to generate control signals.

• Thank's you very much, I work around your answer and I go back. – Ephemeral May 1 '19 at 22:31
• Thank you again for all these very helpful explanations. I have NPN and PNP transistor on hand and many other active and passive components but sorry, I do not see how to use them for now or how to apply your theory by replacing my GPIO ports with transistors. I specify that I want to control each part of my module with their own pin to then be able to program a simple application for beginners like me, to control a green led if need (success), a red led (error), an analog input to read the temperature and an analog input to read the number of lumens. – Ephemeral May 1 '19 at 22:45
• Here is an example of driving LEDs with the Pi. Look at the answers, not the question - the answers do it right, the question got it wrong. The principle is the same whether you use one LED or several in series. Use one LED, and connect to 3.3V instead of 9V. – JRE May 1 '19 at 22:50
• Thank you for that and for your time. – Ephemeral May 1 '19 at 22:51
• That's why we have all these questions and answers - so we can point people at them and say "thataway." – JRE May 1 '19 at 22:53