Page 2 of 2

Re: strange behavior of US sesnor in NXT-G

Posted: 23 Sep 2012, 20:08
by afanofosc
In NXC I purposely add a wait when reading the Ultrasonic sensor so that it is not queried for a value more frequently than once every 15 milliseconds since if you send it i2c commands more frequently than that it quits returning real data and just returns invalid measurements. The NXT-G block does not protect you from shooting yourself in the foot with the Ultrasonic sensor.

John Hansen

Re: strange behavior of US sesnor in NXT-G

Posted: 23 Sep 2012, 20:25
by HaWe
so is USSensor() sending a i2c read cmd and reads a register?
Or is it reading buffers in the abyss of the firmware?

Re: strange behavior of US sesnor in NXT-G

Posted: 23 Sep 2012, 22:15
by aswin0
It is sending commands that are interpreted by the sensor, not reading registers. I came to this conclusion because you cannot read just the second byte from a multibyte register, you must always read the total buffer starting at address. If it were registers you could read any.

Re: strange behavior of US sesnor in NXT-G

Posted: 24 Sep 2012, 16:24
by HaWe
for NXC,
@John:
Anyway, IMO it's not good that one always has to wait for each USS call, because if one wants to poll many sensors in 1 polling loop a forced wait(15) for each USS reduces needlessly the polling frequence of all other sensors, i.g. touch or light in the same loop.

It must be able to switch off this built-in wait(15) if one wants.

(In C the programmer is responsible for everything what he's doing...even if he wants to shoot into his own foot or knee)^^