| SRF02 to BrainStem Example Last Modified: 2007-03-26 | | |
| Acroname Robotics | PDF webpage version | ||
| ![]() Introduction In this example, a BrainStem GP 1.0 module uses a Devantech SRF02 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. Circuit Schematic In the following schematic, one of the IIC headers on the BrainStem is used to interface to the IIC port on the SRF02 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 to power the circuit. ![]() Wiring diagram for interfacing the SRF02 to the IIC bus on the BrainStem. Source Code - I2C Mode The software interface for the SRF02 is identical that of the SRF08 and SRF10 Ultrasonic rangers. This program utilizes the built-in library for handling Devantech SRF08 Rangers and specifies which IIC address is used for the ranger. Different constants could be used to specify the readings in centimeters or milliseconds. Additional SRF02's 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. /* file: srf02ex.tea */
#include <aSRF08.tea>
#include <aPrint.tea>
#include <aCore.tea>
#define SRF02_ADDR 0xE0
void main() {
int val;
while(1) {
/* take inch reading from address 0xE0 */
val = aSRF08_RangeInt((char)SRF02_ADDR, aSRF08_INCH);
/* display on console */
aPrint_IntDec(val);
aPrint_String(" inches\\n");
/* sleep for 1 second */
aCore_Sleep(10000);
} /* while */
} /* main */
Revision History:
| |||||||
Related Links: | ||||||||
| voice: 720-564-0373, email: sales@acroname.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy © Copyright 1994-2008 Acroname, Inc., Boulder, Colorado. All rights reserved. |