Embedded Systems/High-Voltage Circuits
Often we use embedded systems to control high-power devices. For example, maybe we want to program a microcontroller to turn on and off standard light bulbs.
As we discussed earlier, typical microcontroller output pins switch between 0 V and 5 V, and can drive a maximum of 0.025 A. But a typical light bulb requires 120 VAC at 0.5 A to turn on. We can't connect the microcontroller up to the 120 VAC directly.  What do we do?
Transistors and Relays
Some transistors, known as "Power Transistors", can control a high voltage source using a lower voltage control signal. There is also a type of electromechanical device known as a relay that can also be used to control a high voltage source with a relatively small control current. Both of these tools can be used to control the flow of a high-power electrical flow with an embedded computer.
To interface a relay the port pin must me capable to drive the transistor into saturation to avoid "Chattering" of the relay due to voltage variations. The resistor R1 & R2 should be so calculated that the Ib & Ic Values of the transistor are not excedded and the relay coil gets rated current to turn on. A diode should be added as shown so that the relay when turned OFF can discharge through it, and alleviate any potential arching cause due to the stored energy in an inductor. This diode is also known as free wheeling or flyback diode, this is needed as for an inductor v=L di/dt, where v is voltage, L inductance, i current and t time. a sudden change in current running through the inductor will cause a very large voltage to appear at the switch, and could cause arching, a flyback diode will allow current to flow through, and gradually dissipate due to diode voltage drop, and other losses.
Occasionally we need to use multiple stages of amplification. To turn on a large motor, we need a large relay -- but to turn on the large relay, we need a power transistor -- but to turn on the large transistor, we need at least a small transistor -- finally, we turn on the small transistor with the microcontroller output pin.
When driving a large motor, power transistors often need a heat sink.
When working with embedded systems, or any expensive piece of equipment, we often find that it is a good idea to isolate the expensive components from the high power components. We do this through a technique called isolation. Isolation, in essence, is how we keep the high current and/or high voltages out of low-current, low-voltage devices. There are several types of isolators.
The "isolation barrier" is an imaginary line between the high-current or high-voltage device on one side, and low-current, low-voltage devices on the other side.
- Transformers are used to transfer power from one side of the isolation barrier to the other
- optoisolators are used to transfer signals across an isolation barrier from one low-power device to another low-power device
- relays allow a microcontroller on one side of the isolation barrier to switch on and off high-power devices on the other side.
Transformers use magnetic fields to move a voltage from one coil to another (over simplification). There is no direct wire connection between the input and the output terminals, and therefore transformers can help to prevent spikes on one side from damaging expensive equipment on the other. Transformer is used on voltage step up or down this basic principal of transformer.
Opto-Isolators are useful for sending signals from one circuit to another. One half of the Opto-Isolator (OI) is an LED. The circuit connected to that side turns the light on and off. The other half of the optoisolator is a phototransistor. When the light is on, the phototransistor absorbs the light, and acts like a closed switch. When the light is off, the phototransistor acts like an open switch. Because light is used instead of electricity, and because the light can only go in one direction (from LED to phototransistor), they provide a very high level of reliable isolation.
Relays can also be used to isolate, because they act very similarly to transformers. The current flow in one wire is controlled by a magnetic field, generated by a second wire.
A relay controls whether electrons flow or not, by allowing a small current to the input coil producing a magnetic field in which operates the switch.
- (1) Occasionally someone does accidentally connect an integrated circuit to 120 V. The integrated circuit immediately self-destructs. If you're lucky, it cracks in half and lets off a small puff of smoke. If you're unlucky, it will still look like a good chip, leading to hours of frustration trying to figure out why the system isn't working.
For further reading
- SCRs and triacs include several power transistors in a convenient package, and often cost less than buying equivalent transistors separately.