Here we have used IR Sensor which can recognize the presence of an object in front of it. We have also utilized two-blade rotors and put the IR sensor near it in a way that when the blades rotate every time the IR sensor recognizes it. We employ the support of timers and Interrupts in Arduino to estimate the time taken for one entire rotation of the motor. Here it is a two-blade rotor, which means the function will be ordered 4 times in one revolution.
We can measure the RPM by utilizing the formulae, Where 1000/time taken will give us the RPS and multiplying it with 60 will give us the RPM.
rpm = (60/2)*(1000/(millis() - time))*REV/bladesInFan;
From this we get RPM then speed can be estimated by below formula:
Speed = rpm * (2 * Pi * radius) / 1000
Before putting the values, we need to convert radius from inches to meters
radius = ((radius * 2.54)/100.0) meters
Speed= rpm * 60.0 * (2.0 * 3.14 * radius)/ 1000.0) in kilometers per hour
Here we have worked with a 4 wire bipolar stepper motor for analog meter, which is having 200 steps per revolution.
Now we need to show 280 Kmh on the speedometer. For this stepper motor requires to move 280 degree
Here we have maxSpeed = 280 so the steps will be,
maxSteps = 280/1.8 = 155 steps
In the Arduino code, a map function is used to map speed into steps.
Steps = map(speed,0,maxSpeed,0,maxSteps);
After counting steps we can easily apply these steps in stepper motor function to drive a stepper motor.