Qu-Bot, A Quickly Programmable Robot User’s Manual
Page
48
of
52
8.4. Distance measurement
This sample code shows how to move robot for specific distance using encoder
sensors mounted near wheels. This code is made to move robot forward for
approximately 1 meter.
•
The diameter of the Qu-Bot wheel measures 66.3 mm. So the periphery of the
wheel becomes 208.182 mm (πD = 66.3 x 3.14 ).
•
The wheel has 8 holes in it so it gives 16 counts (8 on + 8 off) when it rotates 1
revolution. In one revolution it moves forward to 208.182 mm distance (periphery
of wheel). So at each count we get distance of 208.182 / 16 = 13 mm. This is also
the accuracy which we get when the robot moves on motor count.
•
If we want robot to move forward to 1 meter robot has to go forward until it gets
77(1000/13) motor counts on motor counter.
•
So this is how it works. When switch1 is pressed robot starts moving forward. The
right motor counter is already initialized at code start.
•
The while condition checks until the motor count reaches 76. We need 77 counts
but there is some inertia when the motors are stopped, so the robot moves a little
forward when motors stop, and we get approximately 1 meter move.