oBumper4 Object

Main Index
Object List
Back to top of pageDescription:
 

A Hardware Object that reads a group of 4 bumper switch inputs and returns a URCP Heading value indicating the direction of the impact.

 The following table lists the size and availability of the oBumper4 Object.
 ObjectSizeDescriptionA1A2B1B2C1
oBumper44 BytesReads a 4-contact bumper.xxx
Back to top of pageOperation:
 

The oBumper4 Object uses 4 I/O lines specified by the IOPack property to read a group of 4 bumper switches. It converts the reading to a URCP Heading value indicating the direction of the impact which is then stored in the Heading property.  If any two adjacent bumper switches are pressed at the same time, the Heading property is adjusted to a URCP value indicating that the impact was located between the two bumper switches. When any one of the 4 bumper switches or two adjacent bumper switches are pressed, the Bumped property will be set to 1 and when all 4 bumper switches are not are pressed or two or more non-adjacent switches are pressed, the Bumped property is cleared to 0. 

When created, the oBumper4 Object also creates an instance of the oOrbitSwitch4 object which it uses to read the 4 I/O lines and generate the Heading value.  Modifying any of the properties of the oOrbtSwitch4X Object instance will affect the oBumper4 Object's operation. See the oOrbitSwitch4 for more detail on how the 4 I/O lines are read.

Back to top of pageProperties:
 

The following table lists the properties of the oBumper4 Object:

Property

Description

Heading
A value that indicates the heading in the direction of the bumper switch that has been pressed.
Object Class: oHeading Value Range: -128 to +127 (URCP Heading)
Data Type: Numeric Default Value: 0
I/O InputsBumperPositionHeadingBumped


URCP Heading

0001---xFront01
0011--xx 321
0010--x-Left641
0110-xx- 961
0100-x--Back-1281
1100xx-- -961
1000x---Right-641
1001x--x -321
Other  Unchanged0
Bumped
A value that indicates if the one of the bumper switches is pressed.
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
IOPack
A value that specifies which pack of 4 I/O lines is connected to the 4 bumper switches.
Object Class: oIOPack Value Range: 0 - 7
Data Type: Numeric Default Value: 0
Some I/O Lines have special purposes.  Be sure to see oIOPack help file for details.
Operate
A value that selects whether or not the bumper switches are being read.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe bumper switches are not read.
1cvOnThe bumper switches are read.
DIO
The I/O function object used to read the bumper switches
Object Class: oOrbitSwitch4 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 oBumper4 Object is used.
Visual Basic Syntax C and Java Syntax
' This program reads a 4 switch
' bumper, displays the binary 
' URCP value on I/O Lines 
' 24 - 31 and the Received 
' property on I/O line 7.

Dim A As New oBumper4 
Dim B As New oDIO8
Dim C As New oDIO1

Sub Main()
  ooPIC.PullUp = 1
  A.IOPack = 5
  A.Operate = cvTrue
  B.IOGroup = 3
  B.Direction = cvOutput
  C.IOLine = 21
  C.Direction = cvOutput
  Do
    B.Value = A.Value
    C.Value = A.Received
  Loop
End Sub
// This program reads a 4 switch
// bumper, displays the binary
// URCP value on I/O Lines
// 24 - 31 and the Received
// property on I/O line 7.

oBumper4 A = New oBumper4;
oDIO8 B = New oDIO8;
oDIO1 C = New oDIO1;

Void Main(Void){
  ooPIC.PullUp = 1;
  A.IOPack = 5;
  A.Operate = cvTrue;
  B.IOGroup = 3;
  B.Direction = cvOutput;
  C.IOLine = 21;
  C.Direction = cvOutput;
  Do{
    B.Value = A.Value;
    C.Value = A.Received;
  } While (1);
}
Basic Syntax 
' This program reads a 4 switch
' bumper, displays the binary 
' URCP value on I/O Lines 
' 24 - 31 and the Received 
' property on I/O line 7.

A Var oBumper4(5,cvOn)
B Var oDIO8(3,cvOutput)
C Var oDIO1(21,cvOutput)

ooPIC.PullUp = 1
1:
  B.Value = A.Value
  C.Value = A.Received
  Goto 1
 
Back to top of pageConnections:
 The oBumper4 uses 4 I/O lines.  These 4 I/O lines must be 4 contiguous I/O lines starting with I/O line 8, 12, 16, 20, 24, or 28.  The inputs are active low and each of the 4 I/O lines will require a pull up resister.  If the I/O lines starting with 8 or 12 are selected, the internal pull up resisters can be used by setting the ooPIC.PullUp property to 1.

The 4 I/O lines are used for the 4 four switches; Front, Left, Back and Right. 

Switch PositionTypical wiring for each switch
IOPack:1234567Switch
Location
I/O 0:816245122028Front
I/O 1:917256132129Left
I/O 2:1018267142230Back
I/O 3:111927-152331Right

Caution: IOPack 2 and 6 contain special purpose I/O such as Debugging, Serial Port & PWM. Do not use these I/O Lines if they are in use by the other functions.

Back to top of page Related Items:
 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oBumper8Reads an 8-contact bumper.xx
Back to top of page Version History and Bug List:
 Firmware Ver B1: Introduced.

Bugs: No known bugs.


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