SensComp to BS II Example
Last Modified: 2006-11-01
find:

basket

Acroname Robotics PDF webpage version SensComp to BS II Example PDF

Related
Products

Product image for SensComp 6500 Ranging Module
SensComp 6500 Ranging Module
Product image for SensComp 7000 Transducer
SensComp 7000 Transducer

Contents

Example setup for interfacing the Basic Stamp II to the Senscomp rangers.

Introduction

In this example, a Parallax Basic Stamp II uses a 6500 Polaroid Ranging Module combined with a 7000 Series transducer to measures distances to obstacles.  The stamp tells the sonar module to emit a "ping" and measures the time it takes to receive an echo.  It converts this time to a distance in inches and displays the value using the debug feature in the Basic Stamp II development software. 

Circuit Schematic

In the following schematic, the Basic Stamp II is powered by an external 9V battery.  The sonar module has its own supply of four AA batteries (Ni-Cad, NiMH, or Alkaline).  (Be sure the sonar module power supply and Stamp power supply share a common ground connection.) According to the Polaroid specs, The sonar module uses up to 2A during the transmit period and up to 100ma after the transmit period.  Do not use the Stamp's 50ma onboard regulator to power the sonar module.  The only additional component required for this circuit is a 4.7K pull-up resistor for the ECHO output from the sonar module. 

Wiring diagram between the Basic Stamp II and the 6500 ranger.

The test circuit also included a jumper wire between pin 3 and pin 15 of the socketed chip on the sonar board.  The jumper eliminated some noise problems as described in the Polaroid Sonar Ranging Primer

Source Code

This example code is written in PBASIC. 

' polaroid-1.bs2 ' POLAROID RANGER TEST PROGRAM ' 6-30-2000 '-------------------------------------------------------- ' variable declarations dist var word ' working variable for distance calculation '-------------------------------------------------------- ' constant declarations ECHO con 15 ' sonar module echo detection output INIT con 14 ' sonar module control input ' 1 starts a measurement ' 0 resets the module settle con 1 ' delay to ensure proper initialization delay con 20 ' time between sonar samples ' CONVERSION FACTORS ' ' The RCTIME command returns the round-trip echo time in 2us units ' which is equivalent to the one-way trip time in 1us units. ' ' Taking sonar samples in rapid succession may occasionally cause ' a false measurement. A delay between starting a sonar reading ' and measuring the time to receive an echo helps prevent this ' problem. Because of this delay, the distance calculation ' must include an offset. ' ' distance = (echo time + offset time) / (conversion factor) ' ' use 74 for inches (73.746us per 1 in) ' use 29 for centimeters (29.033us per 1 cm) convfac con 74 ' use inches offset con 700 ' (determined experimentally) '-------------------------------- ' main loop loop: gosub sr_sonar debug dec dist,cr pause delay goto loop sr_sonar: high INIT pause settle ' be certain that ECHO is low rctime ECHO,0,dist ' wait for ECHO to go high low INIT ' reset module dist=(dist+offset)/convfac return
Note

The Basic Stamp II-SX is 2.5 times faster than the regular Basic Stamp II.  Because of its higher speed, the SX "rctime" command measures time in 0.8us increments instead of 2us increments.  If you are using an SX chip, increase the offset constant to 1750.  Use 185 as the inch conversion factor.  Use 73 as the centimeter conversion factor.  The maximum interval for the SX "rctime" command is 52.4ms.  The "rctime" command will return 0 if the measured interval exceeds this limit.  In 52.4ms, sound travels about 60 feet.  That's 30 feet if you consider the round trip for an echo.  However, the maximum range for the Polaroid Sonar Ranger is 35 feet.  So the SX may give erroneous readings for obstacles at extreme range for the Polaroid module. 

Revision History:

  • 2000-06-30: Example created.
  • 2001-04-10: Added note about common ground connection.
 

Related Links:

Senscomp (Polaroid) Sonar Ranging Primer

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.