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 for distance measurement.
Besides distance, the encoder can also provide the speed of the motor. Speed can be represented in two main ways
m/s. Both have advantages and disadvantages but are also easy to implement.
Rotations Per Minuite (RPM)¶
RPM is the number of revolutions of the motor shaft every minute. For example, the Maverick DC Motor has a nominal RPM of 100. However, all motors will rarely rotate at the same speed. With the encoder, some math and the RPM can be calculated to use in formulas if required.
The RPM does not consider any gear ratios or the size of the output object, i.e., wheel.
Fortunately, the Titan has an internal RPM count, so no external math is required. It is as simple as calling the getRPM() functions.
Tip Speed or Velocity¶
RPM is excellent to have, but it does not give the actual speed of the object, such as a wheel. RPM only gives the speed of the motor shaft. In comes a simple formula to convert RPM to
Tip Speed or
D= Diameter of wheel in meters
60= conversion from minutes to seconds
Diameterof the wheel is
Sis the nominal speed of the Maverick at
When looking at the diagram above, the speed is only 0.0314m/s if using just RPM. When calculating for
Y the proper speed is given at 0.53407m/s. There is a clear difference between the two speeds. This can conclude that while the RPM is excellent, it is better to incorporate the adjusted Tip Speed or Velocity in equations to give more accuracy.