Hall Sensor to Find Speed

Hi everyone, I have started a site up to upload my projects. My first project is measuring speed of a wheel using a hall sensor. To view what I have so far, please visit http://basicelectronixs.com/ and navigate to electronics > projects > speed sensor. So far I have implemented one version of the code but I will be posting another version up as soon as I tweak some things out. The version I have now measures revolution over x time while the newer version will measure x revolution over a given time period. This newer version which I will try to have up also consists of a op-amp design so feel free to look around, explore and learn! :smiley:


could you explain in more detail?

There is a function in the arduino called pulsIn(), it measures the period of a pulse.
It might be simpler or more accurate than what you are doing.

pulseIn() would not work for this since your trying to measure peak to peak and not from a high to low or low to high since if you think about it what if a wheel stops on a magnet, then it would have inaccurate readings. Measuring peak to peak will get the actual correct time.
Sorry it took so long to post back.

For a more detailed information, the link is as followed ---> http://basicelectronixs.com/node/41

If you measure the width of a single pulse (I assume this is what you mean with measuring peaks), it will be subject to calibration as the slope (rise/fall time) of the opposing edges is likely to be somewhat unpredictable. The PulseIn() function will cancel out such errors when you calculate the time difference between two sequential pulses and so is more accurate and appropriate for RPM/frequency calculations.

That project uses an A1302 linear hall effect sensor. This is not the right sort of sensor. The web poster says it is his first project and it shows.

The problem with a linear sensor is that you have to read the value with the analogue input A/D converter. This takes quite a long time and is going to add errors to your measurement. You need to use a hall effect switch, this gives a logic level output that you can use with pulseIn().

If you wanted to use the analogue vr sensor it would be easier to find the zero point crossing.

But as mike says it is easier to use a sensor that is active and outputs a digital square wave

Another approach... and it has its cons as well as its pros!... is to send the output from the Hall sensor to a counter. You can then visit the counter from time to time, and see the number of pulses since the last time you looked.

Implementing the counter is something I haven't tried... although it is discussed in various posts.

"... since the last time you looked..." will use "millis", and a stored record of what millis returned the last time you looked, and what the counter was at back then.

i have used the counter approach in other hardware and it works well

count the number of revolutions since you last looked and the time and you know the rpm / speed

i suggest you use the clock in the arduino and not the clock in windows !

another solution could be using a Schmitt trigger to clean the analog signal

I tgink the easiest way to do tgis is program an interrupt on digital pin 2. everytime it updates increase a counter by one and write it and the system time to the serial port

or calculate the speed and write that to the serial port

speed is distance/time