Encoder Front Page
SRS Home | Front Page | Monthly Issue | Index
Search WWW Search seattlerobotics.org

First Steps: Multiplexing Five Sonar Modules

Doug Leppard (DLeppard@CCCI.Org )
Benjamin Leppard (Benjamin@Leppard.Com)

Author’s note:

This is the fifth  in a series of articles outlining the steps we have taken to build our robot. Both Benjamin and I are newbies (but becoming more expert) at this and thus this article will be written for newbies. These articles are focused on a robot that will compete in the Fire Fighting contest, be able to roam around the house and will be a fun learning tool. The 68HC912B32 is our processor, so articles will be on interfacing to the B32 to various mechanical devices and sensors using SBasic as our programming language.

Previous articles:

"Setting the Stage for Building a Robot," we set goals for the robot and did research. From the goals and research we will make fundamental decisions on what our robot will be like.

"Choosing the CPU, Language and Basic Shape," using our goals we choose what microprocessor, language and what the fundamental shape of the robot.

"Motorola’s S-Record" looking at the S-Record format the Motorola uses to load data and programs.

"Booting up the 68HC912B32 for the first time" goes into detail how to boot the B32 up and run a program.

"State of the Union" gives an overview of what state the robot was in August 1999.

Multiplexing Sonar

I decided early on that the Polaroid sonar would be my main sensor for looking around. I think this goes back to the 80s in Popular Electronics magazine seeing articles on this sonar. When I decided to build a robot again I could not believe how cheap they were now.

Looking into other robots both hobby and professional, the Polaroid sonar was a consistent factor in what sensor a robot would use. It seemed to be a very dependable and accurate range device. See following article on how the devices work:

"Polaroid Sonar Ranging Primer" Excellent overview of the Polaroid sonar from Acroname.   Read this before my own article.

"Ultrasonics and Robotics"   Very helpful Encoder article.  Gives various insights into the Polaroid sonar use.

"Wirz FAQ on sonars" This has some very helpful and practical hints.

Or do a search on the web for Polaroid sonar and yo will get lots of hits but few if any on multiplexing them together.

I will not go into how the sonar works here. There are plenty of articles on the web that go into great detail. I would suggest reading these to understand the workings of these devices even before readint htis article.

Looking and studying other robots, there were robots that had one sonar and others that had dozens. Most were on a fixed platform and others on a movable platform to look at various angles.

robotfront.jpg (48013 bytes)  

The picture left is the front of my robot Onesimus.   The top black box is the robots sensor pod with five sonar units and heat sensor.  The front two transducers are mounted to look like eyes and the heat sensor look like a nose.   No mouth at this point.

The sensor pod is opened from the back.   You can see the back of two of transducers (eyes) and on the right of the picture is the right transducer.  Lower right are three of the relays mounted upside down.   It is crowded and messy inside but looks fine outside. robot_pod_inside.jpg (47225 bytes)

Decision factors and the why of the sensor pod

The following is the decision factors and the why I decided to do the configuration above. I am not sure if there are any other sonar configurations out there just like the one I made. I went with a five-sonar pod that had 180 degrees movement horizontal and vertical. The decision factors for this configuration is:


The sensor pod box is a cheap Radio Shack plastic box used for construction. It turned out to be the perfect size and shape. I wanted it to be as small as possible to have the sonar in the center of the robot, but big enough to house five sonar and heat sensor. Everything just barely fits in this box. It is mounted on a dual servo setup which allows the pod to be moved 180 degrees horizontally and almost 180 vertically. I wanted it to be able to look up and down to allow it to scan an object for heat signature. I felt this would give it more versatility.

For the sonar holes in the box, I used a 1- inch wood drill bit. This turned out to be exactly what I needed. The sonar fit snuggly in the holes without needing to be glued in. This allowed me to adjust the angle the sonar was pointing in the box. The front two sonar were angled out at about 5 degrees away from each other to give more stereo effect. See "Ultrasonics and Robotics" and  "SR04 Mobile Robot" for the why of this.

Connecting to the B32

Next question was how to get the five sonar signals to the CPU. I figured that there were three basic ways to do this. As it turns out I tried all three and only the third one worked. The three ways I tried were:

  1. Have five sonar transducers and five sonar electronics and each of these tied into the CPU. Down side of this was it took a lot of I/O ports and a lot of wiring. This would work but decided I didn’t want to go this route. This wasn’t really practical for I didn’t have enough I/O.
  2. Similar, five sonar transducers and five sonar electronics with the electronics multiplexed together. This is the direction I decided to go, but failed at. The Polaroid electronics have open collector outputs and I thought you could tie them together. But as it turns out that even if they have open collector outputs, somehow when they are tied together they interact with each other it causes results that are unpredictable and useless. I had built the entire setup, mounted it on the robot only to find out it did not work. Lots of wasted hours and money. Two additional problems this approach caused was all the wiring I had to do became unreliable and the fact I had five sets of the sonar wires going into the pod. These wires are thick and not very flexible and with five sets the pod had difficulty moving. Thus this approach was tossed out. Plus five modules eat up more power.
  3. The approach I used was one electronic module with the five-sonar transducers multiplex together to the module. The problem with this approach is that the transducers have a very short 400V pulse put across it and they are high impedance thus sensitive to how they are wired. When I first got a sonar, I wired it up and hooked it to my robots CPU. Holding it up with my hand, I pointed it around to see how it worked and it didn’t. I later discovered that when I was touching the sonar transducer with my hand, it would not work correctly.

Multiplexing the five sonar to the electronics module

So deciding to multiplex the transducers to the electronics I had to discover the best way to do that. There seemed to be two choices, solid state relay or reed switches. I felt the solid state relays had to be the choice. After all the solid state relays had to be faster and the idea of mechanical devices clicking together in the robot several times a second did not excite me.

I tried to get several solid state relays to work. One problem is that they must be rated to 400V. But when I tried this setup it just wouldn’t work. I am not sure why, but I suspected it was something to do with the high impedance of the transducers and the fact they had such a low current flow back to the electronics when the signal came back. So now I was forced to look at reed switches.

What I feared was the reed switches would be slow and noisy which to my surprise they were neither. I was concerned that I would have to wait for the reed switch to quit bouncing until I could use it. After searching the web I decided on the Hamlin HE721A05120 reed switch.

According to the specifications they have a one millisecond close time and a .5 millisecond open time. It just blew my mind that a mechanical device could close so quickly. I ran tests on the devices how fast they really closed and they closed much below the sub-mili second time with no bouncing that I could tell. Certainly fast enough for what I wanted to do. Plus you could barely hear them close and the click from the transducer sending its sonar signal out was a lot noisier and drowned out any noise the reed switch made.

The Hamlin HE721A0512 works at 5V with low current drain. The only concern was it carrying the 400V pulse. It had a switching voltage of 200V and can carry 1.2 amps. The 400V pulse would not be on when it switched so that would not be a factor. So only if the 400V pulse surpassed its ability to isolate it’s various inputs from this 400V. I had no specs on this, but I didn’t think it would be a factor.

Another good thing about these reed switches is that it had a clamping diode built in, which saved on construction. Any mechanical switch when it is turned off will produce its own voltage as the field of the windings collapses. This can cause spikes in you system and cause problems. A clamping diode shorts out this spike and protects your system.

Ordering the switches from Digi-Key ($2.70 part number HE101-ND1), they came quickly. Once hooked up they worked great. They were small enough that I mounted them inside the pod box and thus it solved my too many wires going to the box problem.

Wiring the transducers, reed switches and electronic module

The following connections are used for the sonar:

BINH - Blank inhibiting. The input echo is inhibited for 2.38 milliseconds so that the ringing of the transducer will not give false reading. This is equivalent of an object being 1.33 ft away. To get an object as closer this line is taken high to inhibit blanking.

ECHO - When the return signal of the sound is received the ECHO goes high.

INIT - When the INIT is taken high the sound is sent by the sonar and timing starts, initiating the process.

BLNK - Setting this high after ECHO has gone high will reset ECHO allowing you to receive another signal that is more distant. I have not worked with this.

V+ - 5V that must be able to handle 2 amp for a very short period of time. I put the sonar of the same power supply as the motor and isolated it from the microprocessor supply. I also put a 2200 microfarad capacitor at the 5V to help in the power surge.

Diagram of Circuit

reedswi2.jpg (20966 bytes)

The diagram aboveshows how it is wired. Each transducer ground is wired together to the module ground. The module ground is one of the two black wires, use your ohm meter to determine which one is ground. Then the other wire XDCR goes to one side of each of the reed switches. The other side of each of the reed switches go to the other connection of the transducer.

To drive the reed switch I used a 3904 transistor and 1k resistor going into the base of the transistor. The emitter goes to ground and the collector to the reed switch. You probably could have driven the reed switch directly with the microprocessor. The 74HC573 is not necessary for this circuit. It is used to allow the port to be used for other things. It is an eight bit latch to hold the data while the port is being used for another process.

When the reed switch is turned on it makes a very small click, which is useful to know it is working, but you can not hear it unless you are up close to it.

Next Article

Next time I will write on the software behind driving five sonar. I also wrote a program where the robot sends to my PC what sonar distance is received and what angle it was at. Then the PC draws a map from the data. It was really cool the first time I saw this map. You really could see the basic shape of the room. But that is for next time.