GP2D05 to OOPic Example
Last Modified: 2007-03-08
find:

basket

Acroname Robotics PDF webpage version GP2D05 to OOPic Example PDF

Related
Products

Product image for OOPIC II Starter Package
OOPIC II Starter Package
Product image for OOPIC II Module
OOPIC II Module

Contents

Photograph showing the Sharp sensor interfaced to an OOPic controller
Sharp GP2D05 interfaced to an OOPic

Introduction

In this example, an OOPic microcontroller uses a Sharp GP2D05 detector to detect the presence of obstacles.  The program reads the 1-bit output of the sensor and displays it with an LED. 

Circuit Schematic

The following schematic assumes the OOPic has power.  The GP2D05 uses very little current and can therefore safely be powered by the OOPic's 100ma onboard regulator.  The pin selections match those in the source code listed below. 

This circuit uses an interface diode to prevent the HIGH logic level of the OOPic's output at IO Line 9 from exceeding the 3.3 volts allowed by the GP2D05 detector.  This diode is included with and described in the instructions of the R21-IR05 package. 

Schematic diagram of Sharp GP2D05 interfaced to OOPic
GP2D05 to OOPic schematic

Source Code

This code uses BASIC syntax.  It runs with version 3.0.1 of the OOpic compiler and version A.1.7 of the OOpic chip. 

' This program takes continuous readings ' from a Sharp GP2D05 IR ranging module dim LED as new oDio1 dim VIN as new oDio1 dim VOUT as new oDio1 sub main() LED.IOLine=10 LED.Direction=cvOutput VIN.IOLine=8 VIN.Direction=cvOutput VOUT.IOLine=9 VOUT.Direction=cvInput do VIN.value=0 oopic.delay=6 ' 60ms delay LED.value=VOUT.value VIN.value=1 ' time for two instructions VIN.value=1 ' is approximately 1ms loop end sub

The VIN input of the Sharp GP2D05 detector must be high for 1ms to start a new measurement.  The OOpic executes 2000 Basic instructions per second so executing two instructions will take approximately 1ms.  A measurement is complete after 56ms.  The OOpic delay command uses 10ms time units so the program uses a delay of 60ms instead of 56ms. 

Revision History:

  • 2000-07-11: Created
  • 2000-08-14: Added version info for OOPic compiler and OOPic chip used in this example.
 
 
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.