Close

Mathematics behind Auto-Stop feature

A project log for Smart Motor Driver for Robotics

This motor driver is able to control a motor using PID by I2C. Taking precise control of a motor have never been so easy.

danny-frDanny FR 07/07/2018 at 23:210 Comments

One of the fancy features of this driver is the capability of stop the motor automatically at a desired distance, making easier precision navigation in a robot or maybe other kind of applications. Like a  conveyor belt or an actuator, just let your imagination fly. Applications are limitless, trust me ;)

Sounds good right? But it will not happen magically, we need to do the math. We need to obtain an equation that allows us to convert that desired distance into how many pulses the motor Hall sensor should give us to achieve the goal and stop the motor just there.

So let's get started, shall we? Normally robots use wheels and wheels are basically circles with a perimeter, so every time the wheel makes one turn the robot moves an equal distance to this perimeter. This is the key to solve the problem, if we know the perimeter of the wheel and the gear ratio of the motor we can calculate how many turns the motor should do to move the robot certain distance. Said this we have the main formulas involved.

But this way it doesn't help, we a different approach where the perimeter is the desired distance we want. So we really need this one, so Perimeter will be equal to distance.

This formula applies just for the wheel. Now to obtain how many turns  the motor should turn we just need to multiply it by the gear ratio. 

Remember that our Hall sensor will detect 3 pulses (or steps) per each turn of the motor, this is where that constants appears in the play. So we finally have: 

Where G is the gear ratio of the motor, d is the desired distance we will move and D is the diameter of the wheel. That's it, we enter the distance and we get how many pulses our Hall sensor should detect before it stops the motor.  Easier than you thought, right????

Just for reference, if we have a 45mm diameter wheel a fully turn will be equal to 141.4mm. This is the distance the robot will move for each wheel turn. With a 150:1 gear ratio motor it means that for every one complete turn of the wheel the motor needs to turn 150 times. If the Hall sensor detects 3 pulses for every motor turn we obtain 450 pulses for every turn of the wheel. So if we divide the diameter by the pulses we obtain the resolution. So our robot will be capable of moving an amazing super precise steps of 0.314mm!!! Cooooool...well in an ideal world, we will make some testing and explain more about the "ideal world" in the next post ;)

Discussions