Go to Post It's possible to do nearly anything with enough resources and ingenuity. - Madison [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 20-11-2016, 20:06
godkane godkane is offline
Registered User
FRC #3875
 
Join Date: Jan 2014
Location: Grand Rapids, MI
Posts: 11
godkane is an unknown quantity at this point
[FTC]: Using multiple sensors of same type

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);
Attached Files
File Type: java RedStormColorSensor.java (8.5 KB, 12 views)
File Type: java RedStormI2CDevice.java (9.0 KB, 11 views)
File Type: java RedStormRangeSensor.java (2.8 KB, 8 views)
Reply With Quote
  #2   Spotlight this post!  
Unread 21-11-2016, 08:28
ArtemusMaximus's Avatar
ArtemusMaximus ArtemusMaximus is offline
Enginerd
FTC #11722
Team Role: Coach
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Canada
Posts: 248
ArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to all
Re: [FTC]: Using multiple sensors of same type

Quote:
Originally Posted by godkane View Post
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?
__________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
2017 FTC 11722 (Coach)
2016 FTC 10544 (Coach) Canadian Championship Finalist, Rockwell Collins Innovate Award.
2014 FRC 5064 (Mentor)
Reply With Quote
  #3   Spotlight this post!  
Unread 21-11-2016, 08:56
godkane godkane is offline
Registered User
FRC #3875
 
Join Date: Jan 2014
Location: Grand Rapids, MI
Posts: 11
godkane is an unknown quantity at this point
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.
Reply With Quote
  #4   Spotlight this post!  
Unread 21-11-2016, 12:02
Christopher149 Christopher149 is offline
Registered User
FRC #0857 (Superior Roboworks) FTC 10723 (SnowBots)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2007
Location: Houghton, MI
Posts: 1,094
Christopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond repute
Re: [FTC]: Using multiple sensors of same type

Quote:
Originally Posted by ArtemusMaximus View Post
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.
__________________
2015-present: FTC 10723 mentor
2012-present: 857 mentor
2008-2011: 857 student

2015: Industrial Design, Excellence in Engineering, District Finalist, Archimedes Division (#6 alliance captain)
2014: Judges Award, District Engineering Inspiration, District Finalist, Galileo Division

Reply With Quote
  #5   Spotlight this post!  
Unread 21-11-2016, 16:19
ArtemusMaximus's Avatar
ArtemusMaximus ArtemusMaximus is offline
Enginerd
FTC #11722
Team Role: Coach
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Canada
Posts: 248
ArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to all
Re: [FTC]: Using multiple sensors of same type

Quote:
Originally Posted by godkane View Post
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
__________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
2017 FTC 11722 (Coach)
2016 FTC 10544 (Coach) Canadian Championship Finalist, Rockwell Collins Innovate Award.
2014 FRC 5064 (Mentor)
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 14:11.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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