Sonar Board Details



Sonar Multiplexing Module Documentation

0   General Overview
1   Components
2   Design Goals
3   Function Details
4   Comm Protocol
5   Conclusion

0. General Overview:

The sonar multiplexing module is, in the most general sense, a black box that allows a single 115200 baud serial connection from an external device to drive up to 32 polaroid 600 series electrostatic sonar transducers. The firing rate and order are dynamically configurable. At any given time, two sonars fire simultaneously. The device runs off of any DC source greater than 7v. Sonar transducers are connected via RCA jacks. Sonar data and control codes are sent in accordance with the com protocol detailed in the last section of this document.

1. Components:

The box is a standard radio-shack deluxe metal project box with holes drilled in the sides. In these holes, four octal rca jacks are mounted. Four standoffs are mounted in the bottom, and a ground wire is soldered into the shell. The points where the two halves of the box join have the enamel sanded off so that a good electrical contact is made when the box is screwed together. This is important for reasons of electrical shielding since some of the components in this system are very sensitive.

Two custom PCBs are mounted onto the standoffs in the box. Each PCB contains

 1	40 pin dip socket
17	16 pin dip sockets
 1	20 pin dip socket
 1	10 pin dual row header
19	 4 pin keyed headers
16	Coto 8001-05-001 reed relays
 1	Microchip Pic 16F877 MCU
 1	20MHz clock crystal
 2	330uF electrolytic capacitor
 1	  1uF electrolytic capacitor
 1	 .1uF ceramic capacitor
 1      7805 voltage regulator
 1	small heatsink for 7805
 1	power indicator LED
 1	1.0 Kohm resistor
 1      4.7 Kohm resistor
 1	Polaroid sonar ranging board with cable and plug
 5	mounting screws and nuts

In addition, 32 wires connected to keyed female connectors need to be soldered into the RCA jacks and a 4-wire connector needs to be run between the two boards. Also, the wires E1 and E2 on the polaroid ranging board need to be put into a keyed female connector so that they can connect into the PCB. One of the 330uF capacitors should be soldered onto the ranging board (bridging the wires W1 and W2) in order to prevent brownouts from current dips.

2. Design Goals:

Modularity, expandability, ruggedness, reliability, and economy were the major influences in the design process for the sonar module. For economy, the extremely cheap Pic microprocessor was chosen, and all parts used in the design were "off the shelf." For modularity, small keyed connectors and sockets were used wherever possible inside the box instead of direct solder connections. Further, RCA jacks were used on the outside of the box to make it easier to plug and unplug transducers. Expandability aspect of the design was mainly a factor in code design. Each pic uses the same code, and as many as 256 of the PCB's could be daisy chained together (allowing 256*16 sonars to be controlled through one serial connection). In order to accomplish this, each board has three serial connections. One connection may or may not be connected to the external controller. The other two are used to connect the boards in a ring configuration. One of these connections goes to the previous board in the ring and the other goes to the next board. The external controller is then plugged into any of the boards in the ring and controls the entire network of sonar boards via this connection. To make the design both rugged and reliable, shielded cable is used everywhere outside of the box so that no interference can affect the devices. The box is solid metal, and acts both as a faraday cage and as physical protection for the devices inside. The RCA connectors are strong, simple to solder, and form tight connections that won't loosen from vibrations in the robot.

3. Function Details:

Each board has three primary functions. These are initialization, data gathering, and data transmission. The initialization occurs on powerup. At this point, none of the boards knows whether it is connected directly to the external controller or not, nor how many other boards may be connected. So, all the boards wait for a message on either the serial line to the external controller or the line from the previous board. The message from the controller initializes the receiving board which then names itself number 0 and returns a confirmation message to the external controller. Board number 0 then tells the next board in the link its name. Each board names itself the number of the previous board plus one until board 0 gets the message. At this point, initialization is completed for every board except board 0. Board 0 then waits for the external controller to send it information about which sensors to fire at what speed and in what order.

Data gathering is a synchronized process where board 0 sends out the number of the sensor to fire and the delay to use before firing. Each board receives this data, then passes it on. Once the information has been passed, each board waits for the delay period and then fires the appropriate sensor. To fire a specific sensor, a sonar multiplexing board first switches a relay corresponding to the correct transducer, waits for the delay period to allow the relay to fully switch and allow any echos to die down, and then sets the fire pin on the polaroid ranging board high. Two timers are then started on the Pic. When the echo pin on the polaroid ranging board goes high, an interrupt occurs and the time elapsed on the first timer is recorded. This is the time of flight for the sonar pulse. If within a given period of time an echo does not occur, the second timer overflows, causing another interrupt. In this case, a flag is set. This will occur in two very different cases. The first occurs when there is an object so close to the transducer that the echo is ignored. The second occurs when the nearest object is so far away that no echo returns within the given time. During indoor testing, this second case has not occurred.

Once data has been gathered from a given sensor, each board (except board 1) waits to receive data from the previous board in the ring. Board 1 does not wait because it makes no sense for board 0 to pass its data around. Once data has been received from the other boards, the data gathered is added in and then passed along with everything else. When board 0 gets all the information, it converts the elapsed time in ticks into a distance in inches and then passes this information over to the external controller. Board 0 then tells all the other boards which sonar to fire next and new data is gathered. This loop continues until new configuration information is sent or until power is turned off.

4. Comm Protocol:

All messages transferred to and from the Sonar Multiplexing Module are 8 characters long. The first two characters identify the message type and origin. The next characters contain other information. The first message received by the module is called "ping" and consists of z, l, ^@, ^@, ^@, ^@, ^@, ^@.

	The reply is called "pong" and is p, m, ^@, ^@, ^@, ^@, ^@, ^@. 

	The configuration takes three messages. These take the form:
	33 37 delay_time # # # # #
	34 37 # # # # # #
	35 37 # # # # # 255

Each # is a sonar number between 0 and 15 or the number 255. The number 255 signals the board to go back to the first of the sonars selected. In this way less than 16 sonars per board can be fired.

	When data is returned, the format is:
	33 38 sonar_num offset # # # #

Each # is the distance in inches from the nearest object to the sonar on a given board. The offset is 1/4 the difference between the boardnum and the index. So, the message 33 37 5 2 21 29 0 17 would indicate that sonar 5 on board 8 detected something 21 inches away, sonar 5 on board 9 an object 29 inches away, etc. However, since two boards are more than enough for our current purposes, the offset will always be 0.

5. Conclusion:

At this point, enough masking and blackboxing has been done so that the actual hardware inside the box and the embedded programming to control the hardware can be more or less forgotten and focus shifted over to development of control software including algorithms for wall following and obstacle detection and avoidance. The system is unaffected by emf interference, has no electrical problems inside a metal shelled robot, and can sustain some level of impact. Questions and or comments may be referred to Sean Pieper (spieper@andrew.cmu.edu)