Introduction: Motor Speed Tester Using Arduino & IR Sensor

Hey !!!

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.

It is very useful for DIY creators & robot makers and is very easy to make. It requires only 5 minutes for set up.

This assembly works well and can measures rpm much accurately upto 5%. I had tested it till 10000rpm.

And Yes, this can be used for any type of motor Big or Small (industrial too)

What you can do with this?

  • Measure rpm / check rpm of motor
  • measure speed of robot m/s (step 4)
  • Maintain constant speed(rpm) of DC motor (step 5)

How to use

  1. Stick aluminium foil piece as reference point anywhere on shaft or on its attachment
  2. Start the motor
  3. Place IR sensor infront of the reference point.

That's it.

Step 1: We Require

Picture of We Require

Basic Requirement

  1. Arduino
  2. IR sensor
  3. Aluminium foil

LCD if you have

  1. LCD Display
  2. 10K potentiometer or I2C module(will reduce pins)

For controlling speed

  1. Motor Driver
  2. 10K potentiometer

A rigid stand if you have/can make (recommended)

Step 2: How It WORKS ??

Picture of How It WORKS ??

So what is the logic behind this ??

It works on basic principle of an encoder and it works much similar to encoder

When a shaft/body rotates, same point on it repetatively comes to original position after one revolution.

But for that it requires some time.

By measuring time (in second) between these two positions ie. completeing one revolution, we get time (second) required to complete one revolution.

Simply taking reciprocal of this value we get rps (revolution per second) of motor.

Multiplying it by 60 will give rpm

Simple haa ! ! !

RPM does not depend on Distance between centre of shaft and reference point.

Now to measure the time difference IR sensor is used. Aluminium foil is used set a reference point. Also it reflects light thus enhances sensitivity of IR. sensor gives HIGH output, when aluminium foil comes infront of the sensor. micros() command is used to measure time which is 10^-6 of second which can measure time lapse at high speed accurately.

Step 3: Preparation & Code

Picture of Preparation & Code

Basic min. requirement

If you want to measure rpm but don't have display.

No problem. You can measure on Arduino's Serial Monitor on PC.

Simply connect data pin of IR sensor to Arduino's pin 2 and connect +5 & ground pin accordingly.

Upload code and test on Serial Monitor

LCD Display

The assembly looks like mess. But it's really simple. Connecting LCD display requires too much wires and connections.

So if you have I2C connector for LCD then I highly recommend to use it. It requires only 2 Arduino pins.

Code

The code uses unsigned long to store time. The code is written so that only when input from IR sensor changes from LOW to HIGH, it will proceed ie. calculate time difference. So it will be triggered only when leading edge of aluminium foil comes in front of the sensor. So there are less chances of false triggering. Each time one revolution is completed, arduino measures time required and it's corresponding rpm which is then displayed on LCD screen. LCD will refresh its value every 0.1 second.

LCD PIN CONNECTIONS

  1. VSS = Ground
  2. VCC = +5V
  3. VEE = Centre pin of Potentiometer
  4. RS = Pin 8
  5. RW = Ground
  6. E = Pin 9
  7. DB0 = N/C
  8. DB1 = N/C
  9. DB2 = N/C
  10. DB3 = N/C
  11. DB4 = Pin 4
  12. DB5 = Pin 5
  13. DB6 = Pin 6
  14. DB7 = Pin 7
  15. LED+ = +5V
  16. LED- = Ground

Step 4: Update 1 : How to Measure Speed (m/s or Km/hr) of Robot

Picture of Update 1 : How to Measure Speed (m/s or Km/hr) of Robot

If you are mounting this on a robot and want to know speed of your robot then follow this -

A very basic principle.

Speed = Perimeter of wheel * speed of wheel

But perimeter is Pi times the Diameter of wheel

So Speed = PI*D * speed of wheel

Speed(m/s) = Pi * D(in meter) * rps

Speed(km/hr) = Pi*D(in kilo meter) * rpm * 60


Add this in code

const int D = _____ ; // Diameter in cm (include at the top)

speed = 3.14159*(D/100)*(rpm/60) // speed in m/s

speed = 3.15159*(D/100000)*(rpm*60) // speed in km/hr

Step 5: Update 2 : Controlling Rpm of DC Motor

Picture of Update 2 : Controlling Rpm of DC Motor

Now we know the rpm of the motor.

So it's not difficult to manage speed of the motor.

For this purpose we require a motor driver. EN (enable) pin on driver is used to vary speed of motor using PWM (pulse width management). So simply connect pwm pin (pin 11 used in code) to the EN pin on driver. Also set the pin on driver to HIGH which drives the motor.

Same thing can be done by using fast acting NPN transisor. Use resitors to limit current.

Potentiometer knob is used to set the rpm required.

TEST

I tested this code and assembly. Every thing is working well.

Code needed to be slightly fixed because rpm of motor fluctuates wrt set point (speed is not smooth).

But you can try it, it works well. If you have any solution then it will be great.

Advantage of using IR sensor for maintaining conatsnt speed of DC motor

Suppose somehow load is increased on the motor. Which will reduce the RPM of motor. By checking real time rpm, arduino will sense that rpm has been reduced. Accordingly arduino will send signal to increase power supplied to the motor in order to compensate the reduced RPM. Similar thing will happen if load is reduced. Thus a constant RPM will be managed in any condition.

Step 6: Tips and Troubleshooting

Picture of Tips and Troubleshooting

1) rpm does not remains stable / not accurate

Change sensitivity of IR sensor by turning knob. Use stand

2) Shows wrong RPM

Reset arduino because code uses micros() which overflows fast. if this not works change sensitivity

I will recommend you to use stand to hold IR sensor

Try this simple and useful RPM tester which is easy to make.

Give your feedback and suggestions.

Thanks :)

Comments

RegaW (author)2017-07-20

hey Rahul. What type the IR sensor that you are using? And can i request the circuit drawing of this project? Thanks :)

vikram2.reddy (author)2017-04-26

hey rahul .can i get the project report of this?

ateebhassan000 (author)2017-04-06

Hi Rahul...!!! I am getting error.....I am using Flying Fish MH Sensor Series. It has two lights one for power on and other for output indicator....I have copied your code and burn it into my Arduino...I am getting error that the indicator light on sensor is turned on..and LCD is showing RPM=0...
Then I have changed the LCD pin arrangements as LiquidCrystal lcd(12, 11, 5, 4, 3, 2); and dataIn = 7; NOw the sensor indicating light turns off it on when i put my hand in front of the sensor and turns off by removing hand. Now error is that LCD is showing starting RPM =4765 and when i placed rotating motor infront of sensor it is giving random values in thousands. MY LCD no is 1602A

kindly help me out this.....ateebhassan000@gmail.com

Rahul - S (author)ateebhassan0002017-04-07

Hi Ateebh. I think your setup is working well. Regular small DC motors generally have rpm in range of thousands without load on it. You can relate your test with the video I posted. You can try different motor (of known rpm probably upto 1000). The main problem of non zero initial value is the issue that could not be solved for the current program and still finding solution for it. And another thing is that as rpm increases, fluctuation in value also increases. This setup is just a simple basic version. Hope this clear your doubt...

Some advice - 1) Try varying sensitivity of sensor by varying trim pot on the sensor. 2) Use a sturdy stand for the sensor.

ateebhassan000 (author)Rahul - S2017-04-08

Thank you so much Rahul....One more thing I want to ask you is...I want to control the speed of Hard drive motor with potentiometer by using Arduino.....if you have any code, schematic relating this...kindly help me in this....i'll be thankful to you.

ASHISHS198 (author)2017-01-29

Can you please explain me the code(i.e tachometer_withoutLCD.txt) of rpm measurement without LCD. Actually, I have copied your code & using it for measuring RPM of my motor But I have encountered following problems:

1)After removing sensor I am still getting a non-zero rpm value on Serial monitor.

2)Initially, RPM value is not correct & after some time I am getting correct rpm value.

Thanks in Advance.

Rahul - S (author)ASHISHS1982017-03-22

Sorry for late reply.

I made only a basic version, so that I can check rpm of my motors. Program is written such that it will measure time difference between two successive trigger points. So it gives correct values only when motor is rotating. Else as you mention it will give non zero value. Thanks :)

ASHISHS198 (author)Rahul - S2017-03-22

First of all thanks for your reply.

I am using your RPM code in my Project, It would be really helpful if you will tell me that how I can resolve the problem no. 1 which I had mentioned in my earlier Comment.

Please Reply AS SOON AS POSSIBLE.

msk1994 (author)2017-03-16

I had used your (tachometer_withLCD.ino)code for ir sensor.But nothing appeared(values)in display. It looked blank. What i have to do?????.iam just trying your project.kindly reply me quickly .......

Rahul - S (author)msk19942017-03-22

I think there might be a wrong connection to the display. Check pin layout of your LCD display or try a different one, it may be faulty. sorry for late reply...

saiteja0555 (author)2017-03-18

Ir Infrared Obstacle Avoidance Sensor Module can i use this in this project please reply me as fast as possible

Rahul - S (author)saiteja05552017-03-22

Yes. You can use it..

mahmoudg29 (author)2016-12-19

thanks a lot :)

About This Instructable

33,345views

42favorites

License:

Bio: Hi, I am Mechanical Engineering student. But loves electronic mini projects. Also like to do creative things. In free time, I will be making something ... More »
More by Rahul - S:Motor speed tester using Arduino & IR sensorTime Sensor : Easiest way of Home AutomationArduino Shooting Game Arcade
Add instructable to: