View Single Post
  #3   Spotlight this post!  
Unread 09-02-2016, 15:38
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: I2C Color Sensor not working

Quote:
Originally Posted by mikets View Post
I am not familiar with the I2C class in WPILib but it depends on whether the regAddress parameter in the I2C constructor is expecting a 7-bit address or 8-bit address. If it is 8-bit, then 0x3C is the correct address. But if it is expecting a 7-bit address, then it should be 0x1E. In the I2C spec, register address is actually 7 bits, the LSB of the 8-bit address is used to indicate whether it is a READ or WRITE transaction. So a 7-bit address must shift left one-bit to accommodate the READ/WRITE bit. The Modern Robotics Color Sensor spec specifies an 8-bit address. So it's already shifted one bit to the left. But if the WPILib I2C constructor is expecting a 7-bit address (i.e. it will internally shift one bit to the left and OR-in the READ/WRITE bit), then passing 0x1E to it is correct.
I recommend you try both and see which way it is.
The cRIO expects 8 bit, the roboRIO expects 7 bit.
Reply With Quote