October 19, 2010 by Earnhardt Hi ALL, I’m a newbie to the microcontroller and this site; I just purchased & got the NerdKits and hope you Gals & Guys could help. I am looking for a fast and easy way use my nerdKit to get RPM information from a rotating motor shaft and then display it on GLCD. I was thinking of using a Hall Effect Sensor. Since I am new at this and in the need to get it done quickly anyone have simple Source Code and parts for the circuit design I could use. Once I get this RPM information to display on the GLCD I could work on changing and trying other things later. Search the Nerdkit forum for RPM, this has been discussed a lot. Ralph Hi Earnhardt, One of my favourite customer projects of all time is the Hamometer described in this forum post. He did pretty much what you are describing, used a hall effect sensor to measure RPMs. Depending on how fast your motor is spinning this might not work though. Humberto Earnhardt, Below are the pertinent sections of code, pulled from a larger program, that I used to determine the RPM and velocity of a wheel. The setup sounds similar to Hamometer. I have two mags 180 degrees out from each other on the wheel shaft with a nearby mounted hall switch that is triggered on or off with each change in N/S polarity i.e. each pass of a magnet. I use an interrupt in the code to note the change from on to off. Timer setup below is from Nerdkits realtime clock. The velocity equation below assumes a .6 meter circumference wheel. The basic equation is v = delta d/ delta t; in below code delta d is .3 meters for each half rev and tt is delta time. The (t - ttlast)/20 part in the denominator of the velocity equation is there because the delta t value (tt) is only recalculated with an interrupt, which won't happen if the wheel stops, so I wanted the calculated velocity to decay to zero with t continuing to grow but with no new tt calculated. The numerator is multiplied by 10000 because my clock (t) is in .1 msec increments. Eric ``````// Clock set up void time_setup() { // setup Timer0: // CTC (Clear Timer on Compare Match mode) // TOP set by OCR0A register TCCR0A |= (1<