Multiple ultrasonic sensors

This is where you talk about the NXJ hardware related topics such as the brick, sensors, LEGO pieces, etc.

Moderators: roger, imaqine, 99jonathan

User avatar
Posts: 73
Joined: Tue Apr 24, 2007 12:24 pm

Multiple ultrasonic sensors

Postby CoBB » Fri May 16, 2008 1:23 pm

While working on a remote control framework the need for using more than one sonar at a time has come up. Is there anything else I can count on besides the 30-degree cone? I tried operating two sensors by alternating between them and using single shot mode for the active one while turning off the other (by sending {0x41, 0x00}), but it seems there are long-lasting echoes that cause a noticeable disturbance between them. I went as far as issuing pings as rarely as once every two seconds, but the results were practically identical to simply operating the two at the same time. But how can the single shot mode work so well for a lone sensor then? Shouldn’t a preceding impulse interfere with the current one?

Has anyone ever had success getting multiple sonars to cooperate?

Posts: 30
Joined: Tue Feb 26, 2008 5:20 pm

Postby enzomango » Wed Jul 30, 2008 1:14 am

If you don't mind a little soldering you can build an infrared rangefinder that won't interfere with the ultrasonic. If you're interested check out the "Extreme NXT - Extending the LEGO MINDSTORMS NXT to the Next Level" book at your nearest book store.

User avatar
leJOS Team Member
Posts: 4935
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby gloomyandy » Wed Jul 30, 2008 8:50 am

I'm surprised that you are getting interference between the two sensors in this way. Have you tried sampling each sensor twice and discarding the first set of results. It may be that you are seeing an "old" set of results? So set both sensors into single shot mode, ping sensor1 <delay> ping sensor1 and use results <delay2> ping sensor2 <delay>ping sensor2 and use results <delay2>, repeat!

Would be interested to see what sort of results you get.

One thing I've noticed (and I think roger has seen the same), is that when running at high power you get a sort of geometric effect in the results. So if you get a reading at say 32cm you will also get a series of false results at some sort of multiple interval after that.

Finally you can also operate the sensor at 5V rather than 9V (versions of leJOS < 0.5 did this by mistake!). Doing this shortens the range, but also reduces the number of false echos you get. You can switch between 5V and 9V by using setType method on the sensor port TYPE_LOWSPEED is 5V TYPE_LOWSPEED_9V is 9V...

Have fun...


Return to “NXJ Hardware”

Who is online

Users browsing this forum: No registered users and 2 guests