oBumper8 Object

Back to top of page Description:
 

A Hardware Object that reads a group of 8 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 oBumper8 Object.
 ObjectSizeDescriptionA1A2B1B2C1
oBumper84 BytesReads an 8-contact bumper.xx
Back to top of page Operation:
 

The oBumper8 Object uses the 8 I/O lines specified by the IOGroup property to read a group of 8 bumper switches. It converts the data to a URCP Heading value indicating the direction of the impact which is then stored in the Heading property. 

If any two or four adjacent bumper switches are pressed at the same time, the Heading property is adjusted to a URCP Heading indicating that the impart was located between the two center bumper switches and if any three adjacent bumper switches are pressed at the same time, the Heading property is adjusted to a URCP Heading indicating that the impact was located at the position of the center switch. 

When any one of the 8 bumper switches or two, three or four adjacent bumper switches are pressed, the Bumped property will be set to 1 and when all 8 bumper switches are not are pressed or two or more non-adjacent switches are pressed, the Bumped property is cleared to 0. 

Back to top of page Properties:
 

The following table lists the properties of the oBumper8 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
Data Type: Numeric Default Value: 0
I/O InputsBumpersPositionHeadingBumped3 or 4 adjacent switches pressed


URCP Heading

I/O InputsBumpers
00000001-------xFront0110010001x-----xx
00010001------xx 16110010011x----xxx
00010000------x-Front-Left32100010011-----xxx
00010010-----xx- 48100110011----xxxx
00000010-----x--Left64100110010----xxx-
00100010----xx-- 80100110110---xxxx-
00100000----x---Back-Left96100100110---xxx--
00100100---xx--- 112101100110--xxxx--
00000100---x----Back-128101100100--xxx---
01000100--xx---- -112101101100-xxxx---
01000000--x-----Back-Right-96101001100-xxx----
01001000-xx----- -80111001100xxxx----
00001000-x------Right-64111001000xxx-----
10001000xx------ -48111001001xxx----x
10000000x-------Front-Right-32110001001xx-----x
10000001x------x -16110011001xx----xx
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
IOGroup
A value that specifies which group of 8 I/O lines is connected to the 8 bumper switches.
Object Class: oIOGroup Value Range: 0 - 3
Data Type: Numeric Default Value: 0
Some I/O Lines have special purposes.  Be sure to see oIOGroup 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: oOrbitSwitch8X 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 page Examples:
 The following examples use the oBumper8 Object.
Visual Basic Syntax C and Java Syntax
' This program reads a 8 switch
' bumper, displays the URCP 
' heading value on I/O lines 
' 24 - 31 and the Received
' property on I/O line 7.

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

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

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

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

A Var oBumper8(1,cvOn)
B Var oDIO8(3,cvOutput)
C Var oDIO1(7,cvOutput)

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

The first set of 4 I/O lines of the 8 are used for the 4 four switches; Front, Left, Back and Right.  The second set of 4 I/O lines of the 8 are used for the 4 four switches; Front-Left, Back-Left, Back-Right & Front-Right.

Switch PositionTypical wiring for each switch
IOGroup:123Switch
Location
I/O 0:81624Front
I/O 1:91725Left
I/O 2:101826Back
I/O 3:111927Right
I/O 4:122028Front-Left
I/O 5:132129Back-Left
I/O 6:142230Back-Right
I/O 7:152331Front-Right

Caution: IOGroup 2 contains special purpose I/O such as Debugging, Serial Port & PWM. Do not use IOGroup 2 if these other functions are in use.

Back to top of page Related Items:

 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oBumper4Reads a 4-contact bumper.xxx
Back to top of page Version History and Bug List:
 Firmware Ver B2: Introduced.

Bugs: No known bugs.


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