The S3 robot has internal encoder sensors and pre-programmed logic to keep the robot going exactly where you programmed it to go. Without encoders, it would be difficult to make the S3 travel in a straight line as pairs of motors are never precisely matched on their own.
Encoder sensors monitor encoder ticks (explained further, below, in Did You Know?) that the S3 uses to adjust left and right motor speeds as it performs maneuvers. These sensors are what allow the robot to precisely match the speed and/or distances as defined in your program. If the surface you are working on is smooth, such as a desktop, encoders will enable the S3 to return to the programmed starting point and do precise dead reckoning navigation.
Encoders provide a closed loop control system where the drive speed may be controlled and measured continually during operation. The S3’s motors have a gearbox on one side and an optical encoder on the other. The optical encoder has four slots which are counted by a change of state in an infrared slot sensor. With the gear reduction, a full rotation of the wheel has 507.4 encoder transitions or encoder ticks. The S3 robot’s internal encoders are mounted on the printed circuit board (PCB), connected to the motor shaft. If you'd like, you can carefully open up your S3 and take a look – but be sure to save all hardware you remove so you can properly seal the shell when you are done.
/
The S3 has 507.4 encoder counts per complete wheel revolution (0.491 mm / count). The diameter of the wheel is 3.15” (80 mm).
Circumference = pi * diameter (C = π d)
To determine how far the S3 travels when the wheel turns one complete rotation you could use the following formula to determine the circumference of the wheel:
C = π d
In this equation “C” represents the circumference of the wheel and “d” is its diameter. The number π is the mathematical constant pi, commonly approximated to 3.14159. Using only two significant digits, one which was obtained by measuring the wheel, C is equal to (in imperial and metric):
C = (3.14)(3.15 in)
C = 9.89 in
or
C = (3.14)(80 mm)
C = 251.2 mm
The drive distance block lets you program the S3 to move an exact distance.
Remember: Your S3's speed is affected by the slope and material of the surface it is driving on. Refer back to the previous tutorial if you need a reminder about the effect of real world limitations on motion calculations.
The drive distance block is a time blocked command. The S3 must finish this command before continuing on to other blocks. Similar to using the drive speed block, the time required to reach your destination is a function of the speed you choose.
time (t ) = distance (d) / rate (r)
How long does it take to travel a certain distance? You are familiar with the equation d = rt from the prior tutorial where you used the drive speed block with rate and time, solving for distance (d). In this example, you have distance (d) and rate (r) and can solve the same equation for time (t).
An S3 robot moving a distance (d) of 100 cm at 100% speed (r) should take approximately twice as long (t) as an S3 moving 100 cm at 50% speed.
Putting these values in the t = d/r formula we derived above demonstrates this point.
Going half the speed takes about twice as long as full speed, but you wind up at exactly the same place.
Your blocks might look like this:
total time = t(first drive distance block) + t(second drive distance block)
For the first drive distance block the S3 moves 1 m at 100% speed:
time = distance / rate time
time = (1 m) / (0.18 m/s)
time = 5.56 s
For the second drive distance block the S3 moves 1 m at 50% speed:
time = distance / rate time
time = (1 m) / (0.09 m/s)
time = 11.11 s
total time = 5.56 s + 11.11 s = 16.67 s
Hint: 100% speed is 0.18 m/s and 50% speed is 0.09 m/s. 75% speed is approximately halfway between 50% and 100%.
Hint: You will also need to calculate the speed(25%) which is halfway between speed(0%) and speed(50%).
Hint: Re-read the "Did You Know?" section above for an explanation of encoder counts/ticks.
Special thanks to Parallax friend Whit Stodghill for his assistance in writing, editing, and testing material for these S3 tutorials.