View unanswered posts | View active topics It is currently Sun Oct 26, 2014 3:54 am






Reply to topic  [ 14 posts ] 
Avoid interference by other ultrasensor 
Author Message
Rookie

Joined: Fri Oct 28, 2011 11:50 am
Posts: 32
Post Avoid interference by other ultrasensor
I am building a sumo.

I heard that the NXT ultrasensor can get wrong reading due to interference of other nearby ultrasensor, which is a likely scenario.

How can I avoid this?

I also heard that a Guy Ziv has written some NXT-G blocks to avoid this issue (by using I2C read/write blocks to "ping" the US sensor, allowing it to be used in an on-demand fashion).

Does anyone has such ROBOTC equivalent functions?

Thanks.


Mon Nov 14, 2011 9:58 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Avoid interference by other ultrasensor
In my driver suite there's a LEGOUS-driver.h has a function for using the US sensor in single shot mode:
Code:
int USreadDist(tSensors link);
bool USreadDistances(tSensors link, tByteArray &distances);
bool USsetSingleMode(tSensors link);
bool USsetContinuousMode(tSensors link);
bool USsetOff(tSensors link);
bool USsetEventCapture(tSensors link);
bool USreset(tSensors link);

Go check out the driver, you can download it from the link in my signature :)

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Nov 14, 2011 11:14 am
Profile WWW
Rookie

Joined: Fri Oct 28, 2011 11:50 am
Posts: 32
Post Re: Avoid interference by other ultrasensor
Thanks alot.

However, I hit some error somehow when I tried to use your drivers. The NXT screen displayed something like "3rd party driver error. You have not set up the sensor port correctly. Please refer to one of the examples.". Pls help. Thanks.

The program is as follows:

----
#pragma config(Sensor, S2, frontSonarSensor, sensorSONAR)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "../rdpartyrobotcdr-v2.3/drivers/LEGOUS-driver.h"

// main program

task main()
{
// test
/*
if (!USsetSingleMode(frontSonarSensor))
{
writeDebugStreamLine("Error calling USsetSingleMode");
return;
}
*/
int d;

for(;;)
{
d = USreadDist(frontSonarSensor);
writeDebugStreamLine("Distance is %d", d);
nxtDisplayCenteredTextLine(2, "Distance is %d", d);
wait1Msec(100);
}
}


Mon Nov 14, 2011 11:55 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Avoid interference by other ultrasensor
Try this instead:
Code:
#pragma config(Sensor, S2,     frontSonarSensor,    sensorI2CCustom)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//


- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Nov 14, 2011 2:57 pm
Profile WWW
Rookie

Joined: Fri Oct 28, 2011 11:50 am
Posts: 32
Post Re: Avoid interference by other ultrasensor
No more error but the reading is always out of range.


Mon Nov 14, 2011 10:56 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Avoid interference by other ultrasensor
The likelihood of actually getting bad readings is not all that great when you run all of the US Sensors at once. You could use some kind of filter to make sure you get only good values. It will greatly simplify your program.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Nov 15, 2011 2:38 am
Profile WWW
Rookie

Joined: Fri Oct 28, 2011 11:50 am
Posts: 32
Post Re: Avoid interference by other ultrasensor
I will try again. Wish me luck.


Wed Nov 16, 2011 2:53 am
Profile
Rookie

Joined: Fri Oct 28, 2011 11:50 am
Posts: 32
Post Re: Avoid interference by other ultrasensor
Hi,

I still can't get the program working to read distance using your drivers.
- anything wrong with my program?
- do I need do use with a Sensor Multiplexer?

Thanks.

Regards.


Sun Nov 20, 2011 4:38 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Avoid interference by other ultrasensor
You could try it with the MUX but unfortunately at this moment I don't have time to debug the issue due to other more pressing (non-LEGO related) things. I would just use the normal built-in US driver for now and see if you really do get interference with multiple sensors.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Nov 20, 2011 3:56 pm
Profile WWW
Rookie

Joined: Fri Oct 28, 2011 11:50 am
Posts: 32
Post Re: Avoid interference by other ultrasensor
Hi,

I looked into LEGOUS-driver.h and suspected the following value is not correctly defined after googling.

#define LEGOUS_I2C_ADDR 0x10 /*!< Lego US I2C address */

So I changed it to

#define LEGOUS_I2C_ADDR 0x02 /*!< Lego US I2C address */

And somehow, the program managed to work.

Regards.


Sun Nov 20, 2011 10:12 pm
Profile
Expert

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Post Re: Avoid interference by other ultrasensor
Indeed the address of the Ultrasonic sensor is 0x02, as well as almost all HT sensors (and many other NXT 3rd party devices).

_________________
Matt


Sun Nov 20, 2011 10:57 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Avoid interference by other ultrasensor
That is a rather stupid bug on my part, my apologies. It will be fixed in the next release. I wrote the drivers but never tested it, they were made for someone else. I guess they never really used them either or they would've bumped into this. I will blame them for this.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Nov 21, 2011 2:26 am
Profile WWW
Rookie

Joined: Fri Oct 28, 2011 11:50 am
Posts: 32
Post Re: Avoid interference by other ultrasensor
I fully understand and appreciate your kind effort.

Just for sharing
- I tested using normal lego driver and tried to simulate interference by other ultra sensor. However, I couldn't replicate the interference.
- I tested using your 3rd party driver and tried to use the single shot mode. It worked almost perfectly. However, it always returns the last valid distance reading when it is supposed to return an out of range reading (nothing in front)

I do not have more time and capacity to test further so I chose to use the normal lego driver and pray hard there will not be any interference.

Thanks.


Mon Nov 21, 2011 6:11 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Avoid interference by other ultrasensor
I will take your feedback and improve the driver. I really appreciate the feedback, I wish more people would do that :)

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Nov 21, 2011 10:04 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 14 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.