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
strange behavior of US sesnor in NXT-G
Re: strange behavior of US sesnor in NXT-G
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Re: strange behavior of US sesnor in NXT-G
so is USSensor() sending a i2c read cmd and reads a register?
Or is it reading buffers in the abyss of the firmware?
Or is it reading buffers in the abyss of the firmware?
Re: strange behavior of US sesnor in NXT-G
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.
My blog: nxttime.wordpress.com
Re: strange behavior of US sesnor in NXT-G
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)^^
@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)^^
Who is online
Users browsing this forum: Semrush [Bot] and 5 guests