Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

DC Motor Speed Testing Using Arduino

By Ashutosh Bhatt

In DC motor speed testing, the PWM is applied to the motor and its duty cycle is varied from min to max. While applying PWM the actual RPM of DC motor is also measured and note down to see how motor speed (RPM) varies as PWM width varies. Along with this, the applied voltage to the motor is also measured to see the motor speed at different applied voltage. Finally, after noting down all the values, the observation table is prepared for pulse width (duty cycle), applied voltage and motor speed in RPM. This table is used to prepare duty cycle->RPM graph or applied voltage->RPM graph of the motor.

The given project demonstrates above example. It applies PWM to DC motor to vary its speed from min to max and max to min continuously and also measures following parameters.

1) PWM width in %

2) Applied voltage to motor

3) Motor speed in RPM

It uses arduino UNO board to generate PWM and measure/calculate above 3 parameters. These parameters are displayed on 16×4 LCD. It is very easy to vary the speed of DC motor using arduino. Arduino can generate PWM on its analog output pin and when it is applied to DC motor, its speed varies. So it is very simple and easy task. To measure RPM, opto-interrupt sensor MOC7811 is used. When motor completes 1 revolution, the sensor generates 1 pulse and such pulses are calculated by arduino to calculate RPM. So let us see how this is done. Let’s start with circuit diagram first, followed by its descriptions and operation.

CIRCUIT DESCRIPTION

As shown in the figure, the circuit is built using arduino UNO development board, 16×4 LCD, NPN Darlington transistor TIP122 and opto interrupt sensor MOC7811.

• The analog output pin 9 of arduino drives [email protected] RPM DC motor through TIP122. This pin is given to the base input of TIP122 through current limiting resistor R2 and DC motor is connected to the collector of TIP122.

• The internal IR LED of MOC7811 is given forward bias using 5V supply from the arduino board through current limiting resistor R1. Internal photo transistor is pulled up by resistor R4. The collector output of the transistor is connected to digital pin 7 or arduino.

•  LCD data pins D4 to D7 are connected to digital pins 5, 4, 3 and 2 of arduino while control pins Rs and En are connected to 12 and 11. RW pin is connected to ground. Vcc pin and LED+ pin are connected to 5 V supply from arduino board and Vss pin and LED- pins are connected to arduino board ground.

•  One pot is connected to Vee pin to vary contras of LCD.

Here is the snap of arrangement.

Prototype of Arduino based DC Motor Speed Controller

Fig. 1: Prototype of Arduino based DC Motor Speed Controller

CIRCUIT OPERATION

•  First, the motor is given 12 V supply through an external power supply. Next, the arduino board, LCD, and the sensor are given supply through USB from PC / laptop.

•  Initially, the LCD shows different parameters as “PWM ip: PWM Duty: PWM volt: speed:”

•  Then arduino starts applying PWM to motor with maximum pulse width.

•  So motor will start rotating at maximum speed. Sometimes a delay is provided to allow the motor to attain full speed.

•  As the motor starts rotating, the slotted wheel attached to its shaft will also rotate.

• The MOC7811 sensor is placed such a way that the slot of wheel passes through sensor air gap. Thus when the motor rotates one full revolution, the slot passes through sensor gap. Due to the slot in the wheel, the IR light falls on phototransistor. So transistor conducts and generates a negative pulse in collector output. Thus each rotation of motor produces a pulse.

•  The frequency of these pulses is actually RPS (- revolution per second) of the motor. To measure the frequency of this pulse first the ON time is measured then OFF time is measured and from this frequency is calculated as -:

Time period = Ton + Toff (in us)

Frequency = 1000000/time period

• This frequency is the speed of the motor in RPS. From this RPS, the speed of the motor is calculated in RPM as -:

RPM = 60×RPS

• The PWM input is varied from 250 to 100 in step of 15. That is directly displayed on LCD.

• The ON time and OFF time of PWM output are also measured to calculate the PWM duty cycle as -:

PWM duty = [PWM_Ton / (PWM_Ton + PWM_Toff)] × 100

•  Finally, voltage applied to the motor is calculate as -:

Voltage applied to motor = motor voltage × duty

= (12/100) × duty

•  First, the PWM input is decreased from 250 to 100 in 10 steps of 15 and then again it is increased from 100 to 250 and this cycle is repeated continuously.

•  So motor speed continuously decreases and then continuously increases. We can observe the change in motor speed that is displayed on LCD as speed in RPM.

Thus the given project varies the speed of DC motor and also measures it accurately. It displays % of pulse width applied to motor along with applied voltage. So one can note down motor speed in RPM at different voltage and pulse width in observation table for further needs.

Project Source Code

###


#include <LiquidCrystal.h>


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

#define pwm_ip 8

#define rps_ip 7

int ontime,offtime,duty,pw=255,rps,rpm;

float volt,period;

long int rps_Ton,rps_Toff,rps_time;   

void setup()

{

  pinMode(pwm_ip,INPUT);

  pinMode(rps_ip,INPUT);

  lcd.begin(16, 4);

  lcd.clear();

  lcd.print("PWM_ip:255");

  lcd.setCursor(0,1);

  lcd.print("PWM_duty:100%");

  lcd.setCursor(0,2);

  lcd.print("PWM_volt:12.00");  

  lcd.setCursor(0,3);

  lcd.print("speed:");  

}

void loop()

{

   for(pw=250;pw>100;pw-=15) // decrease the pulse width by 2%

     {

        analogWrite(9,pw); // generate PWM

        delay(7000); // apply delay for motor to attain full speed

        ontime = pulseIn(pwm_ip,HIGH); // measure ON time of PWM 

        offtime = pulseIn(pwm_ip,LOW);    // measure OFF time of PWM

        period = ontime+offtime;    // calculate total PWM time

        duty = (ontime/period)*100; // calculate % pulse width 

        volt = 0.12*duty;  // calculate applied motor voltage

        rps_Ton = pulseIn(rps_ip,HIGH); // calculate ON time of RPS pulse input

        rps_Toff = pulseIn(rps_ip,LOW);  // calculate OFF time or RPS pulse

        rps_time = rps_Ton+rps_Toff; // calculate total time

        rps = 1000000/rps_time;   // calculate frequency that is RPS

        rpm = 60*rps;   // calculate RPM from RPS

        lcd.setCursor(7,0); // display all the values

        lcd.print(pw);

        lcd.setCursor(9,1); 

        lcd.print(duty);

        lcd.print('%');    

        lcd.setCursor(9,2);

        lcd.print(volt); 

        lcd.print('v'); 

        lcd.setCursor(6,3);

        lcd.print(rpm); 

        lcd.print(" RPM");         

     }  

    for(pw=100;pw<250;pw+=15) // increase the pulse width and 

     {

        analogWrite(9,pw); // do same as above

        delay(7000);

        ontime = pulseIn(pulse_ip,HIGH);

        offtime = pulseIn(pulse_ip,LOW);   

        period = ontime+offtime;   

        duty = (ontime/period)*100; 

        volt = 0.12*duty; 

        rps_Ton = pulseIn(rps_ip,HIGH);

        rps_Toff = pulseIn(rps_ip,LOW); 

        rps_time = rps_Ton+rps_Toff;

        rps = 1000000/rps_time;  

        rpm = 60*rps;  

        lcd.setCursor(7,0);

        lcd.print(pw);

        lcd.setCursor(9,1); 

        lcd.print(duty);

        lcd.print('%');    

        lcd.setCursor(9,2);

        lcd.print(volt); 

        lcd.print('v'); 

        lcd.setCursor(6,3);

        lcd.print(rpm); 

        lcd.print(" RPM");        

     }   

}

###

 


Circuit Diagrams

Circuit-Diagram-Arduino-Based-DC-Motor-Speed-Controller_0

Project Video


Filed Under: Electronic Projects

 

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Introduction to Brain Waves & its Types (Part 1/13)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)
  • Performing Experiments with Brainwaves (Part 3/13)
  • Amplification of EEG Signal and Interfacing with Arduino (Part 4/13)
  • Controlling Led brightness using Meditation and attention level (Part 5/13)
  • Control Motor’s Speed using Meditation and Attention Level of Brain (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • What are the battery-selection criteria for low-power design?
  • Key factors to optimize power consumption in an embedded device
  • EdgeLock A5000 Secure Authenticator
  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver
  • Introduction to Brain Waves & its Types (Part 1/13)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Op amp non inverting amplifier not working
  • Making a ducted soldering fan?
  • Characterization values of a MOSFET in PDK
  • USBASP Programmer Mod
  • Measure AC current accurateley (100mA to 10A)

RSS Electro-Tech-Online.com Discussions

  • Need a ducted soldering fan for solder smoke extraction
  • How to search component to replace my burn RF inductor?
  • Question about ultrasonic mist maker
  • Someone please explain how this BMS board is supposed to work?
  • bluetooth jammer
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering