DIGITAL TACHOMETER

3,847

15

7

Introduction: DIGITAL TACHOMETER

This is a Digital Tachometer using Hall Effect Magnetic Sensor, Arduino Nano and show the result on 4 Digit 7 Segment Display.

Its very simple project to build.

As you see on circuit diagram, we only need 4 resistors to limit the current for the 7 segment display.

COMPONENTS:

  1. ARDUINO NANO V3
  2. HALL EFFECT SENSOR MODULE
  3. 4 DIGIT 7 SEGMENT DISPLAY (12 PINS)
  4. 4 X 330OHM RESISTOR 1/4W 5%

Step 1: CREATE PCB & CODE

I'm using Fritzing Apps to create a PCB.

The size is about 40mm x 40mm using Single Layer PCB

There are four jumper on PCB.

THE CODE:

// DIGITAL TACHOMETER
// 4 DIGIT 7 SEGMENT DISPLAY // by SAFT7ROBOTICS.com

int sensorvalue; int state1 = HIGH; int state2; float rps; float rpm; long prevMillis = 0; long interval = 200; long currentTime; long prevTime = 1; long diffTime; int sensorthreshold = 30;

//ABCDEFG,dp const int numeral[10] = { B11111100, //0 B01100000, //1 B11011010, //2 B11110010, //3 B01100110, //4 B10110110, //5 B00111110, //6 B11100000, //7 B11111110, //8 B11100110, //9 };

//pins for decimal point and each segment //dp, G, F, E, D, C, B, A const int segmentPins[] = { 4, 7, 8, 6, 5, 3, 2, 9}; const int numberofDigits = 4; const int digitPins[numberofDigits] = { 10, 11, 12, 13}; //digits 1, 2, 3, 4

void setup() { //set segment and DP pins to output for (int i = 0; i < 8; i++) pinMode(segmentPins[i], OUTPUT);

//sets the digit pins as outputs for (int i = 0; i < numberofDigits; i++) pinMode(digitPins[i], OUTPUT); }

void loop() { sensorvalue = analogRead(0); // read from pin 0 if (sensorvalue < sensorthreshold) state1 = HIGH; else state1 = LOW; if (state2 != state1) { if (state2 > state1) { currentTime = micros(); // Get the arduino time in microseconds diffTime = currentTime - prevTime; rpm = 60000000 / diffTime; // calculate how many rev per minute

unsigned long currentMillis = millis();

if (currentMillis - prevMillis > interval) { prevMillis = currentMillis; } showNumber(rpm); prevTime = currentTime; } state2 = state1; } }

void showNumber (int number) { if (number == 0) showDigit (0, numberofDigits - 1); //display 0 in the rightmost digit else { for (int digit = numberofDigits - 1; digit >= 0; digit--) { if (number > 0) { showDigit(number % 10, digit); number = number / 10; } } } }

//Displays given number on a 7-segment display at the given digit position void showDigit (int number, int digit) { digitalWrite(digitPins[digit], HIGH); for (int segment = 1; segment < 8; segment++) { boolean isBitSet = bitRead(numeral[number], segment);

//isBitSet= ! isBitSet; //remove this line if common cathode display digitalWrite(segmentPins[segment], isBitSet); } delay(5); digitalWrite(digitPins[digit], LOW); }

Step 2: TESTING..

I test this tachometer using computer fan with attached magnet on fan blade.

Finally I put Hall Effect Sensor Module on my Mini Drill Machine, and test the sensor.

Tachometer running well.... YEAY!!

Be the First to Share

    Recommendations

    • Make it Glow Contest

      Make it Glow Contest
    • First Time Author Contest

      First Time Author Contest
    • PCB Challenge

      PCB Challenge

    7 Discussions

    0
    petervdm99
    petervdm99

    1 year ago

    The print layout is faulty pin 4 of the display is not connected

    0
    AlbertoB95
    AlbertoB95

    Question 2 years ago on Step 2

    <br><div></div>

    266/5000


    Good work, Mr. Saftari. Do you think it is possible to implement the code to obtain an output signal based on the number of revolutions? Let me explain, I would like to get an output signal which, however, is increasingly delayed as the speed increases.

    Buon lavoro, signor Saftari. Pensi che sia possibile implementare il codice per ottenere un segnale in uscita in base al numero di giri? Lasciatemi spiegare, vorrei ottenere un segnale in uscita che, tuttavia, è sempre più ritardato all'aumentare del numero di giri.

    0
    AlbertoB95
    AlbertoB95

    2 years ago

    Good job Mr Saftary. Do you think it is possible to implement the code in order to obtain an output signal according to the number of laps? Let me explain, I would like to get an outgoing signal which, however, is increasingly delayed as the number of revolutions increases.

    0
    gggbbb
    gggbbb

    2 years ago

    Hey, nice tutorial. What kind of 7 seg. 4 digit display did you use? Common Cathod or Common Anode? I bought a CC one and I'd like to try this project.

    0
    bobparks
    bobparks

    3 years ago

    I've had problems getting it to work. I have tried both a nano and a promini. When connected, the segments on the display just flash in no set order. When I connect the hall effect sensor the lights go blank. The hall effector light does blink when the magnetic field goes by. I tried using 300 ohm resistor and it did the same thing.

    Any suggestions?

    Thanks,

    Bob

    0
    TheThinker
    TheThinker

    3 years ago

    Nice! Thanks for sharing!

    0
    'DanangS
    'DanangS

    3 years ago

    Good job master...