 |
oCenterSwitch4 Object
|
|
|
Description: |
| | The oCenterSwitch4 Object is an I/O Function Object that is used to determine the center most active switch of a switch array. It is designed to gather information about moving objects such as a car driving over a set of pressure switches or a line that a robot needs to follow. The oCenterSwitch4 Object can be configured to look at either 3 or 4 consecutive inputs. It will report the position of the active switch, if it detects any active switches, which direction the active switch moved, and if there are no active switches, which side the active switch was on last. |
| | The following table lists the size and availability of the oCenterSwitch4 Object.
| | Object | Size | Description | A1 | A2 | B1 | B2 | C1 |
 | oCenterSwitch4 | 5 Bytes | An Object that finds the center most active Input. | x | x | x |
|
Operation: |
| | The oCenterSwitch4 Object monitors the 4 I/O lines specified by the IOPack property. It is expecting that the 4 I/O lines are connected to an array of 4 switches that are arranged in such a way to detect a moving object. It takes reading from these I/O lines and calculates a URCP Heading based on the position of the object and stores it in the Position property. Before the URCP Value is stored in the Position property, it is compared to the previous value and the Direction property is set based on the direction that the object has moved. If the object is in the middle of the switch array, then the Center property is set to 1, otherwise the Center property is set to 0. If no switches are active, then the OutOfRange property is set to 1 and the Position property is set based on the value of the Mode property. If the Mode property is 0, then the oCenterSwitch4 Object assumes that the object the switches are detecting has moved to the right or left of the switch array and the Position property is set to 32 or -32 depending on the value of the Direction property. If the Mode property is 1, then the oCenterSwitch4 assumes that object the switches are detecting is between the two middle switches and the Position property is set to 0 and the Center property is set to 1. |
Properties: |
| The following table lists the properties of the oCenterSwitch4 Object:
|
Examples: |
| | In the following example, the oCenterSwitch4 Object is used.
| Visual Basic Syntax | C and Java Syntax |
'This program creates a Virtual
'Circuit that uses an oCenterSwitch4
'Object to track a line and
'position a servo via an oServo
'Object for a line following robot.
Dim l As New oCenterSwitch4
Dim S As New oServoX
Dim W As New oBus
Sub Main()
ooPIC.PullUp = cvTrue
l.IOPack = 1
l.Operate = cvTrue
S.IOLine = 1
S.Operate = cvTrue
W.Input.Link(l.Position)
W.Output.Link(S)
W.Operate = cvTrue
End Sub | // This program creates a Virtual
// Circuit that uses an oCenterSwitch4
// Object to track a line and
// position a servo via an oServo
// Object for a line following robot.
oCenterSwitch4 l = New oCenterSwitch4;
oServoX S = New oServoX;
oBus W = New oBus;
Void Main(Void){
ooPIC.PullUp = cvTrue;
l.IOPack = 1;
l.Operate = cvTrue;
S.IOLine = 1;
S.Operate = cvTrue;
W.Input.Link(l.Position);
W.Output.Link(S);
W.Operate = cvTrue;
} |
| Basic Syntax | |
' This program creates a Virtual
' Circuit that uses an oCenterSwitch4
' object to track a line and
' position a servo via an oServo
' object for a line following robot.
l As oCenterSwitch4(1,,,,cvOn)
S As oServoX(31,,,,,,,cvOn)
W As oBus(l.Position,,S.Position,cvOn)
ooPIC.PullUp = cvTrue |
|
Connections: |
| | See the oTracker Object for connection examples. |
Related Items:
|
| | The following table lists the objects that use the oCenterSwitch4 Object.
| | Object | Description | A1 | A2 | B1 | B2 | C1 |
 | oTracker | An Object that tracks the position of a line. | x | x | x |
|
| | The following table lists objects with related functions
| | Object | Description | A1 | A2 | B1 | B2 | C1 |
 | oOrbitSwitch4 | Reads a circular array of 4 switches. | x | x |
 | oOrbitSwitch8 | Reads a circular array of 8 switches. | x | x |
|
Version History and Bug List: |
| | Firmware Ver B1: Introduced. Bugs: No known bugs. |
|