Transistors - The TIP120
Table of contents
Motors (especially high powered ones) can draw a lot of current quickly. Additionally many motors require a higher voltage than the Particle board can supply. They can often require 12V or more.
For both of these reasons, it’s not a good idea to have them directly powered from the pins on your board. If you do, you risk drawing too much current from the pin, browning out your microcontroller, or damaging the GPIO pin or the board itself. This means we’ll need another power source other than the board to get the needed current to our bigger motors.
This is where transistors come in. A helpful way to think of them is as an electrical switch. They’ll allow us to control the power flow without that power being directly connected to our board. They act as a middleman between two circuits: in one circuit we’ll use an external power source to drive our motors; in the other we’ll use a GPIO pin to turn on and off the power in that second circuit through the transistor.
The transistor will have three pins:
- A Collector - Connected to the External Circuit
- An Emitter - Connected to the External Circuit
- A Base - Connected to our Microcontroller and used to control the external circuit.
There’s two major types of transistor a: NPN and PNP. In this guide, we’ll focus on NPN transistors and specifically the TIP120.
Note: You should note that if you’re working with a different transistor that is also NPN the pin configuations may be different. PNP transistors will behave differently from NPN transistors too. Always check the datasheet for the transistor before you use it: make sure you’re wiring it correctly; that it supports the amps (currents) your actuator will draw; and the voltage range that you’ll be powering it with.
The TIP120 which is a good multipurpose transistor that works well for most scenarios and circumstances: They can switch up to 60V at peak currents of 8A and continuous current of 5A. (see: https://www.adafruit.com/product/976)
When wiring a TIP120 transistor:
- Base - Activates the Transistor. Connected to the Photon
- Collector - Closest to the positive lead of the motor or component you want to supply power to
- Emitter - Closest to the negative lead of the motor or component you want to supply power to
When working with motors, it’s generally good to add a diode between the ground and power of the motor. Diodes only allow electricity to flow in one direction. When you turn the power off to a motor, you get a negative spike of voltage, that can damage your Particle or the transistor. The diode protects against this, by shorting out any such reverse current from the motor. Note the line on the diode. The line should always be closed to the collector.
To find out more
- about transistors: https://learn.sparkfun.com/tutorials/transistors