# Computing stuff tied to the physical world

## Easy Electrons – Diodes

In Hardware on Jan 9, 2011 at 00:01

It’s time for some Easy Electrons again.

Semiconductors are at the heart of today’s electronics designs: diodes, transistors, and the huge advances made possible by Integrated Circuits (i.e. IC’s) is what makes all those electronic devices around us possible. And it all happened in the time scale of just a few decades…

I can’t possibly cover everything in this series, so I’ll cover the two most common ones for now: the diode today, and the “normal” (BJT) transistor in the next installment.

Very roughly speaking, a diode is a one-way conductor. This is also indicated by the schematic symbol used for diodes (image from Wikipedia):

The arrow-like symbol points in the direction of the current flow, if you stick with the convention that current flows from “+” to “—”. If you keep forgetting which side is called the Anode and which the Cathode, this trick might help: in the alphabet, we (eh, I mean currents) go from A (to B) to C.

Diodes are useful to protect a circuit against connecting a power source the wrong way around (we’ve all been there, right?):

With this diode, the circuit is protected. Hooked up the wrong way, the diode will block, so no current will flow through the circuit.

But diodes aren’t perfect. There’s a voltage drop when conducting current, usually around 0.7V. So with the above circuit, if the power supply is 5.0V, then the circuit will only get about 4.3V. With low-voltage components, and especially battery-powered devices, this sort of voltage loss is awkward – and often unacceptable.

Which is why you won’t see this reverse voltage protection very often in circuits operating at 5V, 3.3V, or less. There is another type of protection, however:

This one is a bit nasty. It doesn’t really prevent the circuit from getting a reversed voltage at all. Instead, it will act (almost) like a short circuit when the voltage is applied the wrong way around. The idea being that this will cause the power supply to shut down (or the battery to drain very quickly). The RBBB uses this type of protection to overcome the voltage drop problem. The (cheap) diode will protect the (much more valuable) ATmega, as well as all other components hooked up to it.

This sort of protection is tricky. If you were to connect a LiPo battery, for example, then the short circuit can cause HUGE currents to flow, since many LiPo’s are able to supply them. Think many Amps… and now something else may happen: even if the diode can handle the current, the rest of the power lines might well become overloaded. Especially thin copper traces on a PCB are likely to act like a fuse and simply… evaporate!

There are other ways to deal with the voltage drop and still end up with diode protection. One of them is to minimize the voltage drop – this is where Schottky diodes can be useful. They usually have only half the voltage drop of normal diodes, i.e. around 0.3V. That might just be low enough for your particular setup.

Another option is to build an “ideal diode”. This might sound like an impossible task, given the properties of diodes, but there is actually a way to do this using a MOSFET. I won’t go into MOSFETs here, but basically they can switch current while having almost no resistance and (Ohm’s law!) therefore also almost no voltage drop. Trouble is: MOSFETs don’t know which way the current is flowing, so you need considerable extra circuitry to tell them when to turn on and off, based on comparing voltages on both ends. And although it is not a simple or cheap solution, this datasheet of the LTC4413 chip shows that it is indeed possible to beat the diode characteristics with some clever engineering. Electronics is often like that: people have come up with the most amazing tricks to overcome certain drawbacks, for all sorts of electronic circuit tasks. That’s why it’s so much fun just exploring and discovering it all, IMO :)

The graph of what a diode does is very characteristic: in reverse mode it blocks, and in forward mode (i.e. above around 0.7V) it conducts, albeit not perfectly. For some good example graphs see this page on Wikipedia (just skip the math formulas and look at the pretty pictures).

Now, assuming the voltage drop is no problem, because you’ve got some extra volts from the power supply anyway, then diodes can be extremely useful. The bridge rectifier for example, can be used to get a properly polarized voltage out, regardless of how the power supply is hooked up. This is particularly useful with alternating current, as present on the AC mains lines and on the coils of a transformer (a lot more Easy Electrons articles will be needed to present all this stuff!).

Another interesting diode is the Zener diode. It’s like a regular diode, but one which can’t support a very high reverse voltage. With Zeners, this voltage is called the “breakdown voltage”, and it ranges from about 2..200V. The value is fixed for any particular model.

Zener diodes make very simple (low-current) regulated power supplies:

Note how we’re putting the Zener in reverse mode, and counting on it to break down. As it does, current will start to flow. Until enough current is flowing across the resistor (Ohm’s law!) to take up all the “remaining” voltage.

So with a resistor of 100 Ω, and a Zener of 5.0V, we could power it with say 6..9V. At 6V, the current would be (6 – 5) / 100 = 10 mA. At 9V, the current would stabilize at (9 – 5) / 100 = 40 mA.

The reason this can be used as a regulated power supply, is that we can connect our circuit in parallel with the Zener, and it would always get 5V. The only drawback is that we can’t draw more than 10 mA from it:

• at 6V, the resistor needs to “eat” 1V, so that the Zener ends up with 5V
• if the circuit draws 10 mA, then 0 mA will go through the Zener
• if the circuit draws 5 mA, then 5 mA will go through the Zener
• if the circuit draws 0 mA, then 10 mA will go through the Zener
• at 9V, the current will increase to 40 mA (to get 4V over the resistor)
• in all cases, the circuit will see a 5V input voltage

Cool, so now we have built ourselves a simple regulated power supply!

As I mentioned, this circuit is not very powerful. If we draw more than 10 mA, then the voltage drop over the resistor may increase, leaving less than 5V for our circuit.

There is another drawback with the above regulated supply: it’s grossly inefficient. The reason is that it will always draw 10 mA, whether our circuit needs it or not. And that’s at 6V – at 9V it will always draw 40 mA!

I’ll show you how a transistor can easily increase the current and improve the regulating efficiency in a future installment. Exploring these simple electronic circuits can be great fun, and most of the time you can reason your way through without even having to build them!

Next time: transistors – incredibly useful devices, with tons of ways to use ’em!

PS. Does anyone have tips on how to improve these diagrams? I really want to continue drawing them by hand, but the texts don’t come out very nice, no matter what I try!

1. Dutch trick for +/-: KNAP: Kathode Negatief Anode Positief.

• That works perfectly well in English too, especially with my spelling :o)

I used to remember it as Cathode – Cold Anode – Arrrrrggggh!

:-)

2. With regard to the parallel diode reverse protection, that’s usually combined with a suitable size fuse so the fuse pops before the diode and PCB tracks melt.

maybe use comix-balloons with a number in them and put the text in the article itself ?

consider using Fritzing; it has bread-board and schematics. but it is a lot more work than drawing by hand; have a look at http://fritzing.org/

yet another option : drag/drop the texts onto the schematic when the drawing is already a GIF/JPG. almost any tools can do that.

4. I know this is a posting about diodes, not MOSFETs, but I thought it worth noting that in many cases, a MOSFET can be used as reverse voltage protection with no additional circuitry.

In place of the series diode, use a P-channel MOSFET with the drain connected to the positive voltage, the source connected to the load, and the gate connected to ground. The MOSFET has a built-in body diode and will initially behave just like the series diode: current will flow, but the voltage will drop by the forward voltage of the diode. If the voltage at the source terminal of the MOSFET exceeds the Gate-Source threshhold voltage of the MOSFET, then the MOSFET will turn on, and current will now flow with almost no voltage drop. If you hook up the battery backwards, no current will flow, since the body diode is reverse biased and the gate voltage exceeds the source voltage. Used in this manner, the MOSFET does in fact know which way the current is flowing.

For example, assume a P-channel MOSFET with a diode forward voltage drop of 0.8 volts and a Gate-Source threshhold voltage of 1.5 volts. If you connect a 3.3 volt supply, the load will initially receive 2.5 volts. But since the 2.5 volts at the source terminal of the MOSFET exceeds the voltage at the gate (zero volts) by more than 1.5 volts, the MOSFET will turn on almost instantly, which effectively shorts out the body diode and now provides almost the entire 3.3 volts to the load. The only remaining voltage loss is the current through the load times the Drain-Source resistance when the MOSFET is turned on. For example, if the load draws 200 milliamps and the MOSFET has an RDSon of 0.1 ohms, then the voltage drop over the MOSFET will be a measly 0.02 volts. The key, therefore, is to select a MOSFET with a low threshhold voltage (e.g., 1.5 volts) and a low Drain-Source resistance when on. The technique should work as long as the supply voltage exceeds the sum of the Drain-Source forward voltage and the Gate-Source threshhold voltage; in other words, for supply voltages above roughly 2.5 volts. Below that, you need something fancier.

There is a brief write-up on this technique (with diagrams) here:

http://focus.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=SLVA139&fileType=pdf

P.S. As you will see from the link above, you can also do this with an N-channel MOSFET in the ground return line. But that is often less convenient.

• Fantastic info – thank you!