home  >  BARG index

Previous BARG Newsletter Issue 3/4, Spring/Summer 1985 p11 - 13 -- The Aargh Interface Mark II
Next BARG Newsletter Issue 3/4, Spring/Summer 1985 p21 - 28 -- Zero 2 review, Letters, Index

BARG Newsletter #3/4 pages 14 - 20 -- Polaroid Ultrasonic Ranging System - Richard Moyle
Polaroid Ultrasonic Ranging System - Richard Moyle
The Polaroid sound ranging system was described in Issue 1 of the Newsletter, when some of the theory was discussed. This article is intended to give some practical suggestions for building a suitable circuit and connecting it to a computer.

The technical notes supplied with the equipment are not entirely clear, as they refer to four different versions of the ranging circuit board, as well as a separate designers' kit. The naming of various logic signals in different parts of the circuit is ambiguous, with signals of opposite polarity having the same name. In this article, the main references to the technical notes will follow their conventions with minor changes to avoid ambiguity. This applies also to those diagrams based on the technical notes, and which are included with acknowledgement to Polaroid.

The Polaroid part numbers are as follotws:

Instrument Grade Electrostatic Transducer   Part No 604142

Unmodified 4-frequency Ranging Board        Part No 606191
Unmodified Single-frequency Ranging Board   Part No 606192
Modified 4-frequency Ranging Board          Part No 606745
Modified Single-frequency Ranging Board	    Part No 607089
Cable assembly                              Part No 604789

There is also a commercial grade transducer available but it is not suitable for this purpose. Normally only modified boards are supplied, unless otherwise requested. The modifications involve the addition of two transistors, and connecting a 6-way ribbon cable to locations on the back of the board. The 4-frequency board has three i/cs, whereas the single-frequency board has 2. Use and Interfacing is otherwise identical.

Figure 1 is a block diagram of the circuit, and shows the control signals. VSW supplies upwards of 100 mA of current and is used to trigger the transmission of a pulse VSW should be kept high for at least 100 mS, then taken low for at least 40 mS. /XLDG follows about 5 mS after the application of VSW and consists of about 50 pulses at 49.1kHz (the 4-frequency board uses a combination of frequencies). The leading edge of this signal is used for all timing. /MFLDG is generated on receipt of the first echo, or after 65 mS, but not during the first 1.6 mS after /XLDG. Figure 2 illustrates the timing relationship. /XLDG and /MFLDG are not suitable for connection direct to the computer, and need to be buffered, as described later. These signals are also referred to in the technical notes as XLG and FLG, though these terms should really refer to the inverted signals foIlowing the buffers. There are other points on the board where signals can be tapped, for example to detect echoes other than the first.


              BUT PAINFUL.
Barg Newsletter lssue 3/4 - Page 14

So, the ranging board requires an input signal at VSW, and provides two outputs at /XLDG and /MFLDG. These signals are not at TTL or CMOS levels and will need additional circuitry before they can be handled by a computer. A suitable circuit is shown in Figure 3. The PNP transistor must switch up to 150 mA, but otherwise the transistors are small signal switches. The 1 uf capacitor shown between VSW and GND should already exist on the ranging board, and if so can be omitted from the buffer circuit. As shown, MDL should not be taken high less than about 100 mS after going low, so that the capacitor can discharge. If required, the additional components shown in the inset can be included reducing the 100 mS to a minimum of 40 mS. As this is only an increase from 5 to 7 readings a second, it is not much of an improvement.

Barg Newsletter Issue 3/4 - Page 15

Barg Newsletter Issue 3/4 - Page 16

The ribbon cable fitted to the board is used to connect the buffer circuit, and the transducer is connected using cable assembly 604789. This is a short length of screened cable with two small lucar-style terminals at one end that fit over the lugs on the transducer. It is recommended that this type of connection is used, as soldering to the lugs is very unrewarding and damaging to your wallet. So is applying power to the board without the transducer connected, so don't. The buffered signals can be connected to an I/O port on a computer, or interfaced to other logic, according to requirements. One enhancement would be to fit the flip-flop of Figure 5 to the output of XLG to ensure that only the first edge of the burst of pulses is used for timing.

Operation then becomes a straightforward sequence:

     First, apply Vcc with MDL low
     Then, for each reading;
          Take MDL high
          Wait for XLG (or XLGQ) to go high
          Count until FLG goes high
          Take MDL low
          Wait for 100 mS
The count will be proportional to the round-trip distance, as discussed in the first article. For example, if the count is 1 every 10 uS (100kHz) then each count will represent a distance of 3.43 mm (sound travels at about 343 mm/mS), or 1.71 mm to the object. A simple machine code loop will be sufficient if a resolution of around 1 cm is sufficient, otherwise a hardware counter would be required. A suitable Z80 programme segment is given below, which assumes that FLG is connected to d7 of a parallel port, XLG (or XLGQ) is on d6, MDL on d1 and that the port address is in register C. The other bits are ignored. The routine returns with the count In HL. Users of other processors will have to make do with the flowchart, unless they are bilingual.

xlg    equ  6,	     ;XLG bit
mdl    equ  1        ;MDL bit

start: ld   hl,0     ;clear counter
       xor  a        ;enable MDL
       set  mdl,a
       out  (c),a

wait:  in   (c),a    ;wait for a pulse
       bit  xlg,a
       jr   z,wait_q

count: inc  hi       ;count until FLG high
c1:    bit  7,h      ;check overflow
c2:    jr   nz,exit  ;exit if so

       in   (c),a
       jp   p,count  ;loop if bit 1 low

exit:  ret           ;count is in HL
Statements cl and c2 are not strictly necessary, and reduce the resolution. Without them, the loop around 'count' takes 26 T-states, giving a cycle time of 7 uS with a 4 MHz clock (28/4) or 8 uS with a 3.5 MHz clock (for Spectrum

Barg Newsletter Issue 3/4 - Page 17

owners). These times would give a resolution of 2.4 and 2.75 mm. respectively. However, if FLG never goes high (someone pulled out the plug), the routine will loop for ever. With a realistic clock speed the count In HL should never reach 32000, so if bit 7 of register H goes high after the 'inc hl' command you should jump out of the loop. The extra statements increase the number of T-states to 43, giving cycle times of 10.75 and 12.29 uS and resolutions of 3.7 and 4.2 mm for the above examples. Bear in mind, though, these are approximations which depend on several factors, including the temperature. The ringing system has a basic error of about +-3 mm anyway. The count in HL should be multiplied by half the appropriate figure to give the distance to the object. A distance greater than about 10,000 mm would indicate that the board had timed out. As with all software timing loops, interrupts should be disabled during the count.

An alternative is to use a hardware circuit to do the counting, allowing the processor to attend to other matters until the result is available. Figure 6 is a block diagram for a hardware counter. If the clock frequency is arranged to be 171.6 kHz then the count would be directly equivalent to the distance to the object in millimetres to within a few percent. Such a circuit could run continuously, with the processor reading the last count as required, or by using an interrupt to signal a reading was available.

The Polaroid rangefinder has its limitations, of course. A cycle time of around 150 - 200 mS (I have worked it faster, but not much) means it cannot be used where fast response is needed - Ping Pong machine builders take note. The single frequency board can be operated at higher speeds than the four frequency board, as it is less prone to overheating. Polaroid suggest using a battery of devices time multiplexed to improve response, but sorting which echoes belong where would seem a bit of a nightmare.

Barg Newsletter Issue 3/4 - Page 18

Another problem is the beam angle. According to the graph in the technical notes, the transducer response falls to -3dB (half power) at about 4 degrees each side of the centre line. My version was able to detect a 2 cm thick post within 15 cm of the centre line at 2.5 metres, giving an effective angle of +-3.5 degrees within which an object will be detected. This means that the rangeflnder cannot discrlmlnate between objects that are less than 30 cm apart at 2.5 metres, or 120 cm at extreme range (10 metres). It would be unable, for example, to see a doorway in a wall more than about 6 metres away. Possibly this is of academic interest only, as most of us would be concerned with much shorter ranges than this. Most ideas for narrowing the beamwidth involve redesigning the electronics, which is outside the scope of this article. One suggestion is to use an acoustic horn (HMV robots?).

A possibility that might work is to use a principle from radar. Bouncing the signal from a section of a parabolic reflector will focus the beam. To be effective, the reflector needs to be very much larger than the signal wavelength (about 7 mm In this case), and a 180 mm reflector should reduce the -3dB point to +-2.3 degrees. This is totally experimental, as I haven't tried it, and it depends on the sound waves behaving In the same way as light would in similar circumstances.

A glassflbre reflector could be moulded on the back of a car headlamp. Only a segment of about 1/3 of the headlamp is needed, as shown in Figure 7. The transducer would be mounted at the focus of the parabola, angled into the section so that it does not get in the way of the focused signal. If you try this idea, let me know how you get on.

As discussed in the earlier article, the speed of sound in air is dependent on temperature, and the values given have all assumed 20 degrees ambient. The error is not very great, as the speed varies by less than 2% in 10 degrees. If you intend to include a temperature sensor in your robot you can, of course, use this to provide compensation. The formula is given below. For the really

Barg Newsletter Issue 3/4 - Page 19

ambitious, compensation for inaccuracies generally can be incorporated by using a marker fixed relative to the transducer. The echo from this can be compared with that from the distant object (using the secondary pulse detect signal mentioned earlier), and the ratio used to calculate the distance:
      Distance to object = Distance to marker x (Time to object / Time to marker)
The marker would need to be 30 cm, or more, from the transducer to clear the echo-blanking period following transmission.

      Speed of Sound in Air : 331.4 x (T/273)^0.5   metres / Sec

                              where T is air tenperature in Kelvin
Electrical Characteristics
                              MIN    TYPICAL    MAX    UNITS
Supply Voltage	                4.9    5.6       6.8   Volts DC
Continuous Current (Receive)  175    200       250     mA
                   (Standby)   30     37        50     mA
Peak Current (Transmit)	     2500   3000               mA
VSW Input Current (High)      100              150     mA
/XDLG Output Current (Low)	                -0.5   mA
/XFLG Output Current (Low)	                -1.0   mA

Barg Newsletter Issue 3/4 - Page 20

Next -
BARG Newsletter Issue 3/4, Spring/Summer 1985 p21 - 28 -- Zero 2 review, Letters, Index