Problem with lego color sensor 2.0
Posted: 28 Mar 2011, 12:06
Hello,
I'm currently trying to write a low level driver in Ada for the lego RGB color sensor 2.0. I saw the communication protocol in Lejos (and in the open source firmware) code and I wrote the corresponding code of the initialization sequence in Ada. As far as I understood the initialization procedure is :
- reset
- send sensor mode
- read calibration values
To reset you set and reset the clock every miliseconds twice, and you wait 100 ms.
To send sensor mode you send the corresponding byte (between 13 and 17) whith the least significant bit first.
To read calibration values you receive bytes containing calibration data from the sensor, you compute a CRC and you compare it with the received CRC.
My problem comes when I read those bytes : when I put my finger on the sensor I receive 0x00, when I remove it, I receive 0xff. It's troubling because it seems that the sensor already works and sends absurd values. When I force the data pin in analog mode I only read 0. The RGB led is always off (even if I send a mode such as COLOR_RED). When in the initialization is it supposed to be turned on ?
Lego color sensor doesn't seem to need 9V alimentation, so I left the default 5V alimentation.
Has anyone got the same problem ?
Thanks by advance
Xavier
I'm currently trying to write a low level driver in Ada for the lego RGB color sensor 2.0. I saw the communication protocol in Lejos (and in the open source firmware) code and I wrote the corresponding code of the initialization sequence in Ada. As far as I understood the initialization procedure is :
- reset
- send sensor mode
- read calibration values
To reset you set and reset the clock every miliseconds twice, and you wait 100 ms.
To send sensor mode you send the corresponding byte (between 13 and 17) whith the least significant bit first.
To read calibration values you receive bytes containing calibration data from the sensor, you compute a CRC and you compare it with the received CRC.
My problem comes when I read those bytes : when I put my finger on the sensor I receive 0x00, when I remove it, I receive 0xff. It's troubling because it seems that the sensor already works and sends absurd values. When I force the data pin in analog mode I only read 0. The RGB led is always off (even if I send a mode such as COLOR_RED). When in the initialization is it supposed to be turned on ?
Lego color sensor doesn't seem to need 9V alimentation, so I left the default 5V alimentation.
Has anyone got the same problem ?
Thanks by advance
Xavier