Encoders are a sensor placed normally on a shaft to provide feedback to controller. This feedback allows for the detection of position, speed and direction of motion control system. There are two types of encoders; absolute and incremental. Absolute encoders report back a location specfic position. Incremental encoders only indicate that there has been a change in postion and what that change was. In robotics we tend to mostly use incremental encoders as they are easier to use and have some more benefical advandages than that of the absolute encoder.
The encoders in the worldSkills collection are built into the motors already. This makes it easier for designing drive systems as an external encoder does not need to be designed in.
There is a lot of math assosiated with encoders. Before the encoder class can be used the distance per tick has to be calculated. The formula can be given as:
r= wheel radius
ticksPerRev= encoder pulses on the output shaft of the motor
gearRatio= an external gear ratio used.
Lets look at an example using the Maverick with the 100mm omni wheel attached directly on the shaft of the motor.
r= 51 mm (actual measured value)
ticksPerRev= 1440 (encoder counts per 1 revolution of the motor output shaft)
Therefor we can conculde that the distancePerTick for the Maverick using the 100mm omni wheels is 0.2225294796.
Now that we have the distancePerTick we can calculate the distance traveled. This is simply formulated by:
encoderCount= is the incremental count from the encoder
Lets look at a few examples:
One Wheel Rotation
encoderCount = 1440
The distance measured is in mm as the radius was specficed in mm.
Ten Wheel Rotations
encoderCount = 14400
Now that we know the math behind it, let’s look at how to program the encoder.