NXT Sensor Input Ports

Discussion specific to the intelligent brick, sensors, motors, and more.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXT Sensor Input Ports

Post by afanofosc »

If it doesn't work I would have to suspect the wiring rather than anything to do with the firmware code.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXT Sensor Input Ports

Post by HaWe »

I would have suspected the wiring of the port splitters, too,
if...
- I hadn't tested 3 different port splitters from 2 different builders, and if
- one of those builders hadn't been Xander himself :oops:
linusa
Posts: 228
Joined: 16 Oct 2010, 11:44
Location: Aachen, Germany
Contact:

Re: NXT Sensor Input Ports

Post by linusa »

In my experience, digital sensors tend to need some "boot-up-time" after setting the correct 9V lowspeed sensor mode. Order around 50ms 200ms, but YMMV of course. Maybe the 8ms wait is just too short?
RWTH - Mindstorms NXT Toolbox for MATLAB
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXT Sensor Input Ports

Post by HaWe »

also analog (light) needs much more time! I set both waits to 200 (if less even more faulty):
better!
with analog touch and US: ok!
touch ok: 1023...180, digital ok, too: 8...255 !

with analog light and US: faulty.
analog between 600..700, but digital (US) always 0.

Code: Select all


#define printf1( _x, _y, _format1, _value1) { \
  string sval1 = FormatNum(_format1, _value1); \
  TextOut(_x, _y, sval1); \
}



task DisplayValues() {
  int myvalue;
  while (1) {

    SetSensorLowspeed(S1);
    Wait(200);
    myvalue=SensorUS(S1);
    printf1(0,48, "Digital=%5d ", myvalue);
    
    SetSensorLight(S1);
    Wait(200);
    myvalue=SensorRaw(S1);
    printf1(0,40, "Analog =%5d ", myvalue);
  }
}


//********************************************************************

task main()
{

  start DisplayValues;
  while (1);
}
gloomyandy
Posts: 323
Joined: 29 Sep 2010, 05:03

Re: NXT Sensor Input Ports

Post by gloomyandy »

Doc,
The NXT Light sensor uses one of the digital I/O lines to turn the light on and off. The hardware attached to that line will almost certainly screw up any i2c traffic on the same port, so I don't think you can mix that sensor with i2c devices. Similarly the NXT sound sensor uses the digital lines to control the operating mode so I suspect it will also not work...

Andy
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXT Sensor Input Ports

Post by mattallen37 »

afanofosc wrote:...Today I added a couple of lines of code to the enhanced NBC/NXC firmware so that it does copy over the ADRaw value even when the sensor type is one of these three values.

John Hansen
Sweet! Thanks! That's something I've been wanting for almost a year ;)

I know the limitations of using pins 5 and 6 for analog sensors while also attempting to use I2C stuff. For what I did before (when switching between lowspeed and analog), I was just reading a POT on the analog line (didn't need pin 5 like the light sensor does).
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests