pcbway




DC motor speed control using Arduino, Control speed of the DC motor with arduino, How to control the speed of the DC motor, using Arduino, Arduino DC motor speed control, Controlling the speed of the DC motor with ArduinoHello friends! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about how can you make a simple program for DC Motor Speed Control using Arduino UNO. In my previous tutorial, DC Motor Direction Control using Arduino, I have just controlled the DC motor in both directions at constant speed using Arduino. I have also performed the DC Motor Direction Control in Matlab by sending different commands through serial port from Matlab and LabVIEW to the Arduino and then controlled the direction of rotation of DC motor. But in this tutorial I will rotate the same DC motor at variable speed in both clockwise and anti clockwise directions.

In my previous tutorial, we have seen that input pins In1 In2 of motor control driver L298 (H-Bridge) are useful to control the direction of rotation of the DC motor. In this tutorial, I have controlled its speed as well by providing different voltage levels at the enable pin of the DC motor control driver L298. It will be helpful to vary the speed of the DC motor in either clockwise or in anti clockwise direction. So, let’s get started with DC Motor Speed Control using Arduino UNO:

DC Motor Speed Control using Arduino UNO

In this tutorial we will learn that how to make an algorithm for DC Motor Speed Control using Arduino UNO. Speed control of any motor is always done y Pulse Width Modulation, abbreviated as PWM. PWM pulse can be generated using Arduino and L298 Enable Pin is used to get that PWM pulse and then it controls the motor speed accordingly. Before going into the further details I would like to tell you about the concept of PWM for controlling DC motor. Moreover, you can download the complete Arduino code for DC Motor Speed Control using Arduino by clicking the below button:

Arduino Source Code

Pulse Width Modulation (PWM)

PWM stands for Pulse Width Modulation. It basically describes the type of the digital signal. PWM technique is an excellent technique to control the analog circuits with microcontroller’s digital PWM output. In this technique we can get analog results with the digital means. Digital control is used to create square wave. This pattern can vary voltages between full on i.e. 5V and full off i.e. 0V. The duration of on time i.e. when the the signal is present is known as pulse width. PWM waves for the different duty cycles are shown in the figure below.

DC motor speed control using Arduino, Control speed of the DC motor with arduino, How to control the speed of the DC motor, using Arduino, Arduino DC motor speed control, Controlling the speed of the DC motor with Arduino,

Duty cycle is basically the proportion of the time during which a system is operated. It can be expressed as a percentage. For example motor rotates for 1 second out of 100 seconds, it duty cycle can be represented as 1/100 or as 1%. For Arduino software coding the command analogWrite(255) shows the maximum i.e. 100% duty cycle. To achieve 50% duty cycle we have to update this command to analogWrite(127). Arduino UNO’s pin no 3, 5, 6,10 and 11 are used as PWM pins. In this project we can control the speed of the DC motor by providing high and low voltages to the enable pin of the motor control driver L298. For example, if a motor rotates with the maximum speed and 100% duty cycle at 12V and we provide it with the 6V then it will rotate with the half of the initial speed having 50% duty cycle.

Motor Controller L298

The pins EnA and EnB of the motor controller L298 are used as the PWM pins. We can rotate the DC motor at different speed providing different high and low voltage levels to these pins of the motor control driver. If we start to reduce the maximum voltage at which the motor rotates at maximum speed, the speed of the motor also starts to reduce. In this way these enable pins are helpful to control the speed of the DC motor.

DC motor speed control using Arduino, Control speed of the DC motor with arduino, How to control the speed of the DC motor, using Arduino, Arduino DC motor speed control, Controlling the speed of the DC motor with Arduino

Algorithm design and descrition

In this section of the tutorial DC Motor Speed Control using Arduino UNO, I am going to explain you about designing as well as a detailed description of the designed algorithm. I will tell you about the entire algorithm in step by step procedure.

Note:Since you are working on the DC motor so you must also have a look at my previous tutorials, they will be helpful for you to simulate this project as well.

Open your Arduino software, copy and paste the source code given below in your software.

  • In the previous tutorials, DC Motor Direction Control using Arduino and DC Motor Direction Control using Matlab we have learnt that how to control the direction of the DC motor.
  • We used the commands C, A and S for the clockwise rotation, anti clockwise rotation and stopping the motor respectively.
  • In this tutorial, we have added two further commands and for accelerating and de-accelerating the DC motor.
  • If we send the command H different times consecutively the speed of the motor will increase continuously.
  • If we send the command different times consecutively, the speed of the motor will start to decrease.
  • Now, upload the source code to your Arduino UNO’s board.
  • Open the serial monitor at the top right of the Arduino Software.
  • And enter the commands in serial monitor periodically as explained above.
Actual Hardware Setup
  • When we enter the command in the serial monitor of the Arduino software. Motor will start rotating in the clockwise direction and a statement Clockwise rotation will be printed on serial port.
  • The same statement will be printed on the LCD as well as shown in the figure below.

DC motor speed control using Arduino, Control speed of the DC motor with arduino, How to control the speed of the DC motor, using Arduino, Arduino DC motor speed control, Controlling the speed of the DC motor with Arduino

  • When we enter the command in the serial monitor of the Arduino software. Motor will start rotating in the anti clockwise direction and a statement Anti clockwise rotation will be printed on serial port.
  • The same statement will be printed on the LCD as well as shown in the figure below.

DC motor speed control using Arduino, Control speed of the DC motor with arduino, How to control the speed of the DC motor, using Arduino, Arduino DC motor speed control, Controlling the speed of the DC motor with Arduino

  • When we enter the command in the serial monitor of the Arduino software. Motor will start accelerating and a statement Motor is accelerating will be printed on serial port.
  • The same statement will be printed on the LCD as well as shown in the figure below.

DC motor speed control using Arduino, Control speed of the DC motor with arduino, How to control the speed of the DC motor, using Arduino, Arduino DC motor speed control, Controlling the speed of the DC motor with Arduino

  • When we enter the command in the serial monitor of the Arduino software. Motor will start to deaccelerate and a statement Motor Deaccelerates will be printed on serial port.
  • The same statement will be printed on the LCD as well as shown in the figure below.

DC motor speed control using Arduino UNO, Control speed of the DC motor with arduino, How to control the speed of the DC motor, using Arduino, Arduino DC motor speed control, Controlling the speed of the DC motor with Arduino

Thats all from the tutorial DC Motor Speed Control using Arduino UNO. I hope you have enjoyed this tutorial. If you face any sort of problem, you can ask me anytime without feeling any kind of hesitation. I will further explore my knowledge about Arduino projects in my later tutorials. Till then, Take care 🙂

2 Comments

  1. I want to find/write a program allowing me to use my dual H bridge to run a set up like what makebot mSpider (one of the set-ups for the mdraw bot kit) can do.Much like an X/Y plotter but hanging in mid air. Any suggestions for accomplishing this? I have tried to download many controller that would allow me to “draw” what I want to come out on the other end (at the “spider”) but I am having difficulties with zip files and such. I am currently experimenting with inkscape (recommended) but its not as easy to learn as they would like you to believe. I am trying to refamilurize myself with master cam but the “code” its generating is not being recgonized (has too many characters or such) by the controller. GRBL looks great but due to my inability to open zip files, its a bit of a loss. Any advice or insights you could lend would be greatly appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment