Connecting SRF04 Sonar Modules to the BX-24 

Introduction
The SRF04 module is controlled by a trigger pulse from the BX-24 host controller of around 10uS duration. After receiving the trigger pulse, the SRF04 will raise its echo pulse and wait for a returning echo. As soon as the echo is detected by the SRF04, it will lower its echo line again.   The BX-24 host controller will measure the width of the echo pulse and use this to calculate the range.

Although we have powered the SRF04 from the BX-24 in the photo above, the BX-24's internal 5v regulator is not suitable for powering much external circuitry. It will power a single SRF04 OK, but anything more and I would recommend you use a separate 5v regulator as shown in the schematic below. Further SRF04's can be connected, not shown here, with each SRF04 requiring its own  input and output pins.

Circuit Schematic for connecting an SRF04 Sonar Module to the BX-24

The following code can be downloaded here


'***********************************************************
'**                                                       **
'**      SRF04 Demonstration Software for the BX-24       **
'**                                                       **
'**           Copyright 2002 - Devantech Ltd              **
'**     Commercial use of this software is prohibited     **
'**     Private and educational use only is permitted     **
'**                                                       **
'**        Written by Gerald Coe - February 2002          **
'**                                                       **
'***********************************************************

Sub Main()
   Const EchoPin As Byte = 14             ' Define which pins you want to use here
   Const TrigPin As Byte = 13
   Dim Range As Integer

   Call PutPin(EchoPin, bxInputTristate)
   Call PutPin(TrigPin, bxOutputLow)
   do
      Call PulseOut(TrigPin, 10, 1)       ' 10uS Trigger pulse
      Range = PulseIn(EchoPin, 1) \ 54    ' use 54 for Cm or 137 for Inches
      Debug.Print "Range is "; CStr(Range)
      Call Delay(0.1)                     ' 100mS to next ping (minimum is 10mS)
   loop
End Sub


You can find more information on the SRF04 here