Let's Make Robots!

Binary wheel rotation counter


I have a platform consisting of 2 wheels that are being driven by these real large motors which are controlled by the Sabertooth motor driver, 25 Amps.

The Problem:

 The platform veers off to the left or right cause the motor speed and other hardware like ball bearings etc are not perfectly matched.

So i slapped on 2 hall effect sensors one for each wheel hoping that if i could read the rpm of each wheel and found that they dont match i could control the power of the motor driving the faster/slower wheel, effectly making my platform go straight.

These sensors give me a logic 1 when a magnet attached to the wheel passes by it.

A line like "ST.motor(1, power);" controls the power to motor 1 and "ST.motor(2, power);" controls motor 2.

My values of power can run from 0 for stop to 30 for maximum speed (technically that peed number can go upto 128).

Also I need to have the motors go in one direction only.

Can anyone direct me how can i use the 2 interrupts of arduino to help me compute the speed of each wheel?






Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

a simple encoder. Do your research on motor encoders. Or, wait for someone smarter than me to stop by your post, and, educate you on exactly what you want to know. :)

  • First click that goes by, note the time  remTime=millis()
  • Second click goes by, subtract  elapsedTime=abs(millis()-remTime)
  • Clear the "is it the first time or second time" flag or clear you remTime to 0 or something

Remember, you can't really do anything "time-related" inside of the interrupt routine itself, so it is better to have your interrupt routine simply count ticks and have your main rountine do its "timing" based on when the count changes.

For the love of God, could you correct the title of your post.