strange behavior of US sesnor in NXT-G

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: strange behavior of US sesnor in NXT-G

Post 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
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: strange behavior of US sesnor in NXT-G

Post 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?
aswin0
Posts: 201
Joined: 29 Sep 2010, 06:58

Re: strange behavior of US sesnor in NXT-G

Post 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.
My blog: nxttime.wordpress.com
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: strange behavior of US sesnor in NXT-G

Post 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)^^
Post Reply

Who is online

Users browsing this forum: No registered users and 41 guests