oIRPD2 Object
An Object that reads an IR Proximity Detector with two detectors.
Description:
 

A Hardware Object that uses three I/O lines to control the two IR LEDs contained in an IR Proximity Detector and read their reflection state.

Operation:
 

The oIRPD2 Object alternately toggles two I/O lines which are used as control outputs with one for a right side IR LED and one for a left side IR LED.  A third I/O line monitors the output of an IR Sensor that detects the reflection state of both the IR LEDs.  After the reflection state of both LEDs is determined, a value indicating the reflection state is calculated and stored in the Value property.

The four flag style properties; Center, Left, Right and NonZero are also updated each time the reflection state is determined.  The Center, Left and Right properties are exclusive and only one will be true at any time, while the NonZero flag is true if the Value property is any value other than 0, which indicates that the light from either or both of the IR LEDs is being reflected.

The oIRPD2 Object expects that the I/O line specified by the IOLineS property is connected to an IR Sensor such as the Sharp GP1U581Y and that the I/O lines specified by the IOLineR and the IOLineL properties are combined with a modulation source who's modulation matches the IR Sensor's.  The Lynxmotion IRPD is configured in this way.

Storage size & Availability:
 

The following table lists the size and availability of the oIRPD2 Object.

ObjectSizeFirmware VersionCompiler Version
oIRPD2 5 Bytes B.2.0 5.00
Properties:
 

The following table lists the Properties of the oIRPD2 Object

Property Description
Address

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

Data-Type: Address, Read-Only

Data-Range: 0 - 127

Center

A value that indicates that the light from both the right and left IR LED's are reflecting back to the IR sensor.

Data-Type: Bit, Flag

Data-Range: 0 - 1

InvertIn

A value that specifies if the input is to be inverted. 
Normally, the oIRPD2 Object is expecting that when an IR reflection is detected by the IR Sensor, the I/O Line specified by the IOLineS property is taken to a logical high state by the IR Sensor.  By setting the InvertIn property to 1, the expected input can be inverted so that a logical low state indicates a detection.

Data-Type: Bit

Data-Range: 0 - 1

InvertIn Constant Description
0 cvFalse A detection is indicated with a logical 1.
1 cvTrue A detection is indicated with a logical 0.
InvertOut

A value that specifies if the outputs are to be inverted.
Normally, the output lines specified by the IOLineR and IOLineL properties are set to logical high (+5 volts) when their associated IR LED is to be on.  By setting the InvertOut property to 1, the outputs can be inverted so that a logical low (0 volts) is used to turn the IR LEDs on.

Data-Type: Bit

Data-Range: 0 - 1

InvertOut Constant Description
0 cvFalse The outputs lines are taken to +5 volts to turn on the IR LEDs.
1 cvTrue The outputs lines are taken to 0 volts to turn on the IR LEDs.
IOLineS

A value that specifies the physical I/O Line to connect to the IR Sensor.

Data-Type: Nibble

Data-Range: 0 - 31

IOLineL

A value that specifies the physical I/O Line to use for the left side IR LED.

Data-Type: Nibble

Data-Range: 0 - 31

IOLineR

A value that specifies the physical I/O Line to use for the right side IR LED.

Data-Type: Nibble

Data-Range: 0 - 31

Left

A value that indicates that the light from just the left IR LED is reflecting back to the IR sensor.

Data-Type: Bit, Flag

Data-Range: 0 - 1

NonZero

A value that indicates that the Value property is a value other than zero.

Data-Type: Bit, Flag

Data-Range: 0 - 1

InvertOut Constant Description
0 cvFalse The outputs lines are taken to +5 volts to turn on the IR LEDs.
1 cvTrue The outputs lines are taken to 0 volts to turn on the IR LEDs.
Operate

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

Data-Type: Bit, Flag

Data-Range: 0 - 1

Right

A value that indicates that the light from just the Right IR LED is reflecting back to the IR sensor.

Data-Type: Bit, Flag

Data-Range: 0 - 1

Value

A value that indicates a calculated value of the reflection state.

Data-Type: Word, Default

Data-Range: 0 to 3

Value Constant Description
0   Nether of the IR LEDs are reflecting back to the IR sensor.
1   The light from just the left IR LED is reflecting back to the IR sensor.
2   The light from just the right IR LED is reflecting back to the IR sensor.
3   The light from both IR LEDs are reflecting back to the IR sensor.
Connections:
The Lynxmotion IRPD uses 3 I/O lines.  Each of the three can be any one I/O line of the OOPic's 31 I/O lines.  The IRPD uses a 9 volt power input to operate. 
Note: The Lynxmotion IRPD's SOUT line is inverted therefore, to use the oIRPD2 Object to read the Lynxmotion IRPD, the InvertIn property must be set.
Lynxmotion IRPD
PinNameDescriptionI/O NameOOPic
I/O Line
1,2 +9v +9 Volts power   +V
3 LLED Left IR LED control IOLineL Any
4 RLED Right IR LED control IOLineR Any
5 SOUT IR Sensor Out IOLineS Any
6 +5v +5 Volts power    
7,8 Gnd Ground   Gnd
Example:
  In the following example, the oIRPD2 Object is used to read a Lynxmotion IRPD.
' This program reads a Lynxmotion IRPD
' and displays the results on I/O lines
' 24 and 25.
Dim A As New oIRPD2
Dim B As New oDio4

Sub Main()
  A.IOLineL = 28
  A.IOLineR = 30
  A.IOLineS = 29
  A.InvertIn = cvTrue
  A.Operate = 1
  B.IOGroup = 3
  B.Direction = cvOutput
  Do
    B.Value = A.Value
  Loop
End Sub
                          
See Also:
 

oIRPD1 - An Object that reads an IR Proximity Detector.
oIRRange - An Object that reads a Sharp GP2D12 Infrared distance detector module.