Page 3 of 3

Re: NXT Sensor Input Ports

Posted: 29 Jul 2011, 17:31
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

Re: NXT Sensor Input Ports

Posted: 29 Jul 2011, 17:38
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:

Re: NXT Sensor Input Ports

Posted: 29 Jul 2011, 18:05
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?

Re: NXT Sensor Input Ports

Posted: 29 Jul 2011, 19:31
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);
}

Re: NXT Sensor Input Ports

Posted: 30 Jul 2011, 12:27
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

Re: NXT Sensor Input Ports

Posted: 18 Aug 2011, 04:46
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).