NXC: NXT 2.0 color sensor in lamp mode

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
timpattinson
Posts: 224
Joined: 30 Oct 2010, 04:10
Location: 127.0.0.1
Contact:

NXC: NXT 2.0 color sensor in lamp mode

Post by timpattinson »

Hi.
I'm wondering if anyone knows how to turn on the light on the nxt 2.0 color sensor (not the HT sensor) in NXC?
Tim
Commit to Lego Mindstorms StackExchange Q&A http://area51.stackexchange.com/proposals/4105
Minboards IRC Channel #mindboards on Freenode
My blog: http://timpattinson.wordpress.com/
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC: NXT 2.0 color sensor in lamp mode

Post by mattallen37 »

I use the following to select mode, and therefore setting the LED control.

Code: Select all

SetSensorColorRed(S1);  //Turn on Red
SetSensorColorGreen(S1);//Turn on Green
SetSensorColorBlue(S1); //Turn on Blue
SetSensorColorFull(S1); //Turn on all (multiplexed, so not at the same time, thus reducing brightness)
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
timpattinson
Posts: 224
Joined: 30 Oct 2010, 04:10
Location: 127.0.0.1
Contact:

Re: NXC: NXT 2.0 color sensor in lamp mode

Post by timpattinson »

Thanks. I just didn't know that that did it
Thanks again
Tim.
Commit to Lego Mindstorms StackExchange Q&A http://area51.stackexchange.com/proposals/4105
Minboards IRC Channel #mindboards on Freenode
My blog: http://timpattinson.wordpress.com/
timpattinson
Posts: 224
Joined: 30 Oct 2010, 04:10
Location: 127.0.0.1
Contact:

Re: NXC: NXT 2.0 color sensor in lamp mode

Post by timpattinson »

How do you turn them off?
Thanks
Tim
Commit to Lego Mindstorms StackExchange Q&A http://area51.stackexchange.com/proposals/4105
Minboards IRC Channel #mindboards on Freenode
My blog: http://timpattinson.wordpress.com/
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC: NXT 2.0 color sensor in lamp mode

Post by mattallen37 »

NP. I can only assume, but try using the following to turn it off.

Code: Select all

SetSensorColorNone(S1);
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
timpattinson
Posts: 224
Joined: 30 Oct 2010, 04:10
Location: 127.0.0.1
Contact:

Re: NXC: NXT 2.0 color sensor in lamp mode

Post by timpattinson »

Thanks. ;)
-Tim
Commit to Lego Mindstorms StackExchange Q&A http://area51.stackexchange.com/proposals/4105
Minboards IRC Channel #mindboards on Freenode
My blog: http://timpattinson.wordpress.com/
rghansen
Posts: 67
Joined: 12 Oct 2010, 17:44

Re: NXC: NXT 2.0 color sensor in lamp mode

Post by rghansen »

Does anyone know why the calls SetSensorColorFull( colorSensorPort ) and SetSensorColorNone( colorSensorPort ) each take about 170 milliseconds? It seems like a lot of time just to turn a light on and off. I didn't find any waits in the generated code so I assume that this happens in the firmware.
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXC: NXT 2.0 color sensor in lamp mode

Post by mightor »

This is a firmware/hardware thing and a known issue with this sensor.

- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC: NXT 2.0 color sensor in lamp mode

Post by mattallen37 »

mightor wrote:This is a firmware/hardware thing and a known issue with this sensor.

- Xander
You call it an "issue", is it messed up (not how it should be)? what is responsible for the delay? Is it the NXT firmware? the sensor? both? I don't like the delay, but if it is an NXT problem, could it be used that much faster with a u-processor as an NXT co-processor (Arduino, or PICAXE)?
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXC: NXT 2.0 color sensor in lamp mode

Post by mightor »

I have no idea tbh. One way you could find out is to compare the time it takes with various firmwares :) Use an NXT 1.0 light sensor to measure, it's got a 3ms update time.

- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest