Motor Encoders

A Motor Encoder is a sensor that makes a standard motor a “Smart Motor.” Standard motors can turn on and off but cannot track things like how fast it is spinning, which direction it is turning, or how many degrees it has rotated. An encoder is used to track this data. Without motor encoders, precise driving or moving robotic arms is very difficult.

Picture of an encoder

How it works

Most VEX encoders are Quadrature encoders that use optical technology. Inside the encoder, there is a small wheel with slots cut into it while a light sensor is pointed at it. As the motor spins, the wheel spins as well, chopping up a beam of light. The sensor counts these as ticks.

Picture

Because it uses two offset light sensors, the encoder’s internal brain can tell which sensor saw the light first, letting it know which direction the connected shaft is spinning and how fast.

Types of encoders

In the VEX robotics system, the encoder is typically built inside the casing of the motor. The VEX IQ smart motor encoder has a resolution of 0.375 degrees. This means that every time a motor shaft moves slightly. the encoder registers it. This allows the VEX IQ brain to smoothly control arms and drivetrains.

The VEX V5 Smart Motors encoder is also inside the casing of the motor. Because V5 allows you to swap out the internal physical gear cartriges to change your speed and torque, the number of ticks per full rotation may change depending on the cartrige you plug in.

  • Red Cartridge gives 1800 ticks per full rotation
  • Green Cartridge gives 900 ticks per full rotation
  • Blue Cartridge gives 300 ticks per full rotation

Math

When coding your robot, softwares like VEXcode Pro or PROS often automatically translate ticks into degrees or rotations for you. However, if you are writing custom code or building your own tracking systems, you need to know how to calculate it manually. To find how many degrees your robot has turned based on raw encoder ticks, use the following formula:

mathematical expression or equation

What You Can Measure

By reading data from a motor encoder, a programmer can get several live data points:

  • Position (Position): The total accumulated count of degrees or rotations form the moment the program started
  • Velocity (Velocity): How fast the ticks are changing over time, giving the speed of the motor in RPM (Rotations Per Minute) or percentage.
  • Target Status (isDone): Checks if a motor has reached its command target position. Checks if code is finished before moving to the next line of code.

Limitations

Remember that encoders only track the rotation of a motors internal gears. If your robot slips, the encoder will keep counting ticks because the motor is spinning, even while the robot is still. See Odometry and Localization for information on tracking systems.