Single diode temperature sensor with Arduino ICU (& reverse-bias leakage)

Use a single diode as a temperature sensor with Arduino ICU

Our LED light-sensing experiments lead to an interesting observation: When these loggers are left running overnight they still produce readings because reverse-bias ‘leakage-current’ eventually triggers the Interrupt Capture Unit (ICU) – in the absence of any light. The speed of this self-discharge depends on the ambient temperature. If you deliberately cover an rgb LED with heat shrink, the different color channels have different rates of thermal decay

More details on Underwater Arduino Data Loggers blog.

Diodes: The Switch You Never Knew You Had

Vishay's take on the 1N4148 data sheet (PDF), describing it as a switching diode.
Vishay’s take on the 1N4148 data sheet (PDF), describing it as a switching diode.

When looking across the discrete components in your electronic armory, it is easy to overlook the humble diode. After all, one can be forgiven for the conclusion that the everyday version of this component doesn’t do much. They have none of the special skills you’d find in tunnel, Gunn, varicap, Zener, and avalanche diodes, or even LEDs, instead they are simply a one-way valve for electrical current. Connect them one way round and current flows, the other and it doesn’t. They rectify AC to DC, power supplies are full of them. Perhaps you’ve also used them to generate a stable voltage drop because they have a pretty constant voltage across them when current is flowing, but that’s it. Diodes: the shortest Hackaday article ever.

Not so fast with dismissing the diode though. There is another trick they have hiding up their sleeves, they can also act as a switch. It shouldn’t come as too much of a shock, after all a quick look at many datasheets for general purpose diodes should reveal their description as switching diodes.

So how does a diode switch work? The key lies in that one-way valve we mentioned earlier. When the diode is forward biased and conducting electricity it will pass through any variations in the voltage being put into them, but when it is reverse biased and not conducting any electricity it will not. Thus a signal can be switched on by passing it through a diode in forward bias, and then turned off by putting the diode into reverse bias.

Diode Switch Basics

A simplified diode switch in the reverse biased Off position.
A simplified diode switch in the reverse biased Off position.

To illustrate a basic diode switch, we’ve prepared a couple of simplified circuit diagrams. The first shows the anode tied to ground through R1 and the cathode tied to the Vcc power rail. The diode is in reverse bias, and no current is flowing through it. An AC voltage applied to C1 will appear at the anode, but will not appear at the cathode and the output via C2. The switch, in this case, is off.

The second diagram shows a very similar circuit but with the resistors connected to the opposite supply lines. The anode is now tied to the Vcc rail and the cathode to ground. A current is flowing through the diode, and it is forward-biased. Thus an AC voltage applied to C1 will appear at both the anode and cathode of the diode, and will make it through C2 to the output. The switch has been turned ON.

A simplified diode switch in the forward biased On position.
A simplified diode switch in the forward biased On position.

This is a simplified circuit, but not by much. A practical diode switch usually works by maintain one side of the diode at a bias point so that when a logic level is applied to the other point it will switch the diode from forward to reverse bias to allow the switch to be electronically controlled. In other words, hold one end of the diode in the middle, waggle the other end high or low.

Particularly for RF circuits you will also find RF chokes in the bias lines to stop RF finding its way into the power and logic circuits. But the essence is there in the diagrams, diode switches really are that simple.

So now you know how diodes can be used as simple on-off switches. You can even make multi-way  switches by connecting single diode switches in parallel to a single bias point. But that’s not the limit of the capabilities of the humble diode when it comes to switching, so we’ll now consider a couple more applications.

Diodes: They’re Only Logical

The first electronic digital computers such as those you would have found in military installations or universities in the 1940s used vacuum tubes, sometimes in conjunction with relays or other electromechanical components. As computers evolved through the early 1950s and found their way into civilian applications they started to be produced using the much smaller and less power-hungry semiconductors which were then the new kid on the block. The trouble with transistors of the 1950s though was that they were both expensive and unreliable, instead of the super-reliable planar silicon transistors we are used to today. The early 1950s designer had to work with germanium point-contact transistors. These devices, aside from their fragility, had the unfortunate characteristic of latching in the logic high state and requiring a power supply refresh after a state change. Clearly any circuitry that could reduce reliance on them was of great interest.

The diode OR gate. Thingmaker [CC BY-SA 4.0], via Wikimedia Commons.
The diode OR gate. Thingmaker [CC BY-SA 4.0], via Wikimedia Commons.
To the rescue of those 1950s designers came the humble diode. They were cheaper and far more reliable than a point-contact transistor, and capable of forming AND and OR gates with only resistors for company. This so-called diode-resistor logic, or DRL, was used in solid-state computers everywhere possible during this period, with transistors used only where an inverter was required.

Both diode gates use the diodes on their input lines, bringing the other ends of the diodes together at an output point with a pull-up or pull-down resistor.

The diode OR gate has the anodes facing the inputs and a pull-down resistor on the output, while the AND gate has the cathodes facing the inputs and a pull-up resistor on the output.

The diode AND gate. Thingmaker [CC BY-SA 4.0], via Wikimedia Commons.
The diode AND gate. Thingmaker [CC BY-SA 4.0], via Wikimedia Commons.
Aside from requiring a transistor whenever a logic inversion is required, these gates suffer the problem that there is a voltage drop across each gate. Thus if you daisy-chain a series of diode gates you will find that with each layer the logic levels drop, eventually to a point at which their transition is not sufficient to operate successive gates.

It is however still worth having diode logic in your stock of available circuits, for sometimes you may have a requirement for a single AND or OR in a project and it may make sense to quickly put one together using a few diodes rather than another 74 series chip.

Mixing it up with diodes

A diode mixer or ring modulator.
A diode mixer or ring modulator.

There is a further place that you will encounter a diode switch, especially if you are interested in radio or electronic music. The diode bridge mixer or ring modulator is a circuit using four diodes in a similar configuration to that you’d find in a bridge rectifier, and it functions as a frequency mixer in which an AC signal and the output of an oscillator are mixed to create their sum and their difference. The four diodes act as switches between the balanced signal input and the output, and have the effect of reversing the polarity of the path between them on each cycle of the local oscillator. It is used in synthesisers and guitar pedals, and in radio circuits wherever a transition between frequencies is required.

We hope you’ll now look at those diodes in your junk box with new respect now you know they can also do a good job of switching. You may never use a diode as a switch in practice, but it’s good to be familiar with the concept. And if diodes have caught your interest, why not continue with a look at our recently-published history of the diode?

Filed under: Engineering, Featured, parts