oIRRange Object
An Object that reads a Sharp GP2D12 Infrared distance detector module.
Description:
 

A Hardware Object that uses one I/O line to read a Sharp GP2D12 distance detector in a 64 steps per foot reading.

Operation:
 

The oIRRange Object reads an analog voltage from the I/O line specified by the IOLine property.  It expects that the analog voltage is being provided by a Sharp GP2D12 Module connected to the I/O line.  Once the analog voltage is read, its value is then used to look up a value in a measurement table that corresponds to the distance that the GP2D12 Module is away from its target.  This distance value ( measured in 64 steps per foot) is then stored in the Value property.

The oIRRange Object is an analog Object and shares the Analog-To-Digital converter module with all other analog Objects.  See the oA2D Object for details on the Analog-To-Digital converter module.

The oIRRange Object expects that the Analog-To-Digital converter module has its reference voltage set to 5 volts (which is the reference voltage at power up).  Changing the OOPic.ExtVRef property will change the Voltage Reference and will cause the oIRRange to not function property.

Each Sharp GP2D12 Module appears to return slightly different readings.  The Center 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 Center 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 Center values are between 0 and 10.

Storage size & Availability:
 

The following table lists the size and availability of the oIRRange Object and its variations:

ObjectSizeVersion
oIRRange 5 Bytes B.1.0
Properties:
 

The following table lists the Properties of the oIRRange Object:

Property Description
Address

Returns a pointer to the address of the oIRRange Object instance.

Data-Type: Address, Read-Only

Data-Range: 0 - 127

Center

A value that is used to adjust the center point of the value property.  

Availability: This property was added if firmware version B.2.0

Data-Type: Byte

Data-Range: -128 to 127

IOLine

A value that specifies the physical I/O Line to use.

Data-Type: Nibble

Data-Range: 0 - 7

Operate

A value that specifies whether or not the data is updated.

Data-Type: Bit, Flag

Data-Range: 0 - 1

Value

The distance to the target in 64 steps per foot

Data-Type: Byte, Default

Data-Range: 0 - 128

Example:
  In the following example, the oIRRange Object is used.
'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 = 1
  I.Operate = 1
  P.IOGroup = 3
  P.Direction = cvOutput
  Do
    P.Value = I.Value
  Loop
End Sub
See Also:
 

oIRPD1 - An Object that reads an IR Proximity Detector.
oIRPD2
- An Object that reads an IR Proximity Detector with two detectors.
oSonarPL
- An Object that reads a Polaroid Ultrasonic Range Finder.
oSonarDV - An Object that reads a Devantech SRF04 Ultrasonic Range Finder.