Elliot Carter
Published © GPL3+

Quick Tachometer

This is a small, photoresistor-based tachometer for use on several different development boards (whatever you might have laying around).

BeginnerFull instructions provided30 minutes3,150
Quick Tachometer

Things used in this project

Hardware components

Photo resistor
Photo resistor
A specific photo resistor is not required.
×1
Resistors
You'll need three resistors. Read more to figure which ones you'll need for your project.
×3
Breadboard (generic)
Breadboard (generic)
×1
Teensy 3.1
Teensy 3.1
This is just one of the many platforms you can use for this simple tachometer.
×1
General Purpose Dual Op-Amp
Texas Instruments General Purpose Dual Op-Amp
×1

Software apps and online services

Arduino IDE
Arduino IDE
Whatever IDE you like to use, you'll just need a serial monitor.

Story

Read more

Schematics

Op-Amp Comparator

This op-amp circuit digitizes the change in resistance of a photo resistor. This simplifies the tachometer code and produces more reliable results than an analogRead().

Code

Teensy Tachometer

Arduino
The output from the op-amp is attached to pin 13 on a Teensy 3.2. This digital input has an attached LED so troubleshooting can be easier. Using an interrupt when the pin goes high, a boolean variable is set to true and then the RPM is calculated in the main loop, output to serial and the boolean variable is set back to false.
void setup()
{                
  Serial.begin(38400);
  
  pinMode(13, INPUT_PULLUP);
  
  /* Depending on the board you're using, the interrupt declaration might have
   * a different syntax
   */
  attachInterrupt(13, tick, RISING); 
}

long rev; //T
long prevRev = 0;
bool change = false;
int changeCount = 0;
double rpm;
double prevRPM;

void loop()                     
{
  if (change == true) {
    rev = millis();
    rpm = 60000/(rev - prevRev);
    if (rpm != prevRPM ) {
      Serial.println(String(millis()) + "~" + String(rpm));
      prevRPM = rpm;
    }
    prevRev = rev;
    change = false;
  }  
}

void tick() {
  change = true;
}

Credits

Elliot Carter

Elliot Carter

2 projects • 4 followers

Comments