Trending

DC Motor speed control using PWM

Controlling the speed of DC motor using PWM signal generated through an Arduino which can be altered using Serial monitor.


Introduction- 

Pulse width modulation(PWM) is a method of reducing the average power delivered to the load by the electrical signal, by effectively chopping it up in parts. It works by switching on and off the supply at a very fast rate. The longer the switch is on as compared to the off time, the greater the power transferred. Existing application of PWM include, but are not limited to - 

1. Fan speed control
2. LED Dimmers
3. Electric motor speed control

Duty cycle- 

The term duty cycle describes the proportion of 'on' time to the regular interval or 'period' of time.
Duty cycle is calculated by the equation - 
DC = Time On / Time period


Controlling Motor speed using PWM- 


Here we are going to use an Arduino to generate a variable PWM signal using its serial monitor interface and connect it to the base of a transistor to power up the motor.

Arduino code- 

void setup() {
pinMode(6,OUTPUT);
Serial.begin(9600);
}

void loop() {
  while(Serial.available()>0)
  { int data = Serial.parseInt();
    data = constrain(data,0,255);
    if(Serial.read() == '\n'){
    analogWrite(6,data);
  }
  }
}


In the above code the line, analogWrite(6, data); will produce a PWM signal with the duty cycle as written in the variable 'data'.

Connection- 

1. Connect the first terminal of the motor to the motor, and the other to the Transistor collector.
2. Connect Pin 6 of the Arduino to the transistor base using a 1k ohm resistor.
3. Connect the GND to the emitter of the transistor.

Connect the motor in place of the LED.
Now open the serial monitor and enter the value between 0-255 to control the motor speed.
0-0% duty cycle and 255-100% duty cycle.

Here are some waveforms observed in Arduino based oscilloscope -

At 0% duty cycle - analogWrite(0);
 At 25% duty cycle - analogWrite(64);

At 50% duty cycle - analogWrite(127);


At 75% duty cycle - analogWrite(191);


At 100% duty cycle - analogWrite(255);


No comments