FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Rev Robotics Color Sensor v2

Solved!
Go to solution

So i ordered two http://www.revrobotics.com/rev-31-1537/

But I'm not sure how to program them, is there 3rd party libraries I have to download to use it. Or is there already libraries in labview that I can use?

0 Kudos
Message 1 of 10
(8,924 Views)

Hello RoboticsRocks,

 

Thanks for using the NI FRC forums. Yours is a very interesting question. I am not aware of any API already created for this sensor. However, it uses an I2C communication protocol, which should allow you to communicate with it using LabVIEW and the roboRIO.

 

Based on REV's website, this is the sensor that it has inside: TMD3782. In its datasheet you can find the addresses to communicate with the device.

 

To use I2C with the FRC framework in the roboRIO, you can find an example in the LabVIEW's Help tab > Find Examples.. > FRC Robotics > roboRIO > I2C.

 

You can also find an implementation in text-based language here: Writing code for a color sensor.

 

All the best,

0 Kudos
Message 2 of 10
(8,889 Views)

I attempted to write a project to communicate with the TMD3782 but encountered problems writing or reading from the sensor over the i²c bus. In the attached project, you look at and run "TMD3782 Open.vi", which I modified to find the source of the error message. With the switch "Write stuff" turned off, the program runs without error, but when you turn it on there is an error of "i2clib_write.vi<ERR> Input/output error". I can't figure out what is causing an error whenever I read or write to the device after it is open. Any suggestions?

0 Kudos
Message 3 of 10
(8,875 Views)
Solution
Accepted by MarkBalla

I have completed a LabVIEW project for the REV Robotics Color Sensor V2. It may need some adjustments to timing but it works pretty well.

Message 4 of 10
(8,847 Views)
Solution
Accepted by MarkBalla

I have completed a LabVIEW project for the REV Robotics Color Sensor V2. It may need some adjustments to timing but it works pretty well.

Download All
Message 5 of 10
(8,847 Views)

I have completed a LabVIEW project for the REV Robotics Color Sensor V2. It may need some adjustments to timing but it works pretty well.

Thought I would share it.

Message 6 of 10
(8,844 Views)

@PeacefulPaul wrote:

I have completed a LabVIEW project for the REV Robotics Color Sensor V2. It may need some adjustments to timing but it works pretty well.

Thought I would share it.


PeacefulPaul I sent this link to one of the teams I have  been helping who is also trying to get the color sensor to work.

 

Thanks for sharing

 

Mark

Champion CLA

Making senseless computers do
intelligent real world things
is NOT easy. SO MAKE IT FUN!
Message 7 of 10
(8,841 Views)

Thank you Mark. For whoever uses these VI's, they have to remember that most of the numbers used in addresses and data readouts are in hexadecimal (base 16). Numbers will include A, B, C, D, E, & F in addition to 0 thru 9. I am an old microprocessor programmer and I have found that using hex makes it easier to trouble-shoot. 

The readings on the front panel may be changed back to decimal simply by right clicking the indicator and selecting "display format", then selecting 'decimal'.

0 Kudos
Message 8 of 10
(8,834 Views)

@PeacefulPaul wrote:

I have completed a LabVIEW project for the REV Robotics Color Sensor V2. It may need some adjustments to timing but it works pretty well.

Thought I would share it.


Hi PeacefulPaul,

The team was able to get the color sensor working and is currently testing with it.

 

They brought up a question that I wasn't sure the answer. In the code below the register value is set at x92 we were expecting to send x12 which according to the datasheet is the Device ID data register. Breaking it down we concluded that the value was a x12 ored with a x80 (b0001010 | b10000000 = b10010010) =x92. 

 

Can you explain to us why you need to include the bit at the beginning to make the read work?

 

Thanks

register.png

Champion CLA

Making senseless computers do
intelligent real world things
is NOT easy. SO MAKE IT FUN!
0 Kudos
Message 9 of 10
(8,780 Views)

Can you explain to us why you need to include the bit at the beginning to make the read work?

Certainly. If you look in the programming section of the data sheet under 'Command Register' (page 17) you will see where it says for bit 7: "Select Command Register. Must write as 1 when addressing COMMAND register".  In the Register Description table on page 16 it describes the command register as a write only register with no address. This confused me until I realized that for an i2c address, bit 7 is 1 for write and 0 for read. when I tried it that worked.

Message 10 of 10
(8,770 Views)