1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

strange behavior of US sesnor in NXT-G

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.

Re: strange behavior of US sesnor in NXT-G

Postby afanofosc » 23 Sep 2012, 20:08

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/
User avatar
afanofosc
Site Admin
 
Posts: 1111
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN

Re: strange behavior of US sesnor in NXT-G

Postby doc-helmut » 23 Sep 2012, 20:25

so is USSensor() sending a i2c read cmd and reads a register?
Or is it reading buffers in the abyss of the firmware?
regards, HaWe aka Ford"A Kingdom of Heaven if NXC had recursions" Prefect
±≠≈αγδελπφωΔΦΣΩ∫√∈∉¬⊂⊄∩∪∅∞
NXC CHESS for NXT: url= http://www.mindstormsforum.de/viewtopic.php?f=70&t=6790

wishful for NXC: easy + trouble-free network & I/O remote control for rs485, Xbee, and BT !
User avatar
doc-helmut
 
Posts: 1988
Joined: 29 Sep 2010, 14:25

Re: strange behavior of US sesnor in NXT-G

Postby aswin0 » 23 Sep 2012, 22:15

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
User avatar
aswin0
 
Posts: 189
Joined: 29 Sep 2010, 06:58

Re: strange behavior of US sesnor in NXT-G

Postby doc-helmut » 24 Sep 2012, 16:24

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)^^
regards, HaWe aka Ford"A Kingdom of Heaven if NXC had recursions" Prefect
±≠≈αγδελπφωΔΦΣΩ∫√∈∉¬⊂⊄∩∪∅∞
NXC CHESS for NXT: url= http://www.mindstormsforum.de/viewtopic.php?f=70&t=6790

wishful for NXC: easy + trouble-free network & I/O remote control for rs485, Xbee, and BT !
User avatar
doc-helmut
 
Posts: 1988
Joined: 29 Sep 2010, 14:25

Previous

Return to Mindstorms Software

Who is online

Users browsing this forum: No registered users and 1 guest

cron