Motor Speed Measurement Using Arduino

1,648

3

Introduction: Motor Speed Measurement Using Arduino

About: hi keep learning keep supporting.

Is it difficult to measure rpm of motor ???
I don't think so. Here is one simple solution.

Only one IR sensor and Arduino in your kit can do so.

In this post i will give a simple tutorial explaining how to measure RPM of any motor using IR sensor and Arduino UNO/nano

Supplies:

1. Arduion uno( Amazon ) / Arduion nano( Amazon )

2. IR Sensor( Amazon )

3. DC motor any ( Amazon )

4. LCD 16*2 ( Amazon )

Tools Used

1. Soldering Iron ( Amazon )

2. Wire Stripper ( Amazon )

Step 1: Step: 1 Ensure Working Condition of Sensors and Devices

What is an IR Sensor?
IR sensor is an electronic device, that emits the light in order to sense some object of the surroundings. An IR sensor can measure the heat of an object as well as detects the motion. Usually, in the infrared spectrum, all the objects radiate some form of thermal radiation. These types of radiations are invisible to our eyes, but infrared sensor can detect these radiations.

What is a DC Motor?
A direct current (DC) motor is a type of electric machine that converts electrical energy into mechanical energy. DC motors take electrical power through direct current, and convert this energy into mechanical rotation.

DC motors use magnetic fields that occur from the electrical currents generated, which powers the movement of a rotor fixed within the output shaft. The output torque and speed depends upon both the electrical input and the design of the motor.

What is Arduino?

Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. To do so you use the Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on Processing.

Download ARDUINO IDE

Step 2: How It Works?

So what is the logic behind this ??

It works much similar to encoder. Encoders are quit hard to understand for beginners. All you need to know is the IR sensor generates pulse and we are finding out the time interval between each pulse.

In this case the IR sensor will send a pulse to Arduino when ever its IR beam is intercepted with motors propellers. Normally we use propellers with two blades but I have used propeller with three blades as shown in the figure. depending on the number of propeller blades we need to modify some values while calculating RPM.

let's consider we have a propeller which has two blades. For every revolution motor the blade will intercept the IR ray twice. Thus the IR sensor will produce pulses when ever the intercepts.

Now we have to write a program which could measure the number pulses produced by IR sensor at a particular time interval.

There are more than one ways to solve a problem but we must choose which one is best in this codes i have measured the duration between the interrupts (IR sensor)
I used micros() functions to measure the duration of pulses in micro seconds.

you can use this Formula to measure the RPM
RPM = ((1/duration)*1000*1000*60)/blades

where,
duration - time interval between pulses.

60 - seconds to minutes

1000 - mill to sec

1000 - micro to mill

blades - no of wings in the propeller.

LCD Display - The Arduino updates the command and data registers of LCD display. Which displays the ASCII characters on the LCD display.

Step 3: Program Your Arduino Using Arduino IDE

#include <LiquidCrystal.h>
LiquidCrystal lcd(9,8,7,6,5,4);

const int IR_IN = 2; //IR sensor INPUT
unsigned long prevmicros; // To store time
unsigned long duration; // To store time difference
unsigned long lcdrefresh; // To store time for lcd to refresh

int rpm; // RPM value

boolean currentstate; // Current state of IR input scan
boolean prevstate; // State of IR sensor in previous scan

void setup()
{
  pinMode(IR_IN,INPUT);
  lcd.begin(16,2);     
  prevmicros = 0;
  prevstate = LOW;  
}

void loop()
{
 ///////////////////////////////////////////////////////////////////////////////// RPM Measurement
 currentstate = digitalRead(IR_IN); // Read IR sensor state
 if( prevstate != currentstate) // If there is change in input
   {
     if( currentstate == LOW ) // If input only changes from HIGH to LOW
       {
         duration = ( micros() - prevmicros ); // Time difference between revolution in microsecond
         rpm = ((60000000/duration)/3); // rpm = (1/ time millis)*1000*1000*60;
         prevmicros = micros(); // store time for nect revolution calculation
       }
   }
  prevstate = currentstate; // store this scan (prev scan) data for next scan
  
  //////////////////////////////////////////////////////////////////////////////////// LCD Display
  if( ( millis()-lcdrefresh ) >= 100 )
    {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Speed of Motor");
      lcd.setCursor(0,1);
      lcd.print("RPM = ");
      lcd.print(rpm);         
      lcdrefresh = millis();   
    }

}

Step 4: Simulation Using Proteus

This project worked perfectly fine when I tried simulating this with the help of proteus.

Instead of using IR sensor I used DC pulse generator
Which will simulated the IR pulse similar to one generated when the IR rays hits the propellers blades.

you have to make changes to your program depending on the sensor you use

IR sensor with LM358 must use this command.

if( currentstate == HIGH ) // If input only changes from LOW to HIGH 

IR sensor with LM359 must use this command.

if( currentstate == LOW ) // If input only changes from HIGH to LOW

Step 5: Hardware Execution

For schematic use the simulation pictures or the refer the program codes and make the connections accordingly.
Upload the program code to Arduino and measure the RPM of any motor.
Stay tuned for my next post and watch my YouTube channel.

Step 6:

Be the First to Share

    Recommendations

    • Anything Goes Contest 2021

      Anything Goes Contest 2021
    • Jewelry Challenge

      Jewelry Challenge
    • One Board Contest

      One Board Contest

    Comments