~spillerrec I don't know what the response time of the photo-transistor is, but I assume Lego used some pretty quick switching of the colors. As long as the photo-transistor output circuit has time to stabilize with the new color, I'm sure it isn't waiting for much extra time. I would guess the on time for each color is between 5 and 250 uS, but that's totally a guess.
~shaoxiaojun, FYI, the Lego light sensor uses a red LED, not white.
how to use light sensor in NXC
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: how to use light sensor in NXC
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
-
- Posts: 358
- Joined: 01 Oct 2010, 06:37
- Location: Denmark
- Contact:
Re: how to use light sensor in NXC
I get the expected results from SetSensorColorNone(). Try take a reading when you cover the sensor (blocks it for any light) and when you direct something like a flashlight into it. (Also notice that the human eye is very good at adjusting the perceived light level, so what you see is normally quite different from what the sensor sees.)
About my test:
The shutter speed controls how long the image sensor (or film) are exposed to the scene. If the scene is changing while the sensor is exposed, the image will appear blurry:
(image by Gregory F. Maxwell)
When a lamp switches on and off fast enough, you wouldn't be able to notice it because the on state blends/blurs into the off state, looking like it is consistent. So I tried finding the time frame where it would stop being blurry and hopefully show each color lit up separately.
@matt,
Wow, I didn't even consider that it would switch that fast! I tried with the fastest shutter speed I have on this camera (1/4000, 250 µs) and I managed to get shots where only one color was lit. Only for the green and blue though, it still appears like it completes a circle in 250 µs so I guess red is the second color read. Not sure though...
It is interesting that the off state is much longer, as apparent from my earlier results it must be over 1000 µs.
Anyway, some pictures at 1/4000:
About my test:
The shutter speed controls how long the image sensor (or film) are exposed to the scene. If the scene is changing while the sensor is exposed, the image will appear blurry:
(image by Gregory F. Maxwell)
When a lamp switches on and off fast enough, you wouldn't be able to notice it because the on state blends/blurs into the off state, looking like it is consistent. So I tried finding the time frame where it would stop being blurry and hopefully show each color lit up separately.
@matt,
Wow, I didn't even consider that it would switch that fast! I tried with the fastest shutter speed I have on this camera (1/4000, 250 µs) and I managed to get shots where only one color was lit. Only for the green and blue though, it still appears like it completes a circle in 250 µs so I guess red is the second color read. Not sure though...
It is interesting that the off state is much longer, as apparent from my earlier results it must be over 1000 µs.
Anyway, some pictures at 1/4000:
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
-
- Posts: 220
- Joined: 23 Jan 2012, 17:07
- Location: Round Rock, TX
Re: how to use light sensor in NXC
Philippe E. Hurbain ("philo") has done some analysis of the color sensor at http://www.philohome.com/colcomp/cc.htm. One of his tests shows that the Lego sensor can register the color in 2.5 ms.
McSummation aka James
http://www.mcsummation.com/Mindstorms/
http://www.mcsummation.com/Mindstorms/
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: how to use light sensor in NXC
One good reason for the off state to be so long, is that it isn't consuming as much power overall. The "off" time will only effect the overall update rate. If the off time is 1250 us, and the complete on time cycle takes 250 us, then an entire update would take 1500 us (or 1.5ms). That would be more than 2 updates for every 1 analog sensor update (which is every 3.333 ms). That is incredibly fast for a cheap system.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Who is online
Users browsing this forum: No registered users and 1 guest