Troubleshooting IQ (1st gen) Sensors

When your robot is not behaving as intended while using sensor feedback, you can follow a step-by-step troubleshooting procedure to find and fix your issues. This article will explain the steps in a troubleshooting process, and provide tips for how to use these steps. 

The steps of this process are:

  • Identify the problem
  • Check hardware
  • Check software
  • Analyze and apply data

Identify the Problem

The first step to troubleshooting your sensor is to identify which sensor is causing the problem. Compare the observed robot behavior with the intended robot behavior. Is the problematic behavior caused by a sensor? If so, which sensor? If you need more information to determine which sensor may be the problem, read the article(s) below related to the sensors on your robot.

VEX IQ (1st gen) Sensors:

Once you have identified which sensor is causing the unintended behavior, you can move forward in the process.


Check Hardware

The second step is to check the hardware on the robot to be sure that the sensor can function as intended. Each of the following hardware considerations could be affecting the functionality of your sensor.

Check Sensor Placement

Clawbot IQ build driving on a field, with an arrow pointing from an attached Color Sensor to a Green Cube in front of the robot.

Begin by looking at where the sensor is located on your robot. Is the sensor being blocked by anything, like another part of your robot? Ensure that the sensor has the space needed to operate as intended.

As shown here, the Color Sensor has a clear line of vision to the object it is meant to detect.

Check Sensor Connection

Brain screen is shown in the Settings menu with the Device Info option selected. Device Info is the second option in the list, below System Info.

Test the sensor’s functionality by looking at the data reported in the Device Menu on the VEX IQ (1st gen) Brain. This can help you validate that the sensor is plugged in and working.

To access the Device Menu, follow the steps in this article.

Diagram of a (1st gen) Brain connected to a Smart Motor and a Bumper Switch. The Bumper Switch is called out by an arrow and is labeled Sensor.

Once the Devices Screen is open, see if the sensor is reporting data.

If not, ensure your sensors are plugged in correctly. When plugging in sensors, you should hear a snap when the sensor’s locking tab is fully engaged in a port.

You can also try swapping out the sensor you are using with another to see if that resolves your issue.

If you changed something with your sensor placement or sensor connection, test your project again to see if this resolved the issue. If your sensor placement and connection did not change, move onto the next step to continue the troubleshooting process.


Check Software

Once you have identified that the sensor is placed on and connected to the robot successfully, you can look to the VEXcode IQ project next. Iterating on a project can help you to ensure that the data from the sensor is being used effectively in your project. The following strategies can help you with coding your sensor.

If you apply any of these strategies to your VEXcode IQ project, test your project again to see if this resolved the issue.

Check Firmware and Configuration

VEXcode IQ with a connected Brain and the Brain dropdown menu opened, indicating that it can be used to check the Brain's firmware. The VEXos version is listed as 2.2.0 and to the right there is a Force Update button.

Begin by ensuring that your IQ Brain’s firmware is up to date.

See this article for information about how to update firmware on the VEX IQ (1st gen) Brain.

VEXcode IQ Devices menu with a long list of connected devices shown. This menu can be used to make sure each sensor is connected properly, and to check its specific port on the Brain.

Now that you are sure all devices are correctly connected to the Brain, check the Device Configuration in VEXcode IQ.

Check to be sure all of the sensors are present in the configuration. Then, check to be sure each one is connected to the correct port.

Change any incorrect device configurations.

Run an Example Project

VEXcode Blocks Example Projects menu with a variety of projects across different categories to choose from. The Sensing category is highlighted.

Open an Example Project that uses the sensor you are troubleshooting. You can select the ‘Sensing’ category to filter example projects.

For more information about IQ Blocks Example Projects and Templates, see this article.

For more information about IQ C++ Example Projects and Templates, see this article.

VEXcode IQ with an Example Project opened from the Sensing category, including a stack of code blocks and a note with a description of the project. The note is highlighted.

Once open, read the Note to determine if the functionality in the example project aligns with what you are trying to do with the sensor.

In the example project shown here, the note indicates that this project provides an example of how all the available Distance Sensor commands can be used with the robot.

Run the example project and observe the robot behavior. Then look at the project to see how the sensor data is being used in order to cause the observed behaviors. You may want to run the example project multiple times to help with this.

You may also want to try to create your own simplified project to apply what you have learned from the example project to your task.

Use Other VEXcode IQ Tools

There are also tools and strategies that you can use to help you as you learn more about coding your sensor in VEXcode IQ. You can learn about the blocks or commands in the Toolbox individually by using the Help. You can also view sensor data as a project is running to learn more about what the sensor is reporting.

VEXcode IQ with the Help menu opened and the Drive heading block selected. Descriptions of the block and how it can be used are shown along with images of example uses.

The Help

Read the Help for the blocks or commands in the example project, or in your project to learn about the data that is used, what values the command will report, and examples of how to use the command in a project.

View this article to learn more about accessing Help in VEXcode IQ Blocks.

View this article to learn more about accessing Help in VEXcode IQ C++.

Printing Data

You can also print data from the sensor as the example project or your project is running, to help you better understand what the sensor is reporting in real time. This can help you determine what reported values from the sensor to use as parameters in your project. 

Note that in a Blocks project, a separate {When started} hat block can be used to keep all of the printing commands organized in their own stack.

VEXcode IQ Blocks

VEXcode IQ blocks project that uses a When started hat block to print sensor data live while the project is running. The project has a When started block followed by 4 blocks in a Forever loop. In the loop, first there is a comment block that reads Print the distance to an object on the brain. Next, a Print block reads print Distance7 distance in mm on Brain and set cursor to next row. Next, a comment block reads Wait to print the value, and then repeat the loop. Lastly, a Wait block reads wait 0.1 seconds.

Select the image above to enlarge.

VEXcode IQ C++

int main() {
// Begin project code
// Change the font size to fit on the IQ (2nd generation) Brain's screen
Brain.Screen.setFont(mono12);

// Loop to print all distance sensing values to the screen
while (true) {
// Clear the screen and set cursor to top left corner of the screen
Brain.Screen.clearScreen();
Brain.Screen.setCursor(1, 1);
Brain.Screen.print("Found Object: %s", Distance.foundObject() ? "TRUE" : "FALSE");
Brain.Screen.newLine();

Brain.Screen.print("Distance - mm: %.0f", Distance.distance(mm));
Brain.Screen.newLine();

Brain.Screen.print("Distance - inches: %.0f", Distance.distance(inches));
Brain.Screen.newLine();

// A brief delay to allow text to be printed without distortion or tearing
wait(0.2, seconds);
}
}

Printing to the IQ Brain is helpful when you want to see the values changing as a VEXcode IQ project is running. This can help you determine what reported values from the sensor to use as parameters in your project. These print commands can be built into the VEXcode IQ project you have already created so you can see the sensor values change at specific times while the robot is moving. 

These example projects above show how to print values from the Distance Sensor to the IQ Brain. The comments in each project explain the flow of the project and use of each command.

Using the Device Menu on the IQ Brain is helpful when you want to view sensor values while manually manipulating the robot. You can access the Device Menu without running a VEXcode IQ project and see the values detected by a sensor. 

Brain screen is shown in the Settings menu with the Device Info option selected. Device Info is the second option in the list, below System Info.

Select the X button to access the Brain Settings, scroll down to Device Info, and press the checkmark button to open the Device Menu.

Brain screen is shown in the Device Menu. In this example, the Port 3 Color Sensor is shown, with Mode as 3 for Color, a Color value as Green, and a Distance value as Close. Below a message reads 'Press Check button changes Mode'. At the bottom of the screen, icons indicate that the arrow buttons can be used to scroll and the X button can be used to exit the Device Menu.

While in the Device Menu, use the arrow buttons to select the device you want to view more information for. The Color Sensor is selected in this image. For more information about viewing Device info on the (1st gen) Brain, see this article.


Analyze and Apply Data

Next, use what you have learned in the previous steps to adjust your original project. You can continue to use tools like the Help and printing data to enable you to use the sensor effectively to accomplish your goal.

You can also ask questions about your project to help you move forward. Think about things like:

  • Are you using greater than < or less than > in your project? Is the symbol facing the right direction? If you are using equal to = try replacing it with a greater than or less than, to use a range of values.
  • Are your parameters correct? Are you using the data from the sensor to set your parameters? Did you choose the dropdown option that you need?
  • Are you checking the conditions more than once? Try adding a Forever loop to your project, so that the condition is checked repeatedly when the project is run.
  • Is your project getting stuck? Are your conditions set correctly? If you are using nested loops, try simplifying your project to isolate individual behaviors.
  • Are your environmental conditions influencing the sensor? Is it too bright or too dark? Are there objects or people in the way? Try running your project in a different location to see if that helps.
  • Are you running the most recent version of your project? Have you downloaded your updated project to the Brain? Make sure you redownload the project each time you make a change.
  • Are you detecting the correct color? Is the sensor reporting a different color than the one you have in your project? Try changing the color parameter.
  • Are you detecting an object within the sensor’s field of view? Remember that the field of view moves in conjunction with the movement of the robot.
  • Are you using a waiting block while checking a condition? Be sure to use non-waiting blocks in a project when checking for a condition. View this article to learn more about waiting vs. non-waiting blocks in VEXcode IQ.
  • If you are coding in blocks, is your whole stack attached to the {When started} hat block? Blocks will only run when they are connected. You can listen for a click sound when you drag blocks and connect them together.

As you answer these questions, be sure to change one thing in your project at a time, test it, then evaluate whether that change was effective. Testing your project frequently can help you to more easily see how your code is connected to the robot’s behaviors.  You may need to repeat steps in the troubleshooting process multiple times to solve your problem, and that is ok. Each iteration will help you learn more about the sensor you are using and how to code it in VEXcode IQ.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: