SRF05 Technical Documentation
To use mode 2 with the Basic Stamp BS2, you simply use PULSOUT and PULSIN on the same pin, like this:
SRF05 PIN 15 ' use any pin for both trigger and echo
Range VAR Word ' define the 16 bit range variable
SRF05 = 0 ' start with pin low
PULSOUT SRF05, 5 ' issue 10uS trigger pulse (5 x 2uS)
PULSIN SRF05, 1, Range ' measure echo time
Range = Range/29 ' convert to cm (divide by 74 for inches)
Calculating the Distance
The SRF05 Timing diagrams are shown above for each mode. You only need to supply a short 10uS pulse to the trigger
input to start the ranging. The SRF05 will send out an 8 cycle burst of ultrasound at 40khz and raise its echo line high (or
trigger line in mode 2). It then listens for an echo, and as soon as it detects one it lowers the echo line again. The echo line
is therefore a pulse whose width is proportional to the distance to the object. By timing the pulse it is possible to calculate
the range in inches/centimeters or anything else. If nothing is detected then the SRF05 will lower its echo line anyway after
about 30mS.
The SRF04 provides an echo pulse proportional to distance. If the width of the pulse is measured in uS, then dividing by 58
will give you the distance in cm, or dividing by 148 will give the distance in inches. uS/58=cm or uS/148=inches.
The SRF05 can be triggered as fast as every 50mS, or 20 times each second. You should wait 50ms before the next trigger,
even if the SRF05 detects a close object and the echo pulse is shorter. This is to ensure the ultrasonic "beep" has faded away
and will not cause a false echo on the next ranging.
The other set of 5 pins
The 5 pins marked "programming pins" are used once only during manufacture to program the Flash memory on the
PIC16F630 chip. The PIC16F630's programming pins are also used for other functions on the SRF05, so make sure you
don't connect anything to these pins, or you will disrupt the modules operation.
Changing beam pattern and beam width
You can't! This is a question which crops up regularly, however there is no easy way to reduce or change the beam width
http://www.robot-electronics.co.uk/htm/srf05tech.htm (3 di 4)09/03/2007 15.41.31