oSrvSync Object

Back to top of page Description:
 A Processing Object that provides a method of synchronizing multiple servo-motors for use in such things as walking robots.
 The following table lists the size and availability of the oSrvSync Object.
 ObjectSizeDescriptionA1A2B1B2C1
oSrvSync6 BytesSequences up to 16 servosxxxx
Back to top of page Operation:
 The oSrvSync Object takes the value linked to by the Input property and copies that value to each servo in an array of servos linked to by the Output property. 

For each servo in the array, the value of the Span property multiplied by the servo's position in the array is additionally added to the servos Position property resulting in each servo being offset an equal distance from each other.  The first servo is set to the input value [S1 = Input + (Span * 0)], the second servo being set to the Input value + the span value [S2 = Input + (Span * 1)], the third servo being set to the input value + the span value twice [S3 = Input + (Span * 2)], and so on until each servo in the array is done. 

The RCMax property is provided to limit the distance that each servo will actually move by specifying the maximum value that the servos will be allowed to reach before their values are rolled-over.  As each servo's value is being set, the total value being set is logically ANDed with the value specified by the RCMax property.  This results in the servo's Position property never exceeding the RCMax value and also causes a roll-over effect which will cause the servo to reposition to the other side.  For example, if the value that is being set is 32, and RCMax specifies 31 as the maximum, then the servo will be set to 0, and if the value is 40, then the servo will be set to 8.

The RCJoint property specifies if every other servo is to be treated as the a knee joint in a dual servo leg as one would find on a Hex-a-pod style robot.  If RCJoint is set to 1, the calculations described above skips every other servo and the values of theses servos are set by the following rule:  If the preceding servo is within 2 units of the edge of its range, then the value is set to the value specified by the RCRise property, otherwise it is set to 0.

The Sync property is used to synchronize the values.  In normal operation, the oSrvSync Object will only update all of the servo's values if the first one is different than the Input value.  If the programmer determines that the servos may need to be updated when the first servo is not different, then the Sync value may be set to 1.  When the Sync value is set to 1, all of the servo's values will be updated and then the Sync property is cleared back to 0.  For example, it is typical that the initial position of both the first servo and the Input value would be 0.  In this case, it would be necessary to set the Sync property to 1 to initialize all the servos.

Back to top of page Properties:
 

The following table lists the properties of the oSrvSync Object:

Property

Description

Operate
A value that selects whether or not the servo locations are updated.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe servos are not positioned.
1cvOnThe servos are positioned.
Input
A pointer to an object whose value is to be used to set specify the position of the first servo.
Object Class: oValuePtrI Value Range: Any oValue Object
Data Type: Pointer Default Value: Null
Array
A pointer to an oBuffer Object from which values are returned from or stored to.
Object Class: oBufferPtr Value Range: Any oBuffer Object.
Data Type: Pointer Default Value: Null
Output
A pointer to an array of oServo Objects.
Object Class: oServoPtrO Value Range: Any oServo Object.
Data Type: Pointer Default Value: Null
RCQuantity
A value that specifies how many servos to update.
Object Class: oVar4 Value Range: 0 - 15
Data Type: Numeric Default Value: 0
Mode
A value that selects if the servo values are retrieved from a oBuffer object.
Object Class: oSelect0to1L Value Range: 0 - 1
Data Type: Numeric Default Value: 0
ModeConstantDescription
0cvFalseThe servo values are retrieved from the Input object.
1cvTrueThe servo values are retrieved from the Array.
RCJoint
A value that selects if the even numbered servos are to be used as a knee joints on a Legged Robot.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0
RCJointConstantDescription
0cvFalseThe servos are continuous.
1cvTrueThe servos are paired with the second in each pair used as the knee joint.
RCMax
A value that selects the maximum value that the servos are allowed to reach before the value is rolled-over.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0
RCMaxDescription
0The maximum servo value is 15.
1The maximum servo value is 31.
RCRise
A value that selects the value that the knee joint servos will be set to when the leg is in the upright position.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0
RCRiseDescription
0The rise value is 15
1The rise value is 31
RCSpan
A value that specifies the distance between servos.
Object Class: oVar6 Value Range: 0 - 63
Data Type: Numeric Default Value: 0
Sync
A value that selects if the servos need to be synchronized.
Object Class: oSelect0to1L Value Range: 0 - 1
Data Type: Numeric Default Value: 0
RCRiseDescription
0The servo values update if the first servo is different than the Input value.
1The servo values are updated and the Sync property is cleared back to 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 Example:
 In the following examples, the oSrvSync Object is used to make a hexapod robot walk forwards and backwards.
Dim S As New oSrvSync
Dim S01 As New oServo(10,1,35,,16,1)
Dim S02 As New oServo(11,0,24,,,1)
Dim S03 As New oServo(31,0,46,,16,1)
Dim S04 As New oServo(30,1,23,,,1)
Dim S05 As New oServo(12,1,35,,16,1)
Dim S06 As New oServo(13,0,23,,,1)
Dim S07 As New oServo(29,0,45,,16,1)
Dim S08 As New oServo(28,1,13,,,1)
Dim S09 As New oServo(14,1,36,,16,1)
Dim S10 As New oServo(15,1,19,,,1)
Dim S11 As New oServo(27,0,44,,16,1)
Dim S12 As New oServo(26,0,24,,,1)
Dim X As New oByte

Sub main()

  ' Set up the oSrvSync
  ' Virtual Circuit.
  S.Input.Link(X)
  S.Output.Link(S01)
  S.RCQuantity = 11
  S.RCRise = 1
  S.RCSpan = 5
  S.RCMax = 1
  S.RCJoint = 1
  S.Operate = cvTrue

  Do
    ' Walk forward
    For X = 0 To 255
      ooPIC.Delay = 250
    Next X 
    ' Walk backwards
    For X = 255 To 0 Step -1
      ooPIC.Delay = 250
    Next X 
  Loop

End Sub

Back to top of page Related Items:

 The following table lists other objects with related functions.
 ObjectDescriptionA1A2B1B2C1
oServoControls an RC Servo-motor.xxxxx
Back to top of page Version History and Bug List:
 Firmware Ver A2: Introduced.

Bugs: No known bugs.


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