Connecting SRF04 Sonar Modules to the Basic Atom 

Introduction
The SRF04 module is controlled by a trigger pulse from the Basic Atom 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 Basic Atom 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 Basic Atom in the photo above, the Basic Atom'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 Basic Atom

The following code can be downloaded here


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

' This code must be built with the PROGRAM command - NOT the DEBUG command
' The result is viewed in a terminal window - 9600, No Parity, No Flow Ct, NoEcho
' Click the "Connect" to start it going

Trig  Con P8            ' Define pin for Trigger pulse
Echo  Con P9            ' Define pin for Echo pulse

Range Var Word          ' 16 bit variable for Range

Main
    High Trig           ' Produces about 27uS pulse (must be minimum of 10uS)
    Low Trig
    Pulsin Echo,1,Range ' measures the range in uS
    Pause 10            ' SRF04 mandatory 10mS recharge period after ranging completes
    Range = Range/62    ' use 62 for cm or 149 for inches
    Serout S_OUT, i9600, ["Range = ", DEC Range, " cm", 13] ' Use terminal window
    Goto Main           ' and around forever
End

 


You can find more information on the SRF04 here