Wow very interesting, I'd never considered measuring the time between pulses over number of pulses per time period before. Thanks for including links to your hard work, much appreciated from the UK.
Oh man thank you AGAIN. I've past the last 2 days trying to figure out why my tachometer wasn't working. Tried the number of pulses per time interval but had no success. But now you gave me a new way to look at the problem and it seems so much better! Thank you very much, I'll probably be able to retrofit my '69 car gauges with a more accurate one! :)
@@interlinkknight InterlinkKnight please show how to automatically lock a car when the car reached 40 kmph and AUTO unlock when engine is off from start. Awaiting with much appreciation. Thanks.
SO great. This video is SO great. I'm in a project right now just that requires just this (except my output must be directed to an analog 0-10V pin). You just saved me an ETERNITY of trial and error. GREAT job, kudos!!!!
Thanks for sharing! I was working with a hall effect sensor today and was frustrated by the inaccuracies and refresh rates. I will have to try your code.
Hi, fantastic stuff. Really helped me out. Your code comment " CurrentMicros should always be higher than LastTimeWeMeasured, but in rare occasions that's not true." Arduino documentation: "micros() This number will overflow (go back to zero), after approximately 70 minutes." Hope this helps.
Thanks so much for this awesome video and code. It's really well put together and the code is very well documented/commented. I'm really new to coding and Arduino, and just by reading your code and comments (and a lot of furious googling) I have learned so much. You have probably saved me months of work. Cheers.
@@interlinkknight InterlinkKnight please show how to automatically lock a car when the car reached 40 kmph and AUTO unlock when engine is off from start. Awaiting with much appreciation. Thanks.
Interesting RPM implementation, I've combined it with ESP32 PCNT and the results are really impressive. To do test in noisy pulse environment by reading RPMs from my gocart 2-stroke engine from spark coil (via induction coil). Thank you for sharing!
A really good Arduino program. Most of the Tachoprogram count the impulses per time. For a low rotation (city car) and for a use as speed control the reaction time they are to slow. And you thought on all situations. But even using a Hall Sensor Switch with Schmitt Trigger it was nescessairy to implement a RC Filter to avoid false interrupts. I use a disc with 36 magnets on a wheel with 60 cm diameter to measure and control up to 45 kph down to 2 kph until it shows Zero. Thank you verry much.
Great video I haven't played with Arduino in a very long time and this was very useful I actually took this code and added in a function to activate a relay as a kill switch at a set RPM with a set delay to use as a Small engine rev limiter
I hope it is ok to ask another question In your code - Simple tachometer (Serial)- you have: "FrequencyRaw = 10000000000/ PeriodAverage" to calculate the frequency using the period between pulses. but I think we need to use just 1000000 instead of 10000000000 If I am not mistaking the " PeriodAverage " in microseconds (1second = 1000000 microseconds). Thanks in advance
Nice job. I am using a Pro Mini board connected to Pin 2. I did find it necessary to use pinMode(2, INPUT_PULLUP) to avoid extraneous signals resulting in unstable results at higher speeds.
@@interlinkknight I have a project to.auto lock and unlock car please show how to automatically lock a car when the car reached 40 kmph and AUTO unlock when engine is off from start. Awaiting with much appreciation. Thanks.
Thank you, this is a great project! The most comprehensive guide. I am running this succesfully with one sensor and 4 magnets, but my readings are only starting at 18-20 rpm. I was wondering if adding more magnets and a second sensor would get me lower readings between 1-18 rpm. Also should I place the second sensor on the opposite side of the 1st sensor?
I don't recommend adding another sensor. To read low speed you just need more magnets in the wheel/shaft. The more pulses per revolution, the lower RPM you can measure
I want to implement this in a control system for measuring rpm to find a transfer function of a motor using a bump test. For that, I need a transient as well as steady-state response. Does smoothing give me an accurate transfer function or it will filter out values?
Absolute Genius... Code Works fine... Could you suggest adding calibration factor according to diameter of wheel... I want to use it to monitor speed of flywheel
It's called "Nextion display" and I designed the graphics using the Nexiton Editor. I made a few video tutorials about that display, so you can check it out
@@interlinkknight I already did build this set with Hall sensor and your program calculation quite accurate on Frequency reading compared with my Frequency Counter. Thank you.. Nice work
@@interlinkknight I have Question , Can I use the Basic NX4832TO35-011 instead of Enhanced version on this HMI file? because cost too expensive for the Enhanced version
@@interlinkknight actually I have a 3D printer and its filament sensor is only detecting filament either 0 or in 1 condition but I want to make a device which detect while filament is stucked ( non moving position ) for few seconds
Yeah, that would work. Make a wheel spin with the filament and a few magnets on the wheel. With the hall effect sensor detecting the rotation, if for a while doesn't detect pulses, then create an action like an alert. Although it has to detect if it's printing or not, so that way doesn't alert you when you are not printing.
Thank you for your service to the rest of us. Please forgive me if I'm overlooking it, but do you have the schematic for the hall effect sensor and the nano in here somewhere?
@@interlinkknight thanks for the reply. I do see the schematic showing the pull up resistor for the sensor, but what about the rest of the tachometer. I'm a little ignorant
Dear i have a question i want to measure the rpm using sensor such as magnetic pick up or inductive pick up which kind of sensor i should use to measure the rpm by sensing engine ignition coil hight tenshion cable side (i.e. electro megnation induction)?
Also could i just use hall effect switch A3144 for measuring magnatic lines of force in ignition coil directly? I am using arduino and in past i use pick up coil signal to measure rpm but now i want to measure it from ignition spark plug coil as most of market meters do in workshops
There's only one way to find out if the magnetic field created by the ignition coil is enough for the hall effect to detect the pulses. Try it! You can also try with a coil. I never tried any of this so I can't help you. But you don't loose anything by trying. Let me know how it goes.
Great video thanks for the info! I am looking to measure the shaft deceleration. When applying a brake, I would be interested in taking a speed measurement every fraction of a second (maybe every tenth?) and seeing how quickly it came to a stop on a graph. I'm assuming I would have to increase the number of magnets to get this kind of accuracy. Do you think these components in your video would be capable of achieving this?
You use a 3D printed disc with 36 magnets, every 10° and run the hall sensor to the first interrupt pint of an arduino uno.. Then you use the library "elapsed Millis" which also features a elapsed micros time.. You setup the interrupt and a big variable You start the timer You enable the interrupt and set the time to 0.... When interrupt hits you store the time in an array or whatever you want... You get declaration by declining timer events, arduino uno is very much fast for this if your code is efficient
Thanks a lot for this tutorial! I have few questions: I would like to make a "shifter" for my motorcycle. The system would work like this: when I press the speed selector pedal, via a micro-contact I cut the ignition for xx ms depending on the engine speed while I shift into gear. The micro-contact would be connected to an input of the Arduino and an output of the Arduino would control a Mosfet to cut off the ignition. Would these inputs/outputs prevent your program from functioning correctly? Can you help me?
You could run that program without affecting the tachometer code because the tachometer counts the pulses using interrupts that are not affected by the main loop
Ur video is really awesome and Helpfull and very smart coding process. I have just one question , if I need to add another interrupt so i can calculate the rpm for two wheels , Is all i need is to replicate the same code with different variables ofc ? is that going to slow the calculation process?
Hi. Great Job. What kind of electrical/signal protection/filtering circuit do you use for the entries of pulses signals from sensors to arduino pins ? Do you think any kind of this protection/filtering circuit will be a must when tacho signal comes from a 12V PWM fan mainly used for Computer Liquid coolers ? Should i be confident about signal comes correctly filtered and protected from the origin at fan circuitry ? Thanks in advance and again, great, great job.
What you need is a schmitt trigger to filter noise, but I prefer using sensors with included filters, like that ones I mention in the video. As far I know, those computer fans already have a filtered sensor. Only one way to find out (trying). I guess you don't have an oscilloscope? That would help to see if the signal is clean. Basically if works, it's fine. If you see weird readings, then you need to add the schmitt trigger. I hope it helps. Good luck
Of course you can change the trigger type. The only thing you might want to change is the pulses per revolution. By default it's 2 pulses per revolution, but each person put different amount of magnets in their wheel/shaft
Thanks for this! I want to try to build this system on a motorbike (but I'm not quite sure if it will be enough with a small magnet). Will try to update this comment in the future with my results, in case it can help someone!
Many thanks for sharing this proyect, I am trying to put a 7 segment display to show the rpm value with ledcontrol library but it enter in conflict with the code. Maybe the problems is the clock? also trying to do a shift light with some ws2812 leds via fastled library and I have the same problem. Do you know how to solve the problem to use this libraries? Thanks!!
No idea what could be the problem. But since you also have a problem with a library, the cause might be on the code for the 7 segment display. What I do in those cases is to copy parts of the code, one a the time and see when stops working.
@@interlinkknight Many thanks for the answer! the problem where on the fastled library, I changed it to Adafruit_NeoPixel.h. Now I have woking the RGB led Strip as a shift light and the 7 segment display showing the rpm. Your code is the best with diference because you have real time rpm. Congrats and thanks for sharing!!
I am attempting to repurpose a treadmill motor. It has 2 leads for 0 to 90 vcd and two for the feedback sensor. Since that motor was given to me, I have no idea as to brand. I figure that leads just go to a magnetic coil rather than a hall effect transistor. Do you think a simple op-amp would bring up the signal enough for the ardiuno?
I haven't fully gone through all your code on this to understand it, but I went ahead and gave it a quick run. Seems to work great from around 300 RPM on up to 2000 RPM. But it's basically giving me very weird results below that. Sometimes it just shows 0 and sometimes it will start off showing an rpm over 49,000. In increased your zerotimeout to 1,000,000 but even this doesn't seem to fix it.
@@interlinkknight It's this sensor... www.amazon.com/gp/product/B07P1GKQRM/ref=ppx_yo_dt_b_asin_title_o06_s00?ie=UTF8&psc=1 I've used this and an IR sensor. Both work fine using my own code. Only seems to be a problem at low RPM with your code. Your code definitely has some nice features in it however.
I've been messing with your code for 2 days with no luck. First I tried adapting it to a digispark attiny85 and a 16x2 lcd screen I had laying around but not sure i have the interrupt pin changed correctly to pb3 (I can send code if interested). Switched to a nano and a KY-024 hall effect sensor module (same module I used with the digispark) and am getting readings all over the place. They are mostly very high (100,000+), the module has a potentiometer to adjust sensitivity and I can sometimes adjust it just right to get a fairly consistent reading but as soon as I adjust motor speed slightly up or down (15% +or-) the numbers go all over the place again and I have to re-adjust the sensitivity which involved moving the module all around and getting it realigned... Sometimes I am unable to get a consistant reading at all, also I DO have a 10k pullup on the digital, and yes I was connected to the digital line and not the analog output of the module. Could it be this type of module? Is this normal behavior? I thought that the code would automatically adjust based on the motor speed? I do have a 10k pullup on the data line. I ordered some bare A3144's to try but this should still work shouldn't it? (here's the module I was using arduinomodules.info/ky-024-linear-magnetic-hall-module/)
That's a very common mistake. Like I mentioned on the video, it's very important to have a very clean signal with a schmitt trigger. Your module is a Linear Hall-Effect Sensor, which that can't work. Think of it this way: the sensor has to be LOW or HIGH, and be sure to not send false pulses between the states (bouncing). How we do that? With a hall effect switch with an included schmitt trigger. The A3144 is exactly that. When you get to test with that, it's going to work. Arduino only counts when go from HIGH to LOW. There's nothing to adjust about that regarding speed. If you would see the signal in an oscilloscope, you would understand better why your sensor is not the proper sensor for this. Actually, I show this on the video too. Best of luck :)
I'm thinking of building a digital meter for my manual treadmill. So i can use "hall effect" chip with your code and multiple the rpm with distance the belt will cover when roller complete a rotation. Should work right? I never did any projects with arduino.
Thanks - this was very informative and easy to set up. Now I am trying to add onto your code to have it calculate rotational acceleration from changes in RPM over time. Do you have any suggestions on the best way to implement this - where to add this within your code and what variables would make the most sense to use?
That's interesting. I never done that but what comes to my mind is something similar with what I do with smoothing the RPM, which it stores several values in an array of variables. You just have to do simple math between the current reading and the old reading.
@@interlinkknight thanks a lot for your reply. I realized the current and previous recorded RPM values are saved in the array in your smoothing code, like you said. Now, to get the time that has passed between the instant those two RPM measurements were taken, would that be equal to your "PeriodBetweenPulses" value, or would I need to set up a new array with the timestamps corresponding to the RPM values?
I would do a new array, so the values are smoothed already. To get the time that has passed, you need to record the time in a variable using the micros function
Hallo , thank you for replying for a lot of my questions before ur projects are amazing. I just have one more question , i am working on two hall effect sensors that are integrated on the two wheel and i use your code to calculate the speed of each one then i calculate the median of the two wheel to get the speed in middle rear axle wheel. I am getting a lot of noise or more of non constant value of the speed , i solved that by increasing the value of numreadings which helps in stabalizing the value but uses a lot of dynamique memory of the arduino. Do you have any advices of what i can change to get more of a stable result value? , Thank you.
I'm glad you like my projects. About your problem, I'm guessing you are using a different hall effect part than mine? You put the pullup resistor in the output?
Could you theoretically add many magnets to 'take up' the gap between pulses for low RPMs? Then specify in the code how many pulses per rev? I'm new to Arduino and I'd like to expand my knowledge. Thanks!
Hello I've build it myself and it works amazingly!! But I'm facing an issue, how can I change the sensor PIN which is number 2? is it the part of the code where it's written " attachInterrupt(digitalPinToInterrupt(2), Pulse_Event, RISING); // Enable interruption pin 2 when going from LOW to HIGH." or how can i change hall effect sensor pin input signal? thanks
Yes, that's the lone that selects the pin. But you most use a pin that has an interrupt. In the Arduino uno and nano it's only pin 2 and pin 3. This means you can't use pins 4, 5, 6, etc. Why? We need to use a pin with interrupt because that's the only way to be sure it never miss a pulse, no matter how quick is the pulse
You would have to convert that high voltage of the spark plug to 5V. Also check that the signal is clean (no spikes or multiple HIGH/LOW on a single pulse). Then, it should work
Hi, congratulations for the excellent video. I would like to make a tachometer that reads 23/24,000 rpm. Do you have information on the maximum readable frequency with the Hall sensor? Thanks
Of course. Remap the rpm to whatever you calculate the mph is. I mean, to really say how many mph is in rpm depends on you setup. You can't say the speed of a disc in mph, for example. You would have to convert the motion in to linear.
Thanks so much for this awesome code.. I have some problem, i use d1mini and connect sensor to pin D6 (GPIO12).. and the problem is when first start to count rpm my d1mini always reset and go running to counting rpm, do you have idea?
I don't know, but I would disconnect the sensor and see if stop happening. Also, try with an arduino uno or nano to test the code and the sensor. Is the sensor output 3.3V?
Do you mean the OLED display? You would have to put a few if statements that if RPM is between 0 and 9 the text x position is a value in the center. If RPM is between 10 and 99 the text x position is a value in the center. If RPM is between 100 and 999 the text x position is a value in the center. Etc.
That's really nice. But what if I need to work with the IR sensor ! What to do then ? Like the one used in car speed capture system. That I must record the signal very fast without any bouncing.
If you need to use an IR sensor, just keep it enclosed so it doesn't get external light. And if you have to use a sensor that is very noisy, you need to add a schmitt trigger which will filter the noise. You can make one with an op-amp and a few resistors. This would only work if the output of the sensor is analog, not digital.
Hello. Do you think I can use your project to read the speed of a turntable? The speeds are extremely low: 33, 45, 78 revolutions per minute. I want to use an IR sensor (like the one you showed in the video). I tried to increase the calibration period to 1 second (1000000 uS), but I have false readings. Thanks
Do you think a rotary encoder disc with 100 gaps and a photoelectric sensor would work to measure rpm with a range of 0.00-10.00. I’m trying to make a precise tachometer for a very slow rotating machine. I’m planning to use the arduino uno and a 16x2 I2C display. Yours thoughts would be greatly appreciated. I’m very new to arduino and programming. Thanks
Yes, that would work great. The more pulses per second, the slower RPM you can measure accurately and in real time. Just remember to add the number of gaps in the code so it can calculate the RPM. Also, make sure the photo sensor gives a clean ON/OFF signal. without noise in the transitions. Good luck
I am also doing some similar automation.Thanks for the information.I have a question. Is it possible to take signals from any two wheeler to arduino and also the working of fuel gauges. Please share if you have any ideas.Thanks in advance.
Thanks for sharing your code. When I run your code, the rpm value is fixed even if i changed the speed. sometimes the values that appear seems like actual rpm (1000rpm) come out, but usually stays at 400~ 500 rpm. I only changed the ppr value in the code, is this a sensor issue?
The problem is always the signal of the sensor. If you have an oscilloscope, check the signal. You need to get a clean pulse from below 1v to above 4v.
Hi!, Thank you for share!, There any chance you can help me with my project ? trying to make a tachometer for car but planning to use TM1638 display and leds, Leds for tachometer and display digit for speed, also the leds are bicolor. Thank you in advance
Hello I am trying to connect it to Arduino mega but I already have connected a LCD from pin 0-13 and on other pins doesn't read the signals. do you have any suggestion