Monday, June 8, 2009

Electricity for Synth-DIY'ers: Diodes

At this point in the series, we leave the old-school electrical engineers' world of resistors and capacitors and inductors, and begin to delve into semiconductor devices. The word "semiconductor" is somewhat of a misnomer, and over the years it has dragged many EE students down a wrong path; it suggests a material that conducts electricity, just not very well. The truth is, a semiconductor may conduct electricity very well, or not at all, or anything in between -- depending on the circumstances of the moment.

A semiconductor consists of a base material to which a certain amount of an impurity has been added. The pure base material is often an insulator; for example, silicon (still the most common base material for semiconductor devices) is a very good insulator in its pure form. When small amount of impurities such as phosphorous or arsenic are added to silcon, it becomes a semiconductor.

Semiconductor materials are divided into two categories, referred to as positive or P-type, and negative or N-type. There is a temptation to assume that "positive" and "negative" in these definitions mean something like the poles of a battery, where the materials have an indicated electric charge. That is incorrect; P-type and N-type refer to how the two types of materials conduct electricity internally. When they aren't in a working device, P-type and N-type semiconductors are neutral in charge. (I'm not going to go into semiconductor physics here. It's way too big a topic. Maybe later.)


A diode is a semiconductor device that consists of a slab of P-type semiconductor material joined to a slab of N-type material. The interface where the two types of materials join is usually called the junction, and it is what happens at the junction that gives the diode its properties. Basically, any time you join a piece of P-type to a piece of N-type, the junction has a very strong preference to allow current to flow in one direction versus the other. In fact, it acts like a one-way valve for electricity: conventional current will flow from the P-type end to the N-type end, but not (usually) in the other direction. The symbol for a diode in electrical schematics looks like this:

The arrow points in the direction that conventional current will flow through the diode. Here are a few small-signal diodes:

The glass casing is not uncommon in diodes. The band around one end indicates which end is the negative end (where the current comes out). This end is sometimes referred to as the "cathode", a term that got carried over from vacuum-tube techology. (In fact, the word "diode" itself was also borrowed from the vacuum-tube equivalent.)

The first and most obvious use for a diode is as a rectifier, a device that changes alternating currrent into direct current. Power distribution uses the form of alternating current; however, electronics circuits usually require direct current power supplies, so the first place where diodes are generally found will be in the power supply. Here's an example of a very simple, unregulated power supply:

The transformer changes the distribution voltage into the voltage that we need to power our circuit; note that this must take place before the rectification, since transformers don't work on DC. The diode allows only the positive-going half of the AC power to flow through; it blocks the negative-going half. Note that, although the diode removes the negative-going part of the AC waveform, by itself it does not have any means to produce a "smooth" DC output; its output will still look like an AC waveform with the bottom half chopped off. That gets fixed by putting a big capacitor in series with the diode; it stores up current during the positive half of the AC waveform, and releases it during the negative half, to produce a more or less constant DC voltage.

You may have notice the weasel wording in that last sentence. It's "more or less" smooth because the circuit above is only using half of the incoming AC waveform, and the capacitor has to store enough energy to bridge the gaps between the missing halves. This is called a "half-wave" rectifier for this reason. It isn't very efficient, and it is very difficult to prevent this design of power supply from having "ripple" in its output. What we need is a full-wave rectifier that will use both halves of the AC waveform. Here is an improved design with a full-wave rectifier:

Note the four diodes. This is called a "bridge" rectifier, and this is the way it's usually drawn, with the diodes in the diamond shape, to make it easy to spot in a schematic. Follow the directions that the current takes through the positive and negative halves of the incoming AC waveform, and you will see that the bridge not only lets through the positive half, but it also "turns around" the negative half and makes it positive. So this circuit has now filled in the waveform gaps that the half-wave rectifier created. Note that it still doesn't by itself produce a "flat" continuous output, so we still have to have the capacitors to make the output smooth and even. However, it's a lot easier to clean up this output than the half-wave's output. Although the output is still unregulated (output voltage will vary with the input voltage and the load on the output), it's a practical circuit, and in fact, most solid-state audio amplifiers from about 1960 to 1990 used this basic circuit, with a bit of additional filtering.

A similar use for diodes is in protecting circuits against incorrect voltages. For example, a common problem in battery-powered equipment is the user inserting the batteries backwards. A diode, in series with either the positive or negative terminal, will protect the circuit against reverse voltage. Similarly, in a circuit which takes a control voltage of only one polarity (such as the CV input on many VCAs), a diode prevents control voltage of the wrong polarity from causing the circuit to malfunction or damaging components.

Diode Clamp

A neat trick that you can do with a diode and a capacitor is offset an AC waveform so that it stays above or below the axis. It's a simple circuit:

Charge Pumps and Voltage Doublers

If you fully charge a capacitor, the voltage across it becomes equal to the charging voltage. If you can then switch the capacitor to be in series with another charged capacitor or other voltage source, you can achieve a higher output voltage until the capacitor discharges. Here's a trick circuit that, using diodes to do the switching, doubles the voltage of an AC source without using a transformer:

How this circuit works: On the positive half of the AC cycle, the voltage charges the upper capacitor, while the lower capacitor is isolated from the circuit by the diode. On the negative half of the cycle, the charged upper capacitor contributes its voltage to the AC voltage through its diode, while the lower capacitor gets charged. On the next positive-going half cycle, the lower capacitor contributes its voltage, while the upper capacitor gets recharged. The capacitors have to chosen so that they won't completely discharge before the half-cycle ends, in order to get a reasonably smooth waveform.

The concept can be extended to make a voltage tripler, quadrupler, etc.

Diode Drop and Schottky Diodes

We've implied above that a diode will begin to conduct whenever a forward voltage is applied to it. That isn't quite true; inherent in the physics of the P-N junction is a phemonen called diode drop. Basically, what the diode drop does is establish a constant voltage across the diode when current is flowing. If the voltage across the diode is less than the diode drop voltage, then current will not flow even though it is trying to go in the forward direction. The forward voltage must rise to higher than the diode drop before current will flow. Designers have to keep this in mind when designing a diode into a circuit.

The diode drop is a property of the semiconductor base material. For silicon, it is 0.6V. This is why, often, a modern digital multimeter will measure a perfectly good diode as being open -- it doesn't apply enough voltage to the diode to overcome the diode drop. Other types of base material have different diode drops; if you spend time inside of antique radio or certain guitar stomp box circuits, you will probably come across germanium diodes. These have a diode drop of about 0.2V.

You can use the diode drop to derive lower voltages from higher ones. For example, if you have a 5V power supply but need 3.2V for some new-fangled low-power IC, you can derive the voltage you need (assuming the IC doesn't need too much current) like this:

The three diodes in series give a total drop of 1.8V. At this point, you might ask, "what happened to Ohm's Law here? How can the diode always have the right resistance to produce exactly 0.6V across it?" The short answer is that, yes, you can treat the diode drop as a resistor, if you realize this implication: In a normal resistor, the ohms value of the resistor is (excluding thermal effects) constant; that is, in the Ohm's Law equation E = IR, for a given resistor, R is always constant. So if you vary one of E or I, you know what happens to the other one, since R isn't changing. On the other hand, with a diode, E is constant and R varies. It is easily seen from the equation than if E is constant, and I goes up, then R must go down in order to maintain the constant value of E, and in fact that's exactly what happens. The diode's resistance varies inversely with the current flowing through it. This is why you never want to wire a diode directly across the poles of a battery or power supply, without a resistor in series to limit the current. Once the current starts flowing through the diode, the resistance will go down, which will allow more current to flow, etc., until something melts. Electrical engineers refer to things that behave like diodes as "non-ohmic", and say that they don't obey Ohm's Law. This isn't really true; they do obey Ohm's Law if you allow for the fact that the resistance is not constant. (They say it for another reason too: the particle-physics mechanism that produces the diode-drop resistance is not the same as the mechanism that produces resistance in an ordinary resistor.)

There is something called a Schottky diode, which operates on a different physical principle (it does not use a P-N junction). Its main use is in high-frequency circuits, because it can switch from the non-conducting state to the conducting state faster than a normal diode. For most synth applications, we don't care about that, since synth circuits don't use high enough frequencies

RF Mixers and Ring Modulators

Radio people use the word "mixer" to refer to a circuit that is used to shift a signal to a higher or lower frequency. (This use of the word has nothing to do with audio mixers.) The mixer accepts a signal to be converted, and a sine wave at a given frequency from a local oscillator. The mixer either raises or lowers the frequency of the input signal by the frequency of the local oscillator signal.

Although a well-designed RF mixer contains a number of components and functional blocks, the basic frequency-changing function can, believe it not, be performed by a simple diode. How can it do that when it is nothing but a simple one-way valve for electricity? Well, as we've just seen in the above discussion about diode drops, that isn't totally true. When the voltage applied to the diode is below the diode-drop threshold, and when it is considerably above the threshold, the diode's behavior is linear. However, right at the threshold and just a little above, there is the "corner" region when the resistance of the diode is neither infinite nor very low. And further, it is varying inversely with the current flow. So this part of the diode's response graph is not straight; it's curved.

We now have to discuss some math, so bear with me. Any simple curve can be described (or at least approximated) by a polynomial, of the general form:

Output = A*V + B*V^2 + C*V^3 + ...

where V is the input voltage, and A, B, & C are constants. Now, let's assume for a moment that the signal to be converted is a simple sine wave. When it is added to the signal from the local oscillator (also a sine wave), and run through the polynomial, the B*V^2 term (after doing a bunch of algebra) produces, among other things, two terms in the frequency domain. One of them is a new signal whose frequency is the sum of the input signal and the local oscillator. The other is a new signal whose frequence is the difference of the input signal and the local oscillator.

Do those last two sentences sound familiar? Yes, that's what a ring modulator does. However, the output has other combinations of frequencies in it -- the polynomial has other terms that are generating other multiples of the frequencies involved, plus there is some interaction between the output and the input. Radio RF mixers use filters to eliminate the unwanted frequences, and leave only the desired on, which is usually either the difference frequency or the sum frequency, depending on what the purpose of the mixer is. But there are other frequency combinations that could be selected instead.

Now, for synth use, there is no reason why the "local oscillator" has to be a sine wave. In fact, it could be some other signal. And depending on the particulars of the circuit, it could produce various combinations of frequencies. Here is a simple mixer circuit that will produce several bands of frequency combinations:

Note that this circuit does not eliminate the two original input signals, as a properly balanced ring modulator does. Here is the classic diode-ring modulator circuit:

This circuit does a good job of supressing the input signals, assuming that the diodes are closely matched. There are other types of diode-based modulator and mixer circuits. If you are interested in exploring this further, here is an excellent paper (PDF) the describes various types of RF mixer circuits, how they work, and their characteristics. (If you aren't interested in the theory, skip down to section 4.)

It's worth noting at this point that most synth "ring modulator" circuits do not use the above circuit. Although it works well at radio frequencies, the diode ring modulator has some practical problems at audio frequencies. Distortion due to saturation in the transformer cores is difficult to avoid, and the output level is very low. Most synths do ring modulation using a VCA as an analog multiplier, or else they do the multiplication directly in the digital domain. These techniques will produce a somewhat different sound than a true balanced modulator, since they do not produce the frequencies corresponding to the higher terms of the polynomial.

Reverse Breakdown and Zener Diodes

We say that a diode prevents current from flowing in the reverse direction. The truth is, it can only prevent this up to a certain reverse voltage. Beyond that point, the diode goes into reverse breakdown, and current flows in the reverse direction. In a normal diode, reverse breakdown is something to be avoided, since it usually damages the diode. A small-signal diode such as the commonplace 1N4001 will usually have a reverse breakdown voltage in the 50-200V range. So you want to avoid using such a diode in a circuit where it may be exposed to a reverse voltage in this range or higher.

However, there is such a thing as a diode that is designed to not only tolerate reverse breakdown, but to go into and out of reverse breakdown at a specific voltage. This is called a zener diode. One of the most common uses for a zener diode is that of a quick-and-dirty voltage regulator. For example, we could take the unregulated bridge rectifier power supply that we built above and add regulation to it using a zener:

Note the symbol for the zener, and the current-limiting resistor above and left of it. How does this work? Let's say that the unregulated output of the supply is in the 18-22V range, and the zener has a reverse breakdown voltage of 15V. When the power supply is switched on, the voltage rises above the zener's reverse breakdown voltage, and current begins to flow through the zener. As it pulls current, voltage develops across the current-limiting resistor, which means the voltage on the output side of the resistor drops. When it drops to 15V, the zener will reach a stable state where it conducts just enough to keep the voltage right at that point. If the load begins drawing more current from the supply, the voltage will drop, and as it drops below the zener will stop conducting until the voltage rises back to 15V. It will then stabilize there again.

Note that this actually isn't a very efficient way of regulating a power supply. At times when the load is not drawing much current, the zener and the current-limiting resistor will dissipate a significant amount of the power supply's output as heat. And the current-limiting resistor means that the load cannot draw up to 100% of the supply's output capacity without the voltage sagging. Nonetheless, zeners are often used to develop lower voltages from higher ones, particularly in a situation where a circuit designer needs a specific voltage for a specific purpose (such as a reference voltage) in a particular place in a circuit, and the current demand is not high. The designer will simply put a zener and current limiting resistor on the board at the place where it is needed, drawing from the board's primary power.

Distortion Circuits with Zener Diodes

Here's a use for a zener diode that's a lot more fun. Consider the following circuit:

Note the two zeners back-to-back. What will this circuit do? Well, when the voltage exceeds the reverse breakdown voltage of the upper zener, that zener will start conducting. The second zener, having voltage applied to it in the forward direction, hasn't started conducting, though. It will as soon as the voltage rises a little further, far enough to overcome its diode drop. What happens then? The two zeners clamp the voltage, to the sum of the zener reverse breakdown voltage of the upper zener and the diode drop of the lower zener. Now, what about negative voltages? The same thing happens in the opposite direction: the zeners clamp to the reverse breakdown voltage of the lower zener, plus the diode drop of the upper one. If we assume that both zeners are of the same type, then this circuit's output will be restricted to a +/- voltage range that is determined by the zeners. Any peaks of any waveform that exceed this range will be chopped off.

This is a clipping circuit, aka a distortion or fuzz box. There have been, in fact, guitar distortion pedals that use this circuit. If you run a sine wave through it, the output comes out looking like this:

Suppose we put the zeners in series in the circuit instead of across it?

The zeners now conspire to let through only the portion of the waveform that they clipped off in the previous circuit. Let's call this "anti-clipping"; instead of knocking off the waveform peaks, it rips out the portion of the waveform near the axis, leaving only the peaks. The anti-clipped waveform looks like this:

Light-Emitting Diodes

A light-emitting diode is a diode made from materials such that the P-N junction emits light, at a specific wavelength, when current passes through the diode in the forwards direction. That's straightfowarde enough. LEDs are like normal diodes in that they have a diode drop, which is a resistance that varies inversely with the current flow; hence they are subject to the same current runaway issues as normal diodes. So an LED usually needs a current-limiting resistor ahead of it; a rule of thumb is to use a 1K resistor when in doubt.

LEDs are made from base materials other than silicon; gallium arsenide and gallium nitride are two common ones. The color that the LED emits depends mainly on the base material. The first LEDs produced in the 1970s were all deep red. Green and infrared ones came shortly after, but for various reasons, it took a surprisingly long time to develop a good blue LED. Nowdays, they are available in red, orange, yellow (usually made by putting a red and a green in the same package), green, blue, and violet. There are also any-color LEDs which consist of red, green, and blue all in the same case, each with its own lead; you can produce any desired color by varying the current to each of the three primary colors. Be careful with violet LEDs; they can emit a fair amount of near-UV if they are driven hard.

At this point, the EE student will usually ask: Can an LED be used like an ordinary diode, exclusive of its light-emitting capability? The answer is that it's not a good idea to subject LEDs to reverse voltage. Most LEDs have a reverse breakdown voltage of only a few volts, and they are permanently damaged by reverse current flow. However, there is one common non-light-associated use for LEDs. Because they are made out of materials other than silicon or germanium, they have different diode drop voltages. Different color LEDs have diode drop thresholds of up to 3V, depending on the base material. This can make them very useful in situations where diode drops of several volts, or diode drops that aren't multiples of 0.6V, are called for.

Specifying Diodes

For small-signal processing with ordinary silicon P-N junction diodes, the only really important parameter is the reverse breakdown voltage. The diode drop is a function of the base material and will be the same for all silicon diodes. If the diode is made of some other material, it will have a different diode drop. LEDs have different diode drops depending on the material they are made from. Information on diode drops of specific types is surprisingly hard to find; a quick survey with Google shows that you can't make an assumption based on the LED color alone. Schottky diodes are available in a range of diode drops from 0.2 to 0.8V.

For power applications, the maximum current or maximum power dissipation becomes an important factor. Diodes and integrated bridge rectifiers are available specifically for power applications, and they usually have provisions to be mounted to a heat sink to increase the power handling capacity. Note that really large power diodes will have a non-trivial amount of parasitic capacitance as a consequence of the way the P-N junction works.

There is a JEDEC standard for how diode part numbers are to be formatted; they always start with "1N", which indicates a diode, followed by a part number in a certain series. For example, ordinary P-N junction diodes are numbered 4000-4999, and zener diodes are numbered 5000-5999. However, manufacturers these days seem to be getting away from the standard, particularly with surface-mount parts, which are all over the place.


Diodes can do some surprising things, which aren't always obvious from the basic functional description. There are a lot of other circuit ideas out there, and I simply don't have space to sum it all up. So do some Web searches and read some books.

Next time, we'll make a start at taking on the transistor.

1 comment:

vortex said...

This is the best primer on DC circuits I've ever read. Thanks.