Enhanced TEA for Senscomp Example
Last Modified: 2006-11-02
find:

basket

Acroname Robotics  
 

Contents

Introduction

Here is a library that permits the use of up to four Senscomp 6500 ultrasonic ranging modules.  These routines let you configure the BrainStem GP 1.0 module to use either digital outputs or servo outputs to initiate a sonar reading.  This makes it possible to use four servo outputs and four digital inputs to interface four 6500 modules.  This library is similar to the code in the enhanced SRF04 library example.  See that example for more discussion of TEA libraries.  You can copy this file to your aSystem folder and link it with your TEA applications. 

Note

If you're using servo outputs as digital output pins, use the GP application or Console commands to disable the servo PWM signals.  Then save the new servo configuration.  The servo pins will become digital output pins at power-up. 

Source Code

The a6500x_ConfigForServo routine can be used to configure a servo pin and digital IO pin for interfacing to a 6500 module.  Then you can take a reading with a call to the a6500x_ServoReadInt routine.  The a6500x_ConfigForDigital routine can be used to configure two digital IO pins for interfacing to a 6500 module.  Then you can take a reading with a call to the a6500x_DigReadInt routine. 

/* filename: a6500x.tea */ #ifndef _a6500x_T_ #define _a6500x_T_ #include <aIOPorts.tea> #include <aServo.tea> #include <aDig.tea> void a6500x_ConfigForServo(char init, char echo) { aServo_SetConfig(init, 0); aDig_Config(echo, 0x09); } void a6500x_ConfigForDigital(char init, char echo) { aDig_Config(init, 0); aDig_Config(echo, 0x09); } int a6500x_ServoReadInt(char init, char echo) { int val = 0; asm { /* this will be used to turn off init pulse */ pushlb 0 /* precalculate the INIT (servo cfg) port */ pushsb 7 pushlb aPortServoBlockSize multb pushls aPortServo + aOffsetServoConfig adds /* precalculate the echo port */ pushsb 8 pushlb aPortDigitalBlockSize multb pushls aPortDigital + aOffsetDigitalPTime adds /* turn on digital INIT output */ pushlb SRV_DSTA /* this sets output bit */ pushss 5 /* copy port address */ popbmx /* await the echo from precalculated echo port */ pushmsx /* pop the result into val */ popss 5 // stall before bringing the INIT low pushls 200 popsm aPortVMTimer /* lower INIT output (use 0 we pushed earlier) */ popbmx } return val; } int a6500x_DigReadInt(char init, char echo) { int val = 0; asm { /* this will be used to turn off init pulse */ pushlb 0 /* precalculate the INIT port */ pushsb 7 pushlb aPortDigitalBlockSize multb pushls aPortDigital + aOffsetDigitalIO adds /* precalculate the echo port */ pushsb 8 pushlb aPortDigitalBlockSize multb pushls aPortDigital + aOffsetDigitalPTime adds /* turn on digital INIT output */ pushlb 1 /* will turn on digital bit */ pushss 5 /* copy port address */ popbmx /* await the echo from precalculated echo port */ pushmsx /* pop the result into val */ popss 5 // stall 20ms before bringing the INIT low pushls 200 popsm aPortVMTimer /* lower INIT output (use 0 we pushed earlier) */ popbmx } return val; } #endif /* _a6500x_T_ */

Revision History:

  • 2005-03-01: Example Created
 

Related Links:

Senscomp (Polaroid) Sonar Ranging Primer

Related Examples:

Interface between SensComp 6500 Ranging Module and BrainStem GP Example

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.