Small Tachometer – ElectroSchematics.com

This Arduino based little digital tachometer was originally created for counting the speed of turntables and fidget spinners. There is another application to consider – a rear wheel tachometer for stationary bikes!

The Motif

I wanted to use a compact device to measure and display the speed of some orbiting wheels. I quickly created a simple but compact digital tachometer using an Arduino Uno microcontroller and a pretty nice Arduino LCD Keypad Shield. The setup can measure how many times a switch/sensor action occurs over a specified duration. I used a common reed switch to send falling pulses to the controller. The controller then returns rotation per minute (RPM) values ​​by counting (and processing) the falling edge pulses rendered by the reed switch. Note that this reed switch/sensor method (see below) is how the usual bike computers/bicycle speedometers work. Reed switches are simply rugged, reliable, and right for numberless cycles!

The basic approach is to mount a small permanent magnet to the wheel and then sense when it passes by a fixed point. There are a couple of sensors available for magnetic proximity detection, commonly the reed switch and the hall effect sensor. The ‘passive’ reed switch is simple, and I happened to have a couple of dismantled bike computers in the drawer. I started off playing with one of those. A typical reed switch has two pieces of metal that touch each other when in the presence of an appropriate magnetic field. This completes a switch and allows you to detect whether the magnet is nearby.

Gearing Up (Hardware)

I used an Arduino Uno (Rev 3) with a DFR LCD Keypad shield (v1.0) since it is easy to use. You can use any Arduino compatible LCD panel/shield here but will need to tweak the default Arduino Sketch (code) to work smoothly with your chosen display. Likewise, the sensor can be opted by taste – I have several sensors (and sensor modules tested) and all work just fine (more later). Okay, we can start putting the hardware bits together. This is best described with a bare diagram.

Filling Up (Software)

The hardware setup alone will do nothing without some suitable instructions to do the magic. So simply copy-paste and upload the following Arduino Sketch to Arduino Uno.

[code]

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // DFR LCD Shield v1.0

const int tachoPin = 12;  // Speed Sensor Input

//const int backLight = 10;  // Optional-For Future!

const unsigned long sampleTime = 1000;

const int maxRPM = 3200;  // Maximum RPM for LCD Bar

int rpmMaximum = 0;




void setup()

{

  pinMode(tachoPin, INPUT);

 // pinMode(backLight, OUTPUT); // Ignore

  digitalWrite(tachoPin, HIGH); // Enable Internal Pull-up

//  digitalWrite(backLight, HIGH); // Ignore




  lcd.begin(16, 2);

  lcd.print("---TACHOMETER---");

  delay(4000);

  lcd.clear();




}




void loop()

{

  delay(100);

  int rpm = getRPM();

  if (rpm > rpmMaximum) rpmMaximum = rpm;




  lcd.clear();

  displayRPM(rpm);

  displayBar(rpm);




}




int getRPM()

{

  int count = 0;

  boolean countFlag = LOW;

  unsigned long currentTime = 0;

  unsigned long startTime = millis();

  while (currentTime <= sampleTime)

  {

    if (digitalRead(tachoPin) == HIGH)

    {

      countFlag = HIGH;

    }

    if (digitalRead(tachoPin) == LOW && countFlag == HIGH)

    {

      count++;

      countFlag = LOW;

    }

    currentTime = millis() - startTime;

  }

  int countRpm = int(60000 / float(sampleTime)) * count;

  return countRpm;

}




void displayRPM(int rpm)

{




  lcd.clear();

  lcd.setCursor(0, 0);

  lcd.print(rpm, DEC);

  lcd.setCursor(7, 0);

  lcd.print(rpmMaximum, DEC);

  lcd.setCursor(13, 0);

  lcd.print("MAX");




}




void displayBar(int rpm)

{

  int numOfBars = map(rpm, 0, maxRPM, 0, 15);

  lcd.setCursor(0, 1);

  if (rpm != 0)

  {

    for (int i = 0; i <= numOfBars; i++)

    {

      lcd.setCursor(i, 1);

      lcd.write(1023);

    }

  }

}




[/code]

Quick Runtime

When uploaded successfully, you will see the LCD coming alive. If the display does not start, reset/recheck your hardware and/or adjust the contrast control trimpot (blue) in the LCD Keypad Shield. Powering the prototype up through the USB port of your computer is not recommended. You will also need a USB power supply and the Arduino Uno R3 USB cable, or a 9V Li-ion battery and one Arduino 9V battery connector (2.1mm center positive barrel jack) to run your prototype.

Now it is time to test the sensor and see if it works. By gently moving a small magnet across the reed switch you should get some rough readings and a bar graph. At the top of the tachometer code you can see the configuration line which defines the bar graph display “const int maxRPM = 3200;”. Feel free to customize it!

Silly Knockings

It is good to note that the backlight of the LCD Keypad Shield by default is in an on state as it is hard-wired to VCC (look below). The LED backlight will draw much more current (typically in the range 50-200mA) and you will have to refer to the datasheet to get that number. On the internet there’s very little information on this. You can switch off the backlight by making D10 ‘LOW’ in the code.

For a full schematic drawing, you may go through this official link to download its PDF version http://image.dfrobot.com/image/data/DFR0009/LCDKeypad%20Shield%20V1.0%20SCH.pdf

The 16×2 character LCD module in my LCD Keypad Shield (mine resembles a counterfeit) has one 110Ω (111 SMD) resistor in series with the Anode (A) pin (Pin 15) trace. The value was verified by a thorough visual inspection after removing the 16×2 LCD plate from the shield. Estimated total current consumption of my running prototype is 180mA @ 9VDC.

Rapid Retrace

Be aware that all the bicycle speedometers I have inspected use a wrapped reed switch and magnet. If I keep the magnet close to the reed switch it always work well. Since we’ve the internal pull-up resistor attached to the reed switch to prevent D12 input from floating, usually we do not need an additional ‘filtering’ mechanism, but there is no harm in linking the optional capacitor C1 (100nF – 1uF) , also. If I am right, counting the pulse on the falling edge will greatly raise the success level.

Unposed Photographs

Here are a couple of workbench snaps captured while I was testing my agile prototype. The prototype delivered a fairly steady readout during the test run.

I also fed a 5Vp-p (50%) square wave signal from my digital waveform generator and got a steady readout from the setup.

That is all there is to the Arduino + LCD version of the little tachometer. Good luck with your RPM measurements!

Next Big Step…

The ‘secret’ goal of this preliminary project was to make sure I could actually build an improved digital tachometer, get it to work, and ascertain that I can get accurate readouts of slow to fast wheel rotations.

I also want to do something funny with oil-filled, and mercury-wetted reed switches/sensors (they are getting scarce though). Otherwise I will restart my play with Hall-Effect sensors. Thoughts?

The next step going forward will be to acquire an old stationary bike and build a modified digital tachometer for it. Yes, I am planning to make a small ‘pedal power generator’ at home, with the precise tachometer onboard, and I’ve a good reason for that inclusion!

Listing origins of certain web images, retouched and used by me in this article (no copyright infringement is intended):

  • Alarmy stock photo
  • Crutchfield dot com
  • Google Images

Leave a Comment