Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   FIRST Tech Challenge (http://www.chiefdelphi.com/forums/forumdisplay.php?f=146)
-   -   [FTC]: Using multiple sensors of same type (http://www.chiefdelphi.com/forums/showthread.php?t=152357)

godkane 20-11-2016 20:06

[FTC]: Using multiple sensors of same type
 
3 Attachment(s)
I got tired of not being able to read two color sensors or two sonic sensors, so I re-wrote the code to get them to work as expected.

In configuration, make sensor "I2C Device".

Initialization is hardware map, device name, and configured address.
color = new RedStormColorSensor(hwMap, "cb", 0x40);
range = new RedStormRangeSensor(hwMap, "rf", 0x2a);

ArtemusMaximus 21-11-2016 08:28

Re: [FTC]: Using multiple sensors of same type
 
Quote:

Originally Posted by godkane (Post 1617003)
I got tired of not being able to read two color sensors or two sonic sensors, so I re-wrote the code to get them to work as expected.

In configuration, make sensor "I2C Device".

Initialization is hardware map, device name, and configured address.
color = new RedStormColorSensor(hwMap, "cb", 0x40);
range = new RedStormRangeSensor(hwMap, "rf", 0x2a);

Can this be used for Adafruit Color sensor?

godkane 21-11-2016 08:56

Re: [FTC]: Using multiple sensors of same type
 
Here is the device I think you are talking about: https://cdn-shop.adafruit.com/datasheets/TCS34725.pdf

I have seen other libraries support it, so I would guess it could.

You would have to change RedStormColorSensor.java to match the registers in the datasheet on page 13. Let me know if you have any issues with what the code is doing.

Christopher149 21-11-2016 12:02

Re: [FTC]: Using multiple sensors of same type
 
Quote:

Originally Posted by ArtemusMaximus (Post 1617038)
Can this be used for Adafruit Color sensor?

Because the Adafruit color sensors have a fixed, non-changeable I2C address, you need to use an I2C multiplexer. This code I wrote lets you use Adafruit color sensors over a multiplexer.

ArtemusMaximus 21-11-2016 16:19

Re: [FTC]: Using multiple sensors of same type
 
Quote:

Originally Posted by godkane (Post 1617045)
Here is the device I think you are talking about: https://cdn-shop.adafruit.com/datasheets/TCS34725.pdf

I have seen other libraries support it, so I would guess it could.

You would have to change RedStormColorSensor.java to match the registers in the datasheet on page 13. Let me know if you have any issues with what the code is doing.


Thank you . I already have multiplexer and test code (not mine) that worked. I was just asking because original post didn't specify which sensors affected and it would be cool if Adafruit Sensors with fixed I2C address can be used with just code without needing extra hardware


All times are GMT -5. The time now is 17:02.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi