Announcement

Collapse
No announcement yet.

Problems using I2C device with Modern Robotics Core Device Interface

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

  • Problems using I2C device with Modern Robotics Core Device Interface

    This year, our robotics team decided to use ultrasonic distance sensors for detecting when our robot is close to walls instead of optical ones (the optical distance sensors worked poorly, because our field wall is transparent). As the only ultrasonic distance sensor Modern Robotics makes is the Range Finder, which didn't suite our needs, we decided to use the MaxBotix MB1242 sensor (http://www.maxbotix.com/Ultrasonic_Sensors/MB1242.htm). It claims to be I2C compatible, and the documentation (https://www.maxbotix.com/documents/I..._Datasheet.pdf) gives instruction about how to communicate over I2C.

    Our trouble with the sensor comes when we try to communicate with it via the Modern Robotics Core Device Discovery utility. After plugging the device into the Core Device Interface, we're able to see it in the I2C device list like any other I2C sensor. However, the CDD utility gives us 'Address', 'Register', and 'Value' fields, and we don't know what to write in the 'Register' slot to be able to communicate with the device.

    So, for those with some I2C experience, we would love some help figuring out how we can communicate with our sensor. If anyone else has also tried to communicate with a non-Modern Robotics I2C device, that info would be helpful as well. Thanks!

  • #2
    Quick update - the documentation (https://www.maxbotix.com/documents/I..._Datasheet.pdf) provides a good deal of info about how to communicate with the sensor, and even includes Arduino sample code. Our trouble is simply that we don't know how to use the Core Device Discovery utility, with its 'Register' field, to talk to the sensor.

    Comment


    • #3
      Try typing 224 into the register box and 81 into the value, then hit write. (These are decimal values, do not put 0x in front.)
      Next type 225 into the register box and hit read, record that value.
      Now type 226 into the register box and hit read again, record that value.
      Multiply the first recorded value by 256 and add that to the second value. This should be the distance in cm. (Theoretically register 225 will be zero for anything under 256 cm.)

      Each register has a distinct function. 224 is one you write commands into, and depending on the value sent, the sensor does something different. 81 tells it to send a pulse and record the distance.
      The other maxbotics have a 1024, or 10 bit A to D converter, so you need 2 bytes. Each register is one byte. Register 225 contains the MSB, and hopefully 226 has the LSB. Left shift the MSB 8 bits left (x256) and combine with the LSB.

      Just guessing here, but I have successfully used Core Discovery with MR sensors. Our Maxbotics is the analog one, we just read the voltage value from the AD port.

      Comment


      • #4
        Can't edit.

        "Record that value" in the above, means write down the number in the value field. When you do a write it sends the number in the value field to the sensor, when you read it displays the number returned in the value field.

        Comment


        • #5
          Originally posted by guberti View Post
          Quick update - the documentation (https://www.maxbotix.com/documents/I..._Datasheet.pdf) provides a good deal of info about how to communicate with the sensor, and even includes Arduino sample code. Our trouble is simply that we don't know how to use the Core Device Discovery utility, with its 'Register' field, to talk to the sensor.
          From the documentation, it seems like the register address (it's the physical address of memory to read or write) is 0XE0. Check the Poll Read, then click the READ button. Of course enter the correct address of the sensor. I used the utility to configure multiple ultrasonic sensors and test them.

          Comment


          • #6
            Looking at the Arduino code, I believe I am wrong as to how this one works. This looks like it is a no register device, so ignore my posts.

            Comment


            • #7
              We bought a very similar sensor from Maxbotics, but we specifically bought the analog/pwm/ttl/rs232 model so we don't have to use I2C

              Comment


              • #8
                We also have the analog output EZ series. It can be set to continually find the range, and you just read voltage on the A to D port. It looks like the I2C one has to be sent a command to range each time, then you have to wait 100 mS, then read the value. It ignores the I2C during a ranging operation.

                I don't have one to play with, but now I'm curious about this no register I2C version. If I got this right, most of the sensors we normally use you send the begin code which has the I2C 7 bit address and the LSb indicating read or write. This is followed with a second byte which is the register you want to address, and if a write send another byte to send the value to write to that register. From the Arduino code it looks like for the Max I2C you send the begin code, then the value in a write, skipping the register byte. The FTC SDK I2C commands I've seen so far always sends the register byte. It seems to me you could put the 81 (start a range find) in the register part of the command and then hope the sensor ignores whatever you put in the value box.

                But how do you do a read? The SDK when you give it a range to read, it walks up the registers. On our register based sensors, one byte is in each register. The Maxbotics appears to send the high and low bytes sequentially by sending two read commands to the I2C address. If the sensor ignores the additional register byte I guess a two byte read would get you the high and low bytes. Or would sending two separate one byte reads to the sensor to register zero work?

                Comment

                Working...
                X