| SRF05 to BrainStem Last Modified: 2008-06-11 | | |
| Acroname Robotics | PDF webpage version | ||
| ![]() Introduction The SRF05 Ranger has the unique ability to operate in two different modes to provide system design options when implementing the sensor into resource constrained microcontroller. The BrainStem GP tells the SRF05 module to emit a "ping" and measure the time it takes to receive an echo. It reveals the distance as a raw time in increments of the timer's resolution which is 1.6 uSec that can be directly translated into distance. Operational Mode 1 is back compatible to the Devantech SRF04 , and requires two different digital pins to provide the trigger and the echo pulses when taking readings. A second example illustrates how to use the operational Mode 2 that only requires the use of a single digital IO pin to handle the triggering and echoing functions. Both examples use a host computer running the Console application to display the sonar readings measured from the BrainStem.
Circuit Schematic - Mode 1 Operation In the following schematic, two digital I/O pins of a BrainStem GP 2.0 are configured to handle the ECHO and INIT lines of the SRF05 ranging module. For this example, the ECHO pin is wired up to the GP digital pin 1. This is the line that will receive the value measured by the SRF05 ranger. The ECHO pin must be capable of using the Ptimer input capture to measure the width of the pulse generated by the SRF05. The INIT pin is wired to the GP digital pin 0. This is the pin that will send a 10 uSec pulse to initiate the sonic bursts by the ranger. The circuit is powered by a 6C Battery Pack. ![]() Source Code - Mode 1 Operation This code uses the TEA language which is very similar to ANSI C. It is compiled using the BrainStem Console with the steep command. Both source code examples utilize the built-in library for handling Devantech SRF05 Rangers and specifies which BrainStem digital I/O lines are being used before including the library for the SRF05 drivers (Build 23 and up). /* srf05_mode1.tea */
/* included for the display routines */
#include <aCore.tea>
#include <aPrint.tea>
/* now include the SRF05 driving routines */
#include <aSRF05.tea>
/* set which pins control the SRF05 */
#define aSRF05_INIT 0
#define aSRF05_ECHO 1
#define DELAY 2500
#define ITERATIONS 50
void main()
{
int i;
int r = 0;
for (i = 0; i < ITERATIONS; i++) {
/* Call the SRF05 read sensor function */
r = aSRF05Mode1_ReadInt(aSRF05_INIT,aSRF05_ECHO);
/* Print the values to the Console */
aPrint_IntDec(r);
aPrint_Char('\n');
aCore_Sleep(DELAY);
} /* End of for loop */
} /* End of main */
Circuit Schematic - Mode 2 Operation In the following schematic, a single digital pin is used for both the INIT and the ECHO lines of the SRF05. For this example, the INIT/ECHO line is wired into the GP digital pin 1. This pin is capable of measuring state transitions. ![]() Source Code - Mode 2 Operation This example code takes a single reading from the SRF05 ranger and prints the value out to the Console application. A short delay is introduced to allow the Console application the chance to print all the readings to the screen. /* srf05_mode2.tea */
/* included for the display routines */
#include <aCore.tea>
#include <aPrint.tea>
#include <aDig.tea>
/* now include the SRF05 driving routines */
#include <aSRF05.tea>
/* set which pins control the SRF05 */
#define aSRF05_DIGITAL 1
#define DELAY 2500
#define ITERATIONS 50
void main()
{
int i;
int r = 0;
for (i = 0; i < ITERATIONS; i++) {
/* Call the SRF05 read sensor function */
r = aSRF05Mode2_ReadInt(aSRF05_DIGITAL);
/* Print the values to the Console */
aPrint_IntDec(r);
aPrint_Char('\n');
aCore_Sleep(DELAY);
} /* End of for loop */
} /* End of main */
Revision History:
| ||||||||||
Related Links: Evaluations: The Devantech SRF05 Brainstem Software: Console Overview The Devantech Sonic Range Finders Comparison and Examples Related Examples: Example code and schematic for Devantech SRF04 sensor interface to BrainStem GP | |||||||||||
| voice: 720-564-0373, email: sales@acroname.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy © Copyright 1994-2010 Acroname, Inc., Boulder, Colorado. All rights reserved. |