Speed Control of DC Motor using Arduino with the help of PWM.

PWM stands for pulse width modulation where we can change pulse width of the signal. In short the duty cycle changes. The frequency of PWM signal remains same. We can easily generate pwm using arduino. Arduino has inbuilt functions in its library which makes the task easily. PWM can also be generated using other microcontroller and timer IC’s. Click this PWM Generation using IC555 to see PWM generation using 555 timer. PWM can be used to drive motors and led’s to control the speed and intensity respectively. In this post you will learn How to generate PWM using arduino and how to control speed of DC Motor. In arduino the PWM pins are the ones which indicate ‘~’ symbol. These pins can only generate PWM signals as they are connected to the internal timers.

Circuit Diagram:

pwm generation using Arduino
pwm generation using Arduino

 

Components:

  • Arduino Board
  • 2N222 Transistor NPN Transistor. Click the link for Datasheet.
  • 1N4007 Normal Rectifier diode.
  • DC Motor- 12V
  • 1K Resistor
  • Battery

PWM Generation:

In Arduino there are lots of pins where we can generate PWM’s. They are indicated by ‘~’ symbol. Now the PWM generated at pins 5,6 are of 980Hz. While other pins generate PWM frequency are 490Hz. The specifications are for Arduino UNO boards. Now the Arduino compiler have inbuilt function named as analogWrite(). To generate PWM using arduino two parameters are passed during this function call. It is used like this analogWrite(pin, speed).

analogWrite(10, 255). Generate PWM at 100% duty cycle at pin no 10.

analogWrite(10,128) Generate PWM at 50% duty cycle at pin no 10.

More details about analogWrite() function can be found from Here.

DC Motor Speed Control using 8051:

Click the link to learn DC Motor Speed Control using 8051.

Circuit Working:

The base of the NPN Transistor is connected to the PWM Output pin. Hence we are using the NPN Transistor as a switch. When the PWM wave is at high level the transistor gets ON and starts conducting. Current starts flowing in the collector to base direction. This helps the DC Motor to conduct as the path between the VCC and Ground gets completed. The diode is used for a safety purpose so that the reverse direction current is obstructed. When the PWM wave is at low level the transistor is OFF. There is no connection between the VCC and ground. Hence the Motor does not conduct. Hence higher the duty cycle higher times the transistor remain in ON state and higher the speed.

Higher PWM Duty Cycle ~ More time of Transistor ON Stare ~ Higher Speed.

Code:


int pwm = 10;

void setup() {

pinMode(pwm,OUTPUT); //make 10th pin as output.

}

void loop() {
delay(100);
analogWrite(pwm,10);//slowest speed
delay(1000);
analogWrite(pwm,50);
delay(1000);
analogWrite(pwm,100);
delay(1000);
analogWrite(pwm,150);
delay(1000);
analogWrite(pwm,255); //255 belongs to full speed
delay(1000);

}

 

Output:

Output-PWM Generation
Output-PWM Generation

CHECK OUT THE OUTPUT VIDEO:

 

Thank You for referring the guide. Please feel free to comment or contact us anytime at elexfocus@gmail.com.

 

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here