| Author |
Message |
|
ahbao
Rookie
Joined: Fri Oct 28, 2011 11:50 am Posts: 32
|
 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 |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
 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: Go check out the driver, you can download it from the link in my signature  - Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Mon Nov 14, 2011 11:14 am |
|
 |
|
ahbao
Rookie
Joined: Fri Oct 28, 2011 11:50 am Posts: 32
|
 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 |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
 Re: Avoid interference by other ultrasensor
Try this instead: - Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Mon Nov 14, 2011 2:57 pm |
|
 |
|
ahbao
Rookie
Joined: Fri Oct 28, 2011 11:50 am Posts: 32
|
 Re: Avoid interference by other ultrasensor
No more error but the reading is always out of range.
|
| Mon Nov 14, 2011 10:56 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
 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
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Tue Nov 15, 2011 2:38 am |
|
 |
|
ahbao
Rookie
Joined: Fri Oct 28, 2011 11:50 am Posts: 32
|
 Re: Avoid interference by other ultrasensor
I will try again. Wish me luck.
|
| Wed Nov 16, 2011 2:53 am |
|
 |
|
ahbao
Rookie
Joined: Fri Oct 28, 2011 11:50 am Posts: 32
|
 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 |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
 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
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sun Nov 20, 2011 3:56 pm |
|
 |
|
ahbao
Rookie
Joined: Fri Oct 28, 2011 11:50 am Posts: 32
|
 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 |
|
 |
|
mattallen37
Expert
Joined: Thu Sep 29, 2011 11:09 pm Posts: 146 Location: Michigan USA
|
 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 |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
 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
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Mon Nov 21, 2011 2:26 am |
|
 |
|
ahbao
Rookie
Joined: Fri Oct 28, 2011 11:50 am Posts: 32
|
 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 |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
 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
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Mon Nov 21, 2011 10:04 am |
|
|