A solenoid is an electromagnet that activates a mechanical function, such as a plunger. Solenoids are used to latch safety covers closed so they can’t be opened while a machine is in operation, or to unlock the doors in your car when you push the keyless entry button on the remote. Solenoids can open and close valves in industrial processes or push the record head against the tape in a tape player.
Solenoids come in many shapes and sizes, and are capable of exerting a force from less than an ounce to several pounds. There are two basic varieties: continuous duty and pulse duty. Continuous-duty solenoids are designed to be energized all the time. An application such as holding a safety cover closed would use a continuous-duty solenoid.
A pulse-duty solenoid might be used for the doors in your car. Pulse-duty solenoids will overheat if left energized all the time—they are designed for intermittent operation. A pulse-duty solenoid allows a high-force solenoid to be smaller and cheaper because continuous operation is not a concern.
A relay is a solenoid that operates electrical contacts. When the relay is energized, the contacts are shorted or opened, just like a mechanical switch. Interfacing to Solenoids and Relays For the sake of simplicity, this section will address relays, but the same considerations apply to solenoids. Figure 6.1A shows a relay as it might be connected to a microprocessor. A single bit is used to turn the relay on and off.
The figure shows an NPN transistor connected to a port bit on the processor; you could also use a MOSFET. Some microprocessors have outputs that are capable of sinking sufficient current to activate a relay, as long as the relay is operating from the same voltage as the processor.
Because the relay or solenoid is activated by a coil, there is a flyback voltage that occurs when the drive transistor is turned off and the magnetic field collapses in the coil. This voltage can reach high enough levels to damage the drive transistor. Figure 6.1B shows how a diode can be used to clamp the voltage across the coil to safe levels.
When the transistor turns on, activating the relay, the diode is reverse biased. When the transistor turns off, the top end of the coil is tied to the drive voltage, so a voltage spike appears at the lower end (transistor collector). As soon as this voltage reaches the supply voltage plus one diode drop (about 0.6 V for a silicon diode), the diode conducts.