Image courtesy of pixabay.com
Steps counting for position estimate
Odometry is the use of data derived from vehicle motion to estimate position changes. The new position of the vehicle can be calculated by counting the the turns of the wheels and measuring the vehicle's direction.
To count wheels rotation, we use encoders, and for the direction, a gyroscope.
The encoder is a device attached to the rear of the motor, that is used to track the turning of motor shafts to estimate position and motion information. Even though the motor and the encoder look like an indivisible block, the reality is that the encoder works independently.
The circuit of the encoder has two hall effect probes that react to polarity changes of the magnetic field of a rotating circular magnet coupled to the motor shaft. The probe generates a pulse for each polarity change. The phase difference of the pulses generated by each of the two probes determines the direction of rotation.
The gearbox reduces the wheel revolutions to a factor of the motor rotation equal to the Gear Ratio. Being practical, all you need to know is that the GM25-370 with a Gear Ratio of 1:75, any of the sensors generate 75 pulses by a full turn of the wheel. Knowing that a complete rotation of the axis is equivalent to a displacement of 16 centimeters, by counting the pulses of one of the sensors we can calculate the distance traveled and the speed at each moment.
If you take a look to the code of the Arduino project of the motor controller module you will see that it has been programmed so that with each pulse an interrupt is generated, and the time it occurs is recorded. The pulse count will give us the distance, and the inverse of the time divided by the Gear Ratio, the speed in revolutions per minute (RPM).
Connecting to the control module
The encoders are connected to the control module through connectors 4, right motor encoder, and 5, left motor encoder.
The cable can be made by splicing a 4-wire cable to the 6-wire cable that comes with the chassis kit. Do not rely on the color code shown in the figure because it may vary depending on the cable manufacturer.