Difference between revisions of "Electronics notes/Diodes"

From Helpful
Jump to: navigation, search
m (LED pixel strings)
m (LED pixel strings)
Line 861: Line 861:
There are also variants that separate the driver chip and the LED (and usually control a handful of LEDs each), but work and control much the same.
There are also variants that separate the driver chip and the LED (and usually control a handful of LEDs each), but work and control much the same.
Sometimes called neopixels (this seems to be an adafruit name)
Sometimes called neopixels (this seems to be an adafruit name[https://www.adafruit.com/category/168])

Revision as of 17:51, 1 April 2020

This is for beginners and very much by a beginner.

It's intended to get an intuitive overview for hobbyist needs. It may get you started, but to be able to do anything remotely clever, follow a proper course or read a good book.

Some basics and reference: Volts, amps, energy, power · Ground · batteries · resistors · changing voltage · transistors · fuses · diodes · varistors · capacitors · inductors · transformers · baluns · amplifier notes · frequency generation · skin effect

And some more applied stuff:

IO: Input and output pins · wired local IO wired local-ish IO · · · · Shorter-range wireless (IR, ISM RF, RFID) · bluetooth · 802.15 (including zigbee) · 802.11 (WiFi) · cell phone

Sensors: General sensor notes, voltage and current sensing · Knobs and dials · Pressure sensing · Temperature sensing · humidity sensing · Light sensing · Movement sensing · Capacitive sensing · Touch screen notes

Actuators: General actuator notes, circuit protection · Motors and servos · Solenoids

Some stuff I've messed with: Avrusb500v2 · GPS · Hilo GPRS · JY-MCU · DMX · Thermal printer

Audio notes: basic audio hacks · microphones · amps and speakers · device voltage and impedance, audio and otherwise ·

Less sorted: Common terms, useful basics, soldering · Microcontroller and computer platforms · Arduino and AVR notes · ESP series notes · Electronics notes/Phase Locked Loop notes · mounts, chip carriers, packages, connectors · signal reflection · pulse modulation · electricity and humans · Unsorted stuff

See also Category:Electronics.


Types and materials

Silicon diode

Common, cheap.

Forward voltage drop of about 0.7V.

Germanium diode

Forward voltage drop of about 0.3V.

Zener diode (type/behaviour)

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)


Reverse breakdown refers to diodes/transistors conducting in reverse, which happens at a specific breakdown voltage (the potential that overcomes the p-n junction tendencies).

(This happens when the carriers in the transition region are affected by the electric field enough to create mobile or free electron-hole pairs via collisions with bound electrons, which leads to a very short, relatively large current spike)

All diodes have a zener voltage, and what's called a reverse breakdown region right above it where that reverse flow will happen.

On regular diodes that's far enough away (usually dozens of volts of reverse voltage) to never happen in the circuit it's specced for.

Even when you want to use it, on regular diodes the region is narrow and hard to use, varies with production(verify), and will usually damage it.

A Zener diode, in forward bias, acts like a completely regular diode, with similar voltage drop (usually roughly 0.6V .. 0.7V drop, sometimes lower(verify))

They are more interesting in reverse: Their zener voltage is engineered to be at a lower level, one more practical to typical low-voltage electronics (often between 2.4V and 7V, apparently up to 33V), a wider reverse breakdown region, better-characterized in that region, and more robust within in it. (Lower-than-2.4V Zeners are actually imitations of Zener behaviour and their behaviour is a little different from real Zeners(verify))

The well defined behaviour make this region/behaviour exploitable in its own right, e.g.

  • voltage clamping protection (and other purposes where they effectively act as a sort of relief valve)
e.g. say you have a 5V-powered device, and added a 5.1V zener. A transient spike in the input will be suppressed to a good amount (and because it's transient will not cause temperature issues in the zemer)
  • simple, shunt-style regulation
(TODO: simple zener regulation image)
not efficient, not the mort stable, so for more than a little current you want other regulation
  • fixed voltage references
  • clipping signals
e.g. one for DC, two for an AC waveform
in audio for distortion (see fuzz boxes)
avoiding op amp phase inversion

The current and heat dissipation varies between zeners, often range of milliwatts for voltage reference, a few hundred milliwatts for simple regulation, up to a Watt or so.

Since you rarely want to move a lot of current in reverse bias, circuits will often see some sort of current limitation (a resistor or such).

See also:

Avalance breakdown (behaviour) / avalanche diode (spec/type)

Avalance diodes usually refer to diodes that are made to imitate Zener behaviour, yet will work for higher voltages (100 ~ 300V) than true Zeners can.

Avalance diodes may be found categorized as (or referred to) as Zener diodes.

See also:

Schottky diode (type)

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

Forward voltage drop on the order of 0.15V .. 0.45V rather than the more typical 0.6V .. 0.7V.

Also switches faster than some.

Nice when you want to avoid wasting power when protecting something capable of a bunch of current, or want to avoid a voltage drop that is significant to your application, or for faster switching.

It also has some uses filtering higher frequency.

They have limited reverse voltage ratings (reverse saturation happens more quickly), so are not as useful for certain protection, and have more reverse leakage current.

See also:

Current regulating diode (type)

Signal diode, switching diode (spec)


Bypass diode / flyback protection diode (application)

A bypass diode is a diode used to protect something against reverse biasing - against voltage going the wrong way.

Also known as flyback diode, kickback diode, catch diode, snubber diode, freewheeling diode, suppressor diode, commutating diode, antiparallel diode, and more. (Some names refer more specifically to more transient reverse biasing, or the causes behind that)


  • inductors in general can store energy (in an magnetic field)
some because sudden changes (e.g. solenoid disconnecting)
and larger things that move (solenoids, motors) a little more so (movement that translates back to magnetic field)
They can often easily deliver a few times the voltage they usually operate at (varying with case). This can seriously stress the circuit components directly around it, depending on design.
The use of a diode in parallel, reverse-biased to how you drive it, is one easy way to bleed this short-lived current
yes, you're essentially making a one-way short-circuit, which is why it also affects the braking behaviour of coil-style actuators: the collapse of the magnetic field is usually slowed(verify)
on the spike shape:
  • In a series of solar cells, shading one cell among multiple leads that one cell it to be reverse biased relative to the others, meaning that panel gets fed current from the others, which would heat it and may eventually damage it.
A bypass diode in parallel with each cel llets the current-in-the-wrong-direction pass alongside the cell instead.


  • If the load is bidirectional (e.g. bidirectional motor driver) then the flyback can happen in either direction, and you can't protect it in the way described above
For example, in the case of a H-bridge driver, you need four diodes for protection in both directions
  • Protection diodes should be able to take a decent load - may well be a few amps for a short while (depends a lot on the load)
bog-standard diode like 1N4001-1N4001 series can be used - for lower frequencies
for higher frequencies you need to look around more, probably for schottky diodes
  • Protection diodes should have a voltage rating of at least the voltage you are applying
whenever significant energy can get stored (e.g. in case of coils), leeway is a good idea
  • Protection diodes should be robust to reverse biasing (themselves)
  • You may have preference for a fast-acting diode (e.g. Schottky) to minimize the time the reverse bias is applied (though note they have lower reverse-bias ratings)
  • Sometimes you may also care about low voltage drop (which can matter e.g. in solar and battery applications, minimizing loss).
  • If reaction time is not so important (or low cost is considered more important), cheaper general-purpose diodes such as the 1N400x series can be used.


See also:

Blocking diode (application)

Clamp diode (application)

Clamper circuit

Rectifier bridge (simple design)


LEDs convert a higher percentage of energy going through them to light than, say, classic lightbulbs (where a lot of the energy becomes heat, i.e. IR radiation).

That sounds awesomely efficient, though there's a footnote to that: getting from AC mains voltage to few-volt DC voltage. That conversion is not very efficient to do, particularly not for the quite-low currents involved when each just powers a few LEDs.

LEDs do act as diodes ('Light Emitting Diodes', after all), in that they conduct/work only in one direction. Their ratings as diodes is pretty poor, though. They are slower, and their reverse breakdown is close, so in many situations you'ld want to add a serious diode.

LED of different types usually need something like 2V or 3V forward voltage before they start emitting light. (The extremes, including some less usual types, seem to be 1.6V and approx. 4.4V)(verify).


LEDs have an I-V curve that is not only nonlinear, but also very steep exactly near the point you want the operate them at, particularly if you want to drive them at decent brightness but also have them live long.

they have a threshold below which they do nothing
a fairly flat bit of still low current (and they will be relatively dim here)
quick-and-dirty uses operate them here, e.g. by using a somewhat large resistor.
and then shoots up, from little current to too much, over a volt or two

The exact curve varies with

  • LED type (that search shows different curves for the different classic LED colors),
  • environment temperature - itself largely determined by the current currently going through it
  • production line variation

Indicator LEDs tend to be specced for a continuous current of ~10mA. Superbright for perhaps ~20mA, and low-current LEDs perhaps 2mA.

Keep in mind that these are continuous-use maximums. Both in that most LEDs already give off some light at 1mA. (And also that you can often pulse higher currents on a low duty cycle. Check spec sheets)

All that makes it very hard to create a universal LED driver that is entirely plug and play.

This is roughly why the current-limiting resistor approach is such a typical approach, because it which works fine on things like indicator LEDs where we care more about lifetime and basic visibility than maximum brightness or maximum efficiency.

When driving powerful LEDs, though, we do care (also because of waste heat), and will generally use a current-limiting LED driver, for which there are now plenty of ICs, and supplies centered around them.

LED response time
Current limiting resistor

Short version:

A LED draws current but not because it has resistance, so something with only a LED will not limit current at all.

Adding a resistor in series will be the most limiting current.

For most LED and typical PCB voltages this works out on the order of 100 ohm to 1kOhm.

The upside is that it' very simple to do.

The main downside is that since it will pass the same current as the LED, it will also use similar power (particularly when used for just one LED), putting it into heat instead of light.

...that said, if you have a few indicator LEDs drawing a few dozen mA total, then it's often not worth it energy-wise or component-wise to drive them more efficiently. Yet when producing a lot of light, there are certainly better ways.


Being a diode, the LED drops a fixed voltage, its Vf.

...but does not limit current so in current terms it might as well not be there. Your calculations aim to have just the resistor drop drops enough of the (leftover) voltage that the current through it and something in series with it is at/below some target current.

...in this case the specific LED's rated maximum continuous current - or rather something a bit below it with a slightly higher-valued resistor.

Often your givens are the supply voltage, the LED's voltage drop Vf, and the LED's maximum continuous current rating you want to stay under.

You'll usually use:

     Vin - VLED
R = -----------

Chances are you'll grab the next-highest standard-valued resistor. If you want to know the current for it, the following reformulation is useful:

ILED = (Vin - VLED) / R

For example, to drive a ~2.2V red LED, aiming to stay under 20mA, and using standard-value (e.g. cheap carbon 5%) resistors, you might choose:

  • on 3.3V: 100Ω for 11mA, maybe 220Ω for 5mA
  • on 5V: 220Ω for 12mA, maybe 330Ω for 8mA or 150Ω for 19mA,
  • on 9V: 470Ω for 14mA
  • on 12V: 560Ω for 17mA, or 1kΩ for 10mA, or maybe 470Ω for 21mA.

Side note: A LED's max-current rating is for a good part limited by the ability to sink the generated heat, and assumes continuous current. When you're only ever pulsing the LED with a lowish duty cycle, you can get away with higher currents. For example, TV remote IR leds can do this because their pulsed protocols are implicitly low-duty-cycle. And you might do it for visible LEDs because when using something like PWM, for part of the curve current drops off faster than the human-apparent intensity.

LED drivers

At some point (often above a few hundred mA, for something that is on a lot), it becomes worth it energy-wise to invest in components to drive the LED more efficiently.

Since this often means a cleverer, more controlled circuit, it usually also means we can more safely aim for a current that is nearer its maximum brightness, just because there is less risk of burning it.

There are two basic approaches:

Constant-current LED driver
Constant-voltage LED driver
Multiple LEDs
Common cathode versus common anode
Series versus parallel


LEDs can be dimmed, in two basic ways:

  • Control the current
The amount of light isn't linear, but when humans adjust a knob, they tend to be practical about it, and if digital you can compensate.
The simple analog circuit requires little more than a transistor (being a current amplifier) and a voltage divider with a potmeter to control it, plus some fine tuning for the transistor's gain
...plus some thought on how to never drive it with too much current

  • Blink it very fast, typically using PWM, or possibly a relatively analog oscillating circuit.
Once the cycle in which it blinks is 100Hz or faster, we humans only really perceive the average amount of light that comes out. When you have a microcontroller this tends to be moderately easy. There are some cheaper ICs that can do much the same.
note that the current drops off faster than the intensity apparent to humans, meaning you can save a little power
...and/or get a little more lifetime out of a LED, as it's heat (more than anything else) that destroys LEDs

It also means that on lower duty cycles you can drive them a slightly higher currents than you would use for continuous driving. But since LEDs typically heat up faster than they cool down, this is not "half the duty cycle means twice the power" stuff. Datasheets may spec some of these details, and there are some rules of thumb you can follow if they don't.

Also, it's not really worth it to do this for apparent brightness, because you need to lower the duty cycle.

Still, it's useful for things like an infrared TV remotes. Because the protocols used are quite low duty cycle (typically simple bit-trains, where highs are themselves a 38kHz blockwave rather than continuous, and with relatively large intervals between repeated commands, so in this use are guaranteed to have a pretty low duty cycle), you may be able to drive them at a few times their rated continuous current, which means they carry further.


LED designed made for room lighting are designed to deal with hundreds of mA or more. Often because they're a large area or LEDS side by side (and often in part in series, allowing (or forcing) us to use higher voltages).

See also


Silicon-controlled rectifiers (SCR)




See also


LED pixel strings

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

Each is a LED with built in driver chip (often 3 channels, RGB, 18mA-per-channel), in something like a 5050 package.

There are also variants that separate the driver chip and the LED (and usually control a handful of LEDs each), but work and control much the same.

Sometimes called neopixels (this seems to be an adafruit name[1])

They are not individally controlled as such - there is no addressing. Instead, each chips holds one color, and when it gets a new one it commmunicates the old one on its own output.

As such, changing one pixel in a string actually amounts to remembering what you put on there, altering what you want to change, and shifting out the entire string again.

...but you can update the entire chain fast enough to not notice it's actually shifting.

(If you want to think big, say, make a hundreds-of-pixels display, you'll run into bandwidth and latency details, and you'll probably want multiple controllers. Updating requires little more than the capability to receive data and speak SPI or something similar, so you can probably use some of the cheapest microcontrollers you can find (but note minimum rate on some, e.g. the WS*) while still keeping update latency lower than your eyes can notice.)

Note that a bunch have strict timing, in which case the speed of replacing the entire string is fixed (the one thing you could do faster is walking pixels through it).

For an idea of speed, the WS2812, at 800kHz, means 1.25µs per bit, *3colors*8bits = 30µs per pixel, so e.g. 100 pixels takes ~3ms. (This is roughly the amount of pixels you can update with it still looking pretty smooth to us - so more than that will have to be done in separate strings)

There are perhaps a dozen variations of the ICs in relatively common use.

Most of them (noted if it differs)

  • Have 256 levels(verify) (8-bit) per channel (some try to gamma-correct, which does rather matter to color mixing)
  • control 3 channels (for R,G,B) (sometimes 4, then typically RGBW)
  • specced to draw ~18mA per fully bright color
so around ~50mA max per single pixel (so e.g. 50 pixels take up to ~2.5A).
Colors that look like non-white will take something more like 20-30mA. (So 50 pixels actually often take 1A to 1.7A)
note that there are variants -- which may be labeled exactly the same -- that draw maybe 60% of that.
  • You can often use a lower voltage
but they'll be dimmer
at some point no longer show the right color (because the different colors have different minimum voltages)
and below that fail to light at all.
  • 3.3V-level logic won't work with things expecting 5V CMOS logic, but there are several tricks available (see below)

Somewhat common ICs include:

  • WS2801 - SOP-14 or DIP-14 (separate driver; controls a few LEDs)
    • 3-5V
    • shift up to 25MHz (verify)
    • chains with 4 wires (Vcc, Gnd, Data, Clock)
    • More-channel-per-chip variants include WS2803 (SOP-28, DIP-28) for 18 channels (up to 6 RGB LEDs)
    • WS2801 datasheet

  • WS2811 - PLCC6 (integrated in LED), or separate DIP-8 or SOP-8 chip
    • Vcc is ~6V, VLED up to 12V(verify)
    • chains with 3 wires (Vcc, Gnd, Data) - uses specific timing instead of a clock (...but this puts more constraints on the controller)
    • WS2811 datasheet

  • WS2812, WS2812B - PLCC6 (integrated in LED)
    • 6-7V
    • slight improvement over WS2811 based LEDs, identical to control (verify)
    • chains with 3 wires (Vcc, Gnd, Data) - uses specific timing instead of a clock (...but this puts more constraints on the controller)
    • WS2812 datasheet

  • LPD6803 - SOP-16 / QFN-16 (separate driver)
    • 5-7V
    • shift up to 15MHz (verify)
    • LDP6803 datasheet
    • chains with 4 wires (Vcc, Gnd, Data, Clock)
    • variants include LPD8806, LPD8809

  • LPD8803 - SOP-16, others?(verify) (separate driver)
    • Vcc is 2.7-5.5V, VLED is 3..12V
    • shift up to 20MHz (verify)
    • chains with 4 wires (Vcc, Gnd, Data, Clock)
    • variants include LPD8806, LPD8809

  • HL1606 - SOP-16, others? (separate driver)
    • 3-5V
    • SPI - needs 4 data wires (2 more than most of the others), 6 in total
    • Some sources note it doesn't do PWM, others say it does. I've not looked up what's going on there

I've also seen mention of:

  • More-channel variants of LDPs, e.g. LDP6806 and LDP8806 (6-channel), apparently LDP8809, and probably more.
  • TM1803
  • TM1809
  • LPD1109
  • SM16716
  • TLS3001


  • It seems the LPD6803 and WS2801 are decent tradeoffs between speed and price. There's faster, and there's cheaper, but for many purposes these are nice.
  • WS28*'s 2-wire communcation (in comparison to LDP*, which are more SPI-like) means more restrictions on the timing of communication (you may need a fastish uC for reliable control), and a little less bandwidth. The distance possible between pixels seems higher, and it seems to work out cheaper.
  • most LDP variants are identical to control, most WS variants are similar to control
  • On voltage:
    • Some chips can work with and put out at most ~5V (and may start working around 3 point something V).
    • Some will fry if you give them more than ~6V
    • Some can drive up to 12V and are fine with 5-12V.

3.3V tricks

Most of these LEDs are 5V CMOS devices, meaning they are HIGH above 70%*Vcc = ~3.5V, and just won't work when controlled from 5V.

See Level shifting for your basic options.

I'd go for the two-diode level shifter, since this is just one line
(note that since ws2812 communicate at 800Kbps, not all optoisolators are fast enough)

There's also a trick that runs one pixel at a lower Vcc (4.3V, via one diode) so that its input is high above >3V, and it outputs 4.3V logic (its Vcc) which is fine for the rest.

The one pixel will be a little less bright, so you either don't use it, or maybe use it for something separate like an indicator.


zero cross circuit