02-02-2019 01:33 PM
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?
Solved! Go to Solution.
02-03-2019 09:28 PM - edited 02-03-2019 09:36 PM
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,
02-05-2019 11:09 AM
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?
02-09-2019 07:41 PM
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.
02-09-2019 07:41 PM
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.
02-09-2019 08:08 PM
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.
02-09-2019 09:21 PM
@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
02-09-2019 09:49 PM
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'.
02-14-2019 05:28 PM
@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
02-14-2019 08:37 PM
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.