Page 1 of 1

Lego color sensor api for osek? Any datasheet available?

Posted: 12 Nov 2010, 19:56
by noeyewar
Hi
one of the other students would like to use the lego color sensor for a nxt-osek project. However a api does not seam to be available. Anyone knowing of a third-part api for this sensor?

My first thought was, what the heck. I will make it myself! (has never tried that before), but after been through both google and lego's website i cannot find a datasheet for this sensor. Is there anyone who can provide me with a link? (i guess i need information regarding i2c)

Thanks in advance

Re: Lego color sensor api for osek? Any datasheet available?

Posted: 12 Nov 2010, 20:14
by gloomyandy
Hi,
The Lego color sensor does not use i2c, nor as far as I know is there any data sheet available. It is a rather odd sensor using a combination of a bit banged serial protocol on the digital I/O lines and being the only sensor I know of that uses the AT91 A/D input to allow high speed reading of the analogue input... I implemented the leJOS support based on the code in the Lego firmware, so you could always take a look at that. The source for the leJOS code is here (sorry it is a little complex due to the way we had to bury it as part of a the sensor port class to allow remote access, via LCP to it)....
http://lejos.svn.sourceforge.net/viewvc ... iew=markup
The code you are interested in starts around line 200 and is the ColorSensorClass...

Good luck!

Andy

Re: Lego color sensor api for osek? Any datasheet available?

Posted: 12 Nov 2010, 20:15
by mattallen37
The lego color sensor is not I2C, but rather it uses a protocol that lego designed specifically for it. I have no info on it, but I just know that it isn't I2C. If it was, then the registers would likely be very easy to figure out how to use. If you misspoke, and you are talking about one of the HiTechnic color sensors, then those ARE I2C, and you can find all the I2C info on the HT website.

Edit: sorry for some repeat information, it looks like Andy beat me by a minute.

Re: Lego color sensor api for osek? Any datasheet available?

Posted: 14 Nov 2010, 21:02
by noeyewar
Thank you very much for the great replies.
gloomyandy wrote:Hi,
The Lego color sensor does not use i2c, nor as far as I know is there any data sheet available. It is a rather odd sensor using a combination of a bit banged serial protocol on the digital I/O lines and being the only sensor I know of that uses the AT91 A/D input to allow high speed reading of the analogue input... I implemented the leJOS support based on the code in the Lego firmware, so you could always take a look at that. The source for the leJOS code is here (sorry it is a little complex due to the way we had to bury it as part of a the sensor port class to allow remote access, via LCP to it)....
http://lejos.svn.sourceforge.net/viewvc ... iew=markup
The code you are interested in starts around line 200 and is the ColorSensorClass...

Good luck!

Andy
I took a look at the code and must admit that I will be needing way more than just luck to get anything to work :shock: I assumed it was based on I2C and it seamed quite achievable to work with. I leave him to find a solution on his own.
But thanks for the replies anyway.