SRF10 to BrainStem Example
Last Modified: 2007-11-06
find:

basket

Acroname Robotics  

Related
Products

Product image for Devantech SRF10 Ranger
Devantech SRF10 Ranger
Product image for BrainStem IIC Cable
BrainStem IIC Cable

Contents

Hardware used for SRF10 to BrainStem example.

Introduction

In this example, a BrainStem GP 1.0 module uses a Devantech SRF10 Ranger to measures distances to obstacles.  The BrainStem GP 1.0 uses its built in high speed IIC bus to communicate with the ranger and display the readings on the Console application.  A BrainStem Moto 1.0 could also be used to run the example program since it has identical IIC capabilities. 

Circuit Schematic

In the following schematic, one of the 2 IIC headers on the BrainStem is used to interface to the IIC port on the SRF10 ranger.  Power and ground are also connected using the BrainStem GP's built-in power regulation.  Additionally, this circuit uses the 4 AA battery pack with four AA NiMH batteries to power the circuit. 

Wiring diagram between the SRF10 and the BrainStem.

Source Code

This code uses the TEA language which is a subset of the C programming language.  It is compiled using the BrainStem Console with the steep command. 

This program utilizes the built-in library for handling the Devantech SRF08 Ranger.  The library works with the SRF10, which is similar in function to the SRF08.  The library also specifies which IIC address is used for the ranger.  Different constants could be used to specify the readings in centimeters or milliseconds.  Up to sixteen additional SRF10s could be added along the IIC bus and given different addresses.  These other addresses would then be sent as parameters to the aSRF08_RangeInt command. 

/* filename: srf08-1a.tea */ #include <aSRF08.tea> #include <aPrint.tea> #include <aCore.tea> void main() { int val; while(1) { /* take inch reading from address 0xE0 */ val = aSRF08_RangeInt((char)0xE0, aSRF08_INCH); /* display on console */ aPrint_IntDec(val); aPrint_String(" inches\\n"); /* sleep for 1 second */ aCore_Sleep(10000); } /* while */ } /* main */

Changing SRF10 I2C Address

The IIC address of an SRF10 sensor can be changed by entering commands at the Console prompt.  Before trying to change the address, set the IIC baud rate to 100kbps.  This will ensure reliable communication with the sensor.  To change the baud rate on a BrainStem with an address of 2, enter the following command at the Console prompt:

2 18 3 0

That issues the cmdVAL_SET command (18) to change the IIC baud rate (parameter 3) to 100Kbps (code 0).  The commands in the table below will change the address from 0xE0 (224) to 0xE2 (226).  When entering data in the Console, it is acceptable to use hexadecimal text, decimal text, or a mixture of both.  The last number in the last command is the new address:

0xE0 0 0xA0 /* 1st in sequence */ 0xE0 0 0xAA /* 2nd in sequence */ 0xE0 0 0xA5 /* 3rd in sequence */ 0xE0 0 0xE2 /* New address value */

After changing the address, the red LED on the SRF10 will remain lit and the unit must be turned off.  When powered up again, it will have the new address.  Complete details of SRF10 operation may be found at the Devantech website

Revision History:

  • 2004-10-01: Example Created.
 

Related Links:

Brainstem Software: Console Overview

The Devantech Sonic Range Finders Comparison and Examples

voice: 720-564-0373, email: sales@acroname.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy
© Copyright 1994-2012 Acroname, Inc., Boulder, Colorado. All rights reserved.