Optical Shaft Encoder - Sensors for VEX V5

Description

The Optical Shaft Encoder is a digital sensor which measures the rotation of a shaft using an internal encoder disk. The Optical Shaft Encoder’s housing has three slotted mounting holes to allow easy mounting to the robot’s structure.

The housing also has a removable cover which allows for cleaning and inspection of the internal encoder disk. In the center of the housing is the central hub of the encoder disk. This hub allows for a square shaft to be inserted through it and as the shaft rotates, it rotates the internal encoder disk.

The Optical Shaft Encoder is one of the 3-Wire series of sensors. From the side of the sensor’s housing there are two 3-wire cables. The “Top” cable is the cable closest to the housing’s mounting hole and the “Bottom” cable is the one closest to the center encoder hub.

"Top" and "Bottom" Cables
optical-shaft-wire.png

This 3-Wire sensor is compatible with the V5 Robot Brain or the Cortex. The sensor’s cables can be extended using 3-Wire Extension Cables.

In order for the Optical Shaft Encoder to be functional with the V5 Brain, both the sensor cables need to be fully inserted into a V5 Brain 3-Wire Ports. To measure a clockwise rotation of a shaft as a positive/forward direction the “Top” cable needs to be plugged into a 3-Wire port and the “Bottom” cable needs to be plugged into the next higher consecutive 3-Wire port. Note: only specific pairs of ports will work (AB, CD, EF, and GH).

For example, the “Top” cable on the sensor could be plugged into 3-Wire port A, and then the “Bottom” cable will need to be plugged into the 3-wire port B. The sensor will work if these cables are reversed, however a clockwise rotation will be measured as a negative/reverse direction.

The Optical Shaft Encoder comes in the Advance Sensor Kit or is available as a 2-pack and can be purchased here.

Optical Shaft Encoder 3-Wire Ports
Optical_Shaft_encoder..PNG 3-Wire_Port_-_2_ports.png

How the Optical Shaft Encoder Works:

As mentioned earlier, the Optical Shaft Encoder has an internal encoder disk with a central hub for a shaft to be inserted through and it will rotate as the shaft rotates. The disk has small slots around the circumference of the disk.

Above one side of the disk’s edge are two channels of IR LED lights and on the other side are two channels of IR light sensors. The light is blocked as the disk spins from one slot to the next. When this happens the sensor detects it and sends a digital signal pulse to the V5 Brain. This pulse indicates the shaft has rotated one slot. There are 90 slots, so 90 pulses indicates the shaft has made 1 full rotation.

Optical Shaft Encoder Disk
optical_shaft_disc.png
optical-shaft-ticks.png

The sensor’s two channels are set up so their signal pulses are out of phase by 90o. This allows the signals from the Optical Shaft Encoder to indicate which direction the encoder disk/shaft is rotating.

For instance, if the phase has channel one as the leading pulse, the V5 Brain reads this as the shaft is spinning clockwise; or else if the leading pulse is from channel two, this indicates a counterclockwise rotation. This not only allows the V5 Brain to determine the direction of shaft rotation, but it also allows the Brain to add or subtract readings for a net value of how much the shaft has rotated.

Phase Diagram of Signal Channels
Signal-phase.png

The Optical Shaft Encoder needs to be paired with a programming language such as the VEXcode V5 Blocks or Text to create a user program for the Brain to utilize the signal pulses to control the robot’s behavior.

The V5 Brain in concert with a user program can be used to convert the pulses from the Optical Shaft Encoder into direction of shaft rotation, amount of shaft rotation, and speed of shaft rotation. If the size of the robot’s drive wheels are included within the user program, the distance the robot travels and the speed of the robot can also be determined/controlled by using the sensor.

Determining Distance
determining-distance.png
distance-equation.png

Note: If the slots of the encoder disk within the Optical Disk Encoder become clogged with dust and debris the readings of the sensor will no longer be accurate. It is good practice to occasionally remove the cover from the housing and use canned air to blow out any loose material from the sensor’s interior.

Interior of the Optical Shaft Encoder
DSC_0227.JPG

Common Uses of an Optical Shaft Encoder:

As previously mentioned, an Optical Shaft Encoder can measure direction of shaft rotation, amount of shaft rotation, and speed of shaft rotation. However, the V5 Smart Motors also have excellent internal encoders which can measure the same values without the requirement an additional sensor. Nonetheless, there are some applications in which the Optical Shaft Encoder can provide some valuable readings. Some examples of these are:

Visualizing program values: Within a classroom setting, an Optical Shaft Encoder can provide easy access to the values of shaft rotation or shaft speed. Whether the shaft is used on a manipulator such as arm or for a wheel on a drivetrain, the values gathered from the sensor can be printed to the V5 Brain’s color touch screen or the V5 Controller’s LED display. This will allow the students to directly see the values their user programs are utilizing to change the behavior of the robot.

Input/Output ratio reading: Another great classroom use of an Optical Shaft Encoder is with the study of sprocket and gear ratios. An Optical Shaft Encoder can be placed on the output shaft of the “driven” side of the sprocket/rear ratio. A 1:1 power transfer ratio can be used to record an expected output reading for the Optical Shaft Encoder when the V5 Smart Motor is set to a certain power/speed for the input shaft “driving” side. Then different ratios can be assembled and the expected output for the ratio can be compared to the reading for the actual output.

OSE-InputOutput.png

Ramp testing: A fun classroom inquiry activity is to have the students assemble a “free-rolling” cart. A V5 Control System can be placed on the cart and an Optical Shaft Encoder is inserted onto one of the cart’s shafts. Then a user program can be made which will print out several of the cart’s speeds as it rolls down a ramp. The students can then change different aspects of the ramp or the cart and compare the results of the cart rolling down the ramp with the next iteration.

Uses of an Optical Shaft Encoder on a Competition Robot:

Flywheel speed: Some advanced flywheel designs use a ratchet system to drive the flywheel which throws a ball game piece. This is done so while power is not being applied to the flywheel by the V5 Smart Motor, the flywheel can free spin rather than losing energy from the resistance of the motor. In this type of design, an Optical Shaft Encoder inserted onto the flywheel’s shaft can provide a good method for its measurement. Note: The maximum range for accurate shaft rotational speed measurement is around 1100 RPM.

Isolated wheel/Optical Shaft Encoder: There may be a case (pushing game pieces or other factors) where a robot may experience drive wheel slippage. As soon as the wheels driven by a V5 Smart Motor begin to slip, the values from the motor’s encoders are no longer valid. In this case, an isolated Omni-Directional Wheel with an Optical Shaft Encoder on its shaft can be added to the robot’s chassis to accurately measure the movement of the robot. It is advisable to have this wheel assembly “spring” loaded through the use of rubber bands or latex tubing. This design will allow the measurement wheel to maintain adequate contact with the field surface without lifting the drive wheels off the floor.

Isolated wheel/Optical Shaft Encoder on a spring-loaded wheel assembly
OpticalShaftEncoder-ArmWheel.png

If the drivetrain has wheels which are not powered by a motor, another option would be to place an Optical Shaft Encoder on one of these wheel’s shafts.

Isolated wheel/Optical Shaft Encoder
OpticalShaftEncoder-Wheel.png

No matter what application the direction of shaft rotation, amount of shaft rotation, or speed of shaft rotation needs to be measured, the Optical Shaft Encoder can provide an accurate and effective sensor for the measurement.