The V5 Optical Sensor is one of the powerful V5 sensors which are designed for complete integration with the V5 robotics platform.
Description of the Sensor
The V5 Optical Sensor is a combination of the following sensors:
- Ambient light sensor
- Color sensor
- Proximity sensor
Color information is available as RGB (Red, Green, Blue), hue and saturation, or grayscale. Color detection works best when the object is closer than 100 millimeters (mm).
The proximity sensor measures reflected IR (infrared) energy sourced from an integrated IR LED. As such, the values will change with ambient light and object reflectivity.
The Optical Sensor has a white LED to assist color detection in low light conditions.
The housing of this sensor has two mounting tabs with slotted holes to provide flexibility when mounting the sensor to a robot.
On the face of the sensor there is a small window where the optical sensors are located.
The width of the V5 Optical Sensor allows it to be nested into a piece of C-Channel.
Note: a 1/4 inch Standoff (275 - 1013) or an 8 mm Plastic Spacer (276-2019) needs to be used for this attachment in order to provide clearance for the V5 Smart Port.
In order for the Optical Sensor to be functional with the V5 Robot Brain, the sensor’s V5 Smart Port and a V5 Robot Brain’s Smart Port need to be connected with a V5 Smart Cable. The Optical Sensor will work with any of the 21 Smart Ports on the V5 Robot Brain. When connecting a V5 Smart Cable to the ports, be sure the cable’s connector is fully inserted into the port and the connector’s locking tab is fully engaged.
How the Optical Sensor Works
The V5 Optical Sensor receives light energy and converts the energy into electrical signals. The sensor's internal electronics (a hardware state machine) converts these signals into output signals to be received as an input by the V5 Brain.
As previously mentioned:
- The sensor’s color detection works best when the object is closer than 100 millimeters (mm) or approximately 3.9 inches.
- The proximity sensor measures reflected lR light intensity. This will cause the values to change with ambient light and object reflectivity.
The Optical Sensor needs to be paired with a programming language such as the VEXcode V5 or VEXcode Pro V5 to create a user program for the V5 Robot Brain to utilize the sensor’s readings to control the robot’s behavior.
The V5 Brain in concert with a user program can be used with the Optical Sensor to:
- Turn the sensor’s white LED light on or off.
- Set the white LED light’s percentage of power.
- Detect an object.
- Detect a color.
- Measure the percent brightness of ambient light.
- Measure the hue of a color in degrees.
Setup of the Optical Sensor
The placement of the Optical Sensor is very important to obtaining accurate readings. Be sure no structure on the robot is in front of the small optical sensor window on the face of the sensor. There needs to be a clear path in front of the sensor between any object being measured and the sensor.
Reading Optical Sensor Values.
It is helpful to use the Device Info screen on the V5 Robot Brain to see the information the Optical Sensor is returning. This can be done with the sensor connected to the Brain with the following steps:
Remove the V5 Brain Magnetic Screen Protector, turn on the Brain, and touch the Devices icon.
Touch the Optical Sensor icon on the Device Info screen.
Color mode. Place an object in front of the Optical Sensor. The display will show the brightness the sensor is detecting, the proximity of the object, and the number for the hue of the color of the object. Touching the LED brightness portion of the screen will change the brightness of the LED.
Note: Be sure the V5 Robot Brain has the latest version of firmware.
Adding the Optical Sensor as a Device in VEXcode V5
Whenever a sensor is used with a programming language, it needs to be configured within that language. With VEXcode V5 and VEXcode Pro V5, this is accomplished by using the ‘Add a device’ feature. To provide an example of this, the following steps will add the Optical Sensor as a device within VEXcode V5.
Select the Devices icon.
Select ‘Add a device.’
Select the Smart Port that the Optical Sensor is plugged into on the V5 Robot Brain.
Once the port is chosen, select ‘DONE.’
Note: There is an option to change the name of the Optical Sensor in the text window from Optical1 to a different name.
Once the Optical sensor has been added to your user program, a new set of sensor commands will become available.
For more information on the commands from the ‘Sensing’ category pertaining to the Optical Sensor, view the Help information (Blocks project or Python project).
Common Uses of the Optical Sensor
The Optical Sensor can produce several measurements which can be used to change the behavior of the robot.
These features can be used with either:
- The ‘Device info’ option on the V5 Robot Brain.
- Using the example project ‘Detecting Objects (Optical)’ found in the ‘Open Examples’ option in the File menu of VEXcode V5.
- Writing a custom user program with one of the VEXcode programs.
These features include:
- Detect an object. This feature allows your robot to detect an object when it becomes within the range of the Optical Sensor. A fun classroom challenge would be to place objects with different reflectivity in front of the sensor, such as a block of black foam rubber or a shiny ball of aluminum foil, to see if the object’s surface has any effect on its detection.
Detect a color. This feature allows your robot to identify the color of an object. A fun classroom activity would be to get some paint swatches from the hardware store in different colors (red, green, blue, yellow, orange, purple, cyan) and see if the shade of the color affects its detection.
- Measure the percent brightness of ambient light. This feature allows your robot to measure the brightness of the light around it. A fun classroom activity is to use this feature to measure the amount of light in a room with the classroom lights on and the classroom lights off. Then, write a custom user program so when the lights in the room are turned on your robot drives in a circle and when the lights are turned off your robot stops moving.
Measure the hue of a color in degrees. This feature allows your robot to provide a number for the hue of color of an object. The Optical Sensor reports the corresponding hue value in degrees from 0 to 359 based on the color wheel below. This provides a more precise measurement of color as compared to a generalized red, green, or blue designation. A fun classroom activity would be to measure the hue of different objects in the room and see which student can find the object with the highest hue number.
Uses of the Optical Sensor on a Competition Robot
The Optical Sensor will provide an excellent competitive advantage for competition robots. The ability to detect objects and their color will provide a great deal of information when designing autonomous routines.
An object’s presence and hue of color will provide helpful information with the detection of game pieces and or goals.
For example, in the 2020 - 2021 VEX Robotics Competition Game, Change Up, an Optical sensor could be angled to scan the floor in front of your robot's intake. As soon as one of your alliance's colored balls is detected, this could automatically turn on the robot's intake and pick up the ball.
No matter what the application the VEX V5 Optical Sensor is used for, there is no doubt it will be a welcomed addition for teams. The function of the sensor’s values are open for the imagination of the user.
The V5 Optical Sensor is available on VEX’s website.