top of page

Project Name :Measuring a motor speed in RPM

 

Project description:

The motor drive a round black wheel. a small segment of the wheel covered with white paper.

The sensor - TCRT5000 dedect the difference in color and a counter count the rounds. In Parallel a Clock measure the ellapsed time.

A simple calculation produce the speed in RPM-Rounds per minute.

 

Components:

  • Sensor based on the TCRT-5000 sensor.

 

 contact to                                                    yohizu@gmail.com

 

 

Arduino code

 

 /*

RPM measuring
 This example code is in the public domain.
Create 19 February 2015
  by Yohi Zucker

 

This sketch use  a IIC LCD  with 16 Char per line X 2 lines
We use as well the Analog reading of TCRT5000 sensor connected to
A0 to dedect a white color on black background. it used to measure and calculate
the rpm of a geared motor.
LCD - SDA connect to A4.
LCD - SCL connect to A5.
LCD adress is 0x27.
Sensor TCRT5000 output to A0.
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

int tcrt;  //sensor output value. also it appear as analog it output will very between 0-1 when no dedection, 700-750 when white detect.
 int counter;  //count the revolution.
  float n;  //time mesuring
  float v;  //calculated rpm
   
void setup()

{

 lcd.begin(16,2);
 counter=0;  // initializing veriabels
  n=0;

}
void loop()
{


lcd.setCursor(0,0);  //set the cursor at theleft of first line .
tcrt=analogRead(A0);//read sensor value.
n=millis()/1000;//start time mesuring in seconds.

if (tcrt>500)
{
  counter=counter+1;//if white line dedect, increase counter by 1.
  lcd.print("ROUN=");
  lcd.print(counter);
  lcd.print(" ");
  lcd.print("TIME=");
  lcd.print(n);
 lcd.setCursor(0,1);
 lcd.print("RPM=");
 lcd.print(60*(counter/n));//calculate in rpm and display.
 
  delay(\(\(\(\(\(\(80);
  /*this is an important value. As the white line has some width
  // (mine was about 2 cm.) The loop can run more than once and
  //detect the same line. This value, 80 ms asure that the whole width
 // of the white line will pass when the sensor  will try to
 //sense once again. the higer the RPM of the motor, the smaller this value should be.

// It is a challenge for  someone to make this value choosen by the software..
*/
  }

}


 

bottom of page