oServoX Object
An Object that uses URCP Heading values to control an RC Servo.
Description:
 

A Hardware Object that uses one digital I/O line to set the position of an RC servo-motor using URCP Heading values for positioning.

The oServoX Object is capable of positioning an RC Servo anywhere within its 180 degree rotational span.  The position within the 180 degree span is specified by a value with a range of -64 to 63 were 0 is the center position. Once the servo has reached the specified position, it is held in place until the specified position changes or the oServoX Object is turned off.

The maximum number of oServoX Objects that can be dimensioned in a single application program is 14, limited only by the amount of Object RAM.  At best case, it is possible to control all 14 oServoX servos at the same time with a high torque setting of 70 Pulses Per Second.  At worse case, All 14 possible oServoX servos at full swing can be controlled at the same time while maintaining a 20 Pulses Per Second refresh rate.

All servo Objects use a default refresh rate of 35 Control Pulses Per Second.  This refresh rate can be doubled to 70 Control Pulses Per Second to provide a higher torque output from the servos.  Up to 12 servos positioned at full swing swing can be controlled at the same time while maintaining a 35 Pulses Per Second refresh rate and up to 6 servos positioned at full swing can be controlled at the same time while maintaining a 70 Pulses Per Second refresh rate. 

Operation:
 

An oServoX Object positions a RC servo motor connected to the I/O Line specified by the IOLine property to a position specified by the Value, Center, Offset and InvertOut properties by outputting a PWM servo control pulse. 

The IOLine property specifies which one of the OOPic's 31 digital I/O Lines is to be used. 
NOTE: The IOLine property MUST be set before the Operate property is set to 1. demonstration

When all 4 of the positioning values are set to 0, the servo will move to the middle position.  As the Value property increases, the servo will move to one direction.  And as the servo decreases, the servo will move to the other direction.  The Value property is a full 8-bit URCP Heading value, but since the servo can only rotate 180 degrees, one half of the range is not used.

When the Operate property is set to 1, the oServo Object will continuously output a PWM servo control pulse to the I/O Line specified by the IOLine  property. This results in the RC Servo holding at the position specified by the Value property. When the Operate property is cleared to 0, the oServo Object sets the specified I/O line to 0 volts.

The Center property is used to adjust the mechanical center of the servo.

The InvertOut property causes the servo to move in the opposite direction.

The Offset indicates which one-half section of the URCP Heading value to use and the Mode property specifies how the servo responds to values on the other half of the URCP Heading.

The refresh rate defaults to 35 Pulses Per Second and can be set to a high torque setting of 70 Pulses Per Second.  More information on the refresh rate can be found in the description of the oServo Object

Storage size & Availability:
 

The following table lists the size and availability of the oServoX Object:

ObjectSizeVersion
oServoX 6 Bytes B.1.0
Properties:
 

The following table lists the Properties of the oServoX Object:

Property Description
Address

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

Data-Type: Address, Read-Only

Data-Range: 0 - 127

Center

Adjusts the value for the servo's mechanical center

Data-Type: Byte

Data-Range: -32 to +31

InvertOut

A value that specifies if the output pulse is reversed.

Data-Type: Bit, Flag

Data-Range: 0 - 1

IOLine

A value that specifies the physical I/O Line to use.

Data-Type: Byte

Data-Range: 0 - 31

Mode

A value that specifies how the servo responds to values outside of it's mechanical limit.

Data-Type: Nibble

Data-Range: 0 - 3

ModeDescription
0 The servo splits the inaccessible area into 2 parts and will position itself to the side closest to the value property.
1 The servo will position itself on the low value side.
2 The servo will position itself on the high value side.
3 The servo will shut off.
Offset

A value that specifies where to place the servo's mechanical capability within the Value properties range.

The Value property is capable of specifying one of 256 possible Brad positions (360 degrees).  A typical RC servo has a mechanical limit of 128 Brads (180 degrees).  The offset property specifies which Brad the servo is to consider the center of its movement.

Data-Type: Byte

Data-Range: -128 to +127

OffsetThe servo will be at
Center when the 
Value property is:
The servo will be 
positioned for values:
Any At the Offset value Offset-64 to Offset+63
Examples
 0  0 -64 to +63
 64  64 0 to +127
-64 -64 -128 to -1
Operate

A value that specifies whether or not the pulse is outputted.

Data-Type: Bit, Flag

Data-Range: 0 - 1

OutofRange

A value that specifies when the Value property is outside of the mechanical capability of the servo.

Data-Type: Bit, Flag

Data-Range: 0 - 1

String

The Value property represented as a string.

Data-Type: String

Data-Range: 0 - 127

Value

The value specifying the position of the servo-motor.

Data-Type: Byte, Default

Data-Range: -128 to +127

Example:
In the following example, a Servo is moved back and forth.
'This program moves a servo to the 
'center, then left of center, then
'back to center then right of center.

Dim S As New oServoX

Sub Main()
  S.IOLine = 1
  S.Operate =cvTrue
  Do
   S = 0:   OOPic.delay = 150
   S = 31:  OOPic.delay = 150
   S = 0:   OOPic.delay = 150
   S = -31: OOPic.delay = 150
  Loop
End Sub
Connections:
A RC Servo requires only one I/O Line connection to the OOPic.  It is absolutely necessary that the servo be driven by a different power source than the one that the OOPic is using AND that the ground of each power supply be connected together.
See Also:
oServo - Another Object that drives a servo that is less sophisticated and uses less memory.
oServoSP - An Object that uses URCP Speed values to control a modified RC Servo.
oServoSE
- An Object that controls a Scott Edwards mini ssc II servo controller module.
OOPic.SrvRefresh - A property that selects a 70 Pulses Per Second refresh rate for all servos.