Learn different methods for controlling high voltage and high power devices using transistors, relays, and more.

Some projects will contain devices that consume more power than a microcontroller can output, making it so they can not be controlled directly. Instead, these devices require an external power source and therefore have to be interfaced in a different way. This article illustrates some popular methods of interfacing such devices with a simple microcontroller.

DC Switching With Simple Transistors

This is the simplest method and suitable for most applications. It allows you to turn a DC component ON and OFF by using one output of a microcontroller. If you want to use many transistors, take a look at how you can extend the number of outputs of your controller.

Both types, NPN and PNP, can be used as a switch:

Transistors as Switch

The NPN transistor connects a load to the negative side of the power supply and it is turned ON by pulling the control line high. The other type, PNP transistors, supply a path to the positive side of the supply when control is low.

Use a Relay for Switching

A relay is a magnetically controlled mechanical switch that can be turned ON and OFF. They have a higher power consumption compared to transistors but they can usually also drive loads that draw a lot of current. Furthermore, they can also be used to control AC devices. Makers will usually want to use a relay module for their projects:

Using a relay for Switching

The NPN transistor connects a load to the negative side of the power supply and it is turned ON by pulling the control line high. The other type, PNP transistors, supply a path to the positive side of the supply when control is low.

The usage is pretty simple. Each relay has two contacts: One that is initially open (not connected) and one that is closed (connected). By applying a voltage to the control input, the relay turns on and the normally open contact gets connected to the common contact of the relay. Otherwise, the normally closed contact is connected.

Use an H-Bridge

All the options so far only allowed us to turn a device ON or OFF. However, DC-motors, for example, can be reversed to turn in the other direction. This can’t be accomplished by using the simple methods explained above. A popular solution to this problem is the H-Bridge, an uncomplicated transistor based circuit:

H-Bridge

H-bridge

Note that the image is heavily simplified. However, this solution is so popular that there are different driver ICs available (for example the LN298N) that can be used as well as pre-made modules.

The motor can be controlled via the two inputs INP_A and INP_B. Only when they are both different (one of them is HIGH, the other one LOW), the motor will spin. Otherwise, it’s turned OFF. The direction, in which the motor spins, can be changed by altering the state of the input pins.

Conclusion

These are a few different methods you can utilize to control high voltage devices with a simple microcontroller. Some methods are better in certain applications than others. For a fast DC-switch, you should use transistors. If you want to switch high power loads or AC devices, like home appliances, you should go with a relay. Either way, always make sure that the parts you use are rated for the voltage and current you want to switch.

Daniel Hertz
Hi! I am a software engineer and owner of nerdhut.de who loves to experiment with electronics, gadgets and tech in general.

Categories