Announcement

Collapse

Technology Forum Has Moved!

The FIRST Tech Challenge Technology forum has moved to a new location! Please take a look at our forum blog for links and instructions on how to access the new forum.

The official blog of the FIRST Tech Challenge - a STEM robotics programs for students grades 7-12.


Note that volunteers (except for FTA/WTA/CSA will still access their role specific forum through this site. The blog also outlines how to access the volunteer forums.
See more
See less

Using more than one Modern Robotics color sensor returns 0 for all values

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using more than one Modern Robotics color sensor returns 0 for all values

    Hello all,
    When our team tried to use 2 Modern Robotics color sensors plugged in to the same Device Interface Module and run the default example program (MRRGBExample), all of the values that show up on the telemetry are 0. Is anyone else having this problem and does anyone know how to fix this?

  • #2
    By the way, our code is here:
    package com.qualcomm.ftcrobotcontroller.opmodes;

    import android.graphics.Color;
    public class linedetect extends autoencode {
    @Override
    public void runOpMode() throws InterruptedException {
    hardwareMap.logDevices();
    setup();
    bottomsensorleft.enableLed(true);
    bottomsensorright.enableLed(true);
    waitOneFullHardwareCycle();
    waitForStart();
    float hsvValues[] = {0F,0F,0F};
    float hsvValues2[] = {0F,0F,0F};
    while (opModeIsActive()) {
    if(gamepad1.x && gamepad1.a && gamepad1.right_bumper)
    {
    bottomsensorleft.enableLed(true);
    bottomsensorright.enableLed(true);
    sensorRGB.enableLed(true);
    }
    else
    {
    bottomsensorleft.enableLed(false);
    bottomsensorright.enableLed(false);
    sensorRGB.enableLed(false);
    }
    Color.RGBToHSV(bottomsensorleft.red() * 8, bottomsensorleft.green() * 8, bottomsensorleft.blue() * 8, hsvValues);
    Color.RGBToHSV(bottomsensorright.red() * 8, bottomsensorright.green() * 8, bottomsensorright.blue() * 8, hsvValues2);

    telemetry.addData("Clear left", bottomsensorleft.alpha());
    telemetry.addData("Red left", bottomsensorleft.red());
    telemetry.addData("Green left", bottomsensorleft.green());
    telemetry.addData("Blue left", bottomsensorleft.blue());
    telemetry.addData("Hue left", hsvValues[0]);

    telemetry.addData("Clear right", bottomsensorright.alpha());
    telemetry.addData("Red right", bottomsensorright.red());
    telemetry.addData("Green right", bottomsensorright.green());
    telemetry.addData("Blue right", bottomsensorright.blue());
    telemetry.addData("Hue right", hsvValues2[0]);

    waitOneFullHardwareCycle();
    }
    }
    }

    Comment


    • #3
      Color sensors run off I2C bus. Each I2C device must have a unique I2C address. If you have two of them, they will have the same I2C address. Search the forum for the thread about how to change I2C device address on a device. You need to change one of the two color sensors to a different address.

      Comment


      • #4
        Wouldn't you be able to do that with setI2cAddress() on the color sensor?

        Comment


        • #5
          As Mike said, each I2C device must have a unique address; check out the example opmode to do this.
          Rohan Menon
          Programmer, Team 8441
          https://www.facebook.com/TotalReboot8441/

          Comment


          • #6
            Putting this here, as it took our team a while to figure this out.

            A simple way to change the address on one of your color sensors is to use the Modern Robotics Core Device Discovery application (http://www.modernroboticsinc.com/coredevicediscovery). Connect the color sensor you want to update to a Core Device Interface module, plug that into your computer's USB, then use the CDD and open the advanced window for the Core Device Interface. Refresh the list of I2C devices, then use the change address controls. Our team (#2997 Beauty Bot and the Beasts) set theirs to 0x70. This change of address will be retained, even when you remove the sensor from power.

            Then, in your code, at the top of your OpMode you'll want to add code like
            mySecondColorSensor.setI2cAddress(0x70);
            where mySecondColorSensor is the variable name to which you've assigned your sensor.

            So, it's actually pretty easy. Our team had a grueling experience due to the fact that they had a bum Core Device Interface module which made everything confusing until they ran through the Modern Robotics hardware troubleshooting guide and found they needed to replace the module. Modern Robotics shipped a replacement for free, quickly. (Thanks, MR!)

            Comment

            Working...
            X