oIRRange Object

Main Index
Object List
Back to top of pageDescription:
 

The oIRRange Object is a Hardware Object that uses one I/O line to read a Sharp GP2D12 distance detector in a 64 steps per foot reading.  Sharp GP2D12 can precisely and reliably read the distance to an from 10cm-80cm away.

The oIRRange Object calculates a value based on how far away the obstacle is from the sensor. 

 The following table lists the size and availability of the oIRRange Object.
 ObjectSizeDescriptionA1A2B1B2C1
oIRRange5 BytesReads a Sharp GP2D12 IR ranging module.xxx
Back to top of pageOperation:
 

The oIRRange Object reads the output signal from a Sharp GP2D12 IR ranging module and calculates a number that indicates the distance between the GP2D12 and its target.  It expects that the signal is being provided by a Sharp GP2D12 Module connected to the I/O line specified by the IOLine property.  The distance value that is calculated (which is measured in 64 steps per foot) is stored in the Distance property.

Each Sharp GP2D12 Module appears to return slightly different readings.  The Adjust property was added in firmware version B.2.0 to allow the input value from the Sharp GP2D12 to be adjusted.  When connecting a new Sharp GP2D12 Module, the Adjust property needs to be adjusted so that when nothing is in front of it, the oIRRange Object returns a steady reading of 128.  The most common Adjust values are between 0 and 10.

When created, the oIRRange Object also creates an instance of the oA2DX object which it uses to read the output signal from the sensor.  The instance of the oA2DX is configured to use a 5 volt reference and modifying that or any other properties of the oA2DX instance will affect the oIRRange Object's operation in ways that could make the oIRRange Object unable to read the sensor.  See the oA2DX Help for more detail on how analog signals (such as the signal form the Sharp GP2D12 IR ranging module) are read.

Back to top of pageProperties:

The following table lists the properties of the oIRRange Object:

Property

Description

Distance
A value that indicates the distance to the target.  (in 64 steps per foot)
Object Class: oDistance Value Range: 0 - 255
Data Type: Numeric Default Value: 0
IOLine
A value that specifies which I/O Line is use to read the Sharp GP2D12 IR ranging module.
Object Class: oIOLineA Value Range: 0 - 7
Data Type: Numeric Default Value: 0
Adjust
A value that specifies a calibration value for the Sharp GP2D12 IR ranging module.
Object Class: oAdjust Value Range: -128 to +127
Data Type: Numeric Default Value: 0
Availability: This property was added if firmware version B.2.0
Operate
A value that selects whether or not the Sharp GP2D12 distance detector is read.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe detector is not read.
1cvOnThe detector is read.
A2D
The I/O function object used to read the Sharp GP2D12 IR ranging module's distance data.
Object Class: oA2DX Value Range: -128 to +127
Data Type: Numeric Default Value: 0
Address
Returns a pointer to the address of the oCounter Object instance.
Object Class: oAddress Value Range: 0 - 127
Data Type:Pointer (Read Only) Default Value: Address of Object

Back to top of pageExamples:
 In the following example, the oIRRange Object is used.
Visual Basic Syntax C and Java Syntax
'This program reads a Sharp  
'GP2D12 and outputs the binary
'result on a oDio8.

Dim I As New oIRRange  
Dim P As New oDIO8

Sub Main()
  I.IOLine = 3
  I.Operate = 1
  I.Adjust = 8
  P.IOGroup = 1
  P.Direction = cvOutput
  Do
    P.Value = I.Value
  Loop
End Sub
// This program reads a Sharp
// GP2D12 and outputs the binary
// result on a oDio8.

oIRRange I = New oIRRange;
oDIO8 P = New oDIO8;

Void Main(Void){
  I.IOLine = 3;
  I.Operate = 1;
  I.Adjust = 8;
  P.IOGroup = 1;
  P.Direction = cvOutput;
  Do{
    P.Value = I.Value;
  } While (1);
}
Basic Syntax 
'This program reads a Sharp  
'GP2D12 and outputs the binary
'result on a oDio8.

I As oIRRange(3,8,cvOn)
P As oDIO8(1,cvOutput)

Do
  P.Value = I.Value
Loop
 
Back to top of page Connections:

The oIRRange Object uses 1 I/O line.  The I/O line can be any 1 of the analog I/O lines.  As shown, a Sharp GP2D12 is connected in a circuit with a capacitor. 

Note that the value of the capacitor is 4.7uF.  

Back to top of page Related Items:
 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oIRPD1Reads a Lynxmotion IR Proximity Detector.xxxxx
oIRPD(2)Reads a Lynxmotion Dual IR Proximity Detector.xx
oSonarDVReads a Devantech SRF04 Ultrasonic Range Finder.xxx
oSonarPLReads a Polaroid 6500 sonar ranging module.xxx
Back to top of page Version History and Bug List:
 Firmware Ver B.1.0: Introduced.
Firmware Ver B.2.0: The Adjust property was added.

Bugs: No known bugs.


ooPIC Compiler Ver 6.0 (c) Copyright 1997 - 2007 Savage Innovations, LLC.