DC motors are widely used in various applications, and one way to control the speed and direction of a DC motor is by using a TIP122 transistor and an Arduino microcontroller. The TIP122 is a Darlington transistor, which allows for the control of high current loads with a small control signal from the Arduino. By connecting the base of the TIP122 to a PWM pin on the Arduino, the duty cycle of the PWM signal can be used to control the speed of the DC motor. Additionally, by connecting the motor to the collector and emitter of the TIP122 and reversing the direction of current flow through the motor, the direction of the motor can also be controlled. In this tutorial it is shown how to use the TIP122 darlington transistor as power switch to control a DC motor with PWM signal from Arduino.
TIP122 Transistor
The TIP122 is a Darlington transistor that can be used for motor
control. It is a NPN device, meaning that it is designed to control the
current flowing through a load by using a smaller current applied to its
base terminal. This allows the TIP122 to switch high current loads,
such as motors, on and off. The TIP122 can handle a maximum collector
current of 5A and a maximum collector-emitter voltage of 100V, making it
suitable for controlling medium to large motors. It is also relatively
fast switching and can be used in a variety of different applications,
including in robotics and industrial control systems.
The following picture shows TIP122 transistor.
The following picture shows Arduino Nano with TIP122 and potentiometer to control DC Motor speed.
Demonstration of DC motor Speed Control with TIP122
The following video shows how the speed of a 12V DC motor is controlled using TIP122 as a power switch, controlled by PWM signal generated by Arduino Nano and PWM duty cycle controlled by 10KOhm resistor.
Circuit Diagram and Operation
The following circuit diagram shows how one can use Arduino Nano with TIP 122 to control the speed of a 12V DC motor.
In the above example, the DC motor is connected as load to the collector. The dc motor has flywheel protection diode and capacitor to smooth noisy signal. The Arduino Nano generates PWM signal with varying duty cycle using the 10KOhm potentiometer. The PWM signal goes into the base of the TIP122 darlington transistor via the current limiting resistor. When the potentiometer is varied Arduino Nano generates varying duty cycle PWM(Pulse Width Modulation) signal with different power which then controls the switching action of the TIP122 transistor and hence power delivered to the motor. The varying PWM delivers different power to the motor and hence the speed is controlled.
Arduino Code
The following is the code for Arduino to control the speed of a DC motor using POT and TIP122 NPN transistor as a switch.
const int POT = 0; const int MOT = 10; void setup () { pinMode(POT, INPUT); pinMode(MOT, OUTPUT); } void loop() { int p = analogRead(POT); p = map(p, 0, 1023, 0, 255); analogWrite(MOT, p); }
The above Arduino code is written with the intention to control the speed of a DC motor using a potentiometer (POT) and TIP122 as a power switch.
In the first two lines, constants POT and MOT are defined and assigned values of 0 and 10 respectively. POT is used to represent the input pin connected to the potentiometer, while MOT is used to represent the output pin connected to the motor.
The setup()
function is called once when the Arduino board is powered on or reset. It uses the pinMode()
function to configure the POT and MOT pins. POT is set as INPUT, which means it will be used to read input from the potentiometer. MOT is set as OUTPUT, which means it will be used to send output to the motor.
Summary & Further Recommendation
Here it was illustrated how one can use the TIP122 to control the speed of a DC motor using PWM signal from Arduino Nano controlled via a potentiometer. TIP122 is excellent for motor control and useful in DIY electronics projects which involves motors and in robotics. Although Arduino and L298N motor driver IC can be used to achieve the same TIP122 is smaller in size and can be used to control a dedicated motor. For using motor driver IC see Arduino code for dc motor using motor driver. Other application examples of TIP122 are relay switching, amplifier, lamp dimmer, power supply control, solenoid control etc.