KLCarithers Robotics

Devantech SRF05

Kyle L. Carithers

 

The Devantech SRF05 is a sonar module that features two modes of operation and a four meter maximum range.  One mode uses two digital pins on a microcontroller.  One pin is a trigger pin and is held high for 10µs to trigger sonar.  The second pin is the output of the sonar and is held high for a length of time proportional to the distance the sonar is away from an object.  In this mode, the SRF05 is a drop in replacement for the previous SRF04 sonar module.  Aside from a led that blinks every time the sonar is triggered, a feature very useful when debugging, the SRF05 offers an additional feature not found on the SRF04, a second mode of operation.  In this mode, the trigger line and output of the sonar are sent on a single line to and from the microcontroller.  This mode requires the microcontroller to switch the pin from an output for the trigger to an input for the sonar output.  This mode is beneficial because it allows each sonar module to be placed on a single pin.  Additionally, each sonar module requires only three wires, VCC, GND, and signal.

 

Further explanation of each mode is detailed along with example code in C.

 

Mode 2, Single pin mode

This code includes a function that can return the distance measured by any one of a maximum eight possible sonar placed on a single port of the Atmega128.  The single pin mode is mode 2 for the sonar.

 

Mode 1 using an external interrupt combined with a multiplexer

This code uses the two pin mode, mode 1 of the SRF05.  The example code is designed to be used with the output of five sonar connected to a multiplexer.  The multiplexer uses three digital pins on the microcontroller to determine which sonar signal to send to an external interrupt pin on the microcontroller.