oServo Object

Main Index
Object List
Back to top of pageDescription:
 A Hardware Object that uses one digital I/O line to set the position of an RC servomotor

The oServo 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 0 to 63 and once the servo has reached the specified position, it is held in place until the specified position changes or the oServo Object is turned off.

The oServo object can control the servo in low-torque mode or high torque mode.  Up to 20 servos can be controlled in either mode as long as they are not all at full swing.  Up to 20 servos positioned at full swing swing can be controlled at low-torque and up to 6 servos positioned at full swing can be controlled at high torque. 

The maximum number of oServo Objects that can be dimensioned in a single application program is 20 , limited only by the amount of Object RAM.

 The following table lists the size and availability of the oServo Object.
 ObjectSizeDescriptionA1A2B1B2C1
oServo4 BytesControls an RC Servo-motor.xxxxx
Back to top of pageOperation:
 

An oServo Object positions a RC Servo motor connected to the I/O Line specified by the IOLine property to a position specified by the Position, Adjust and Invert properties.

An Operate property specifies if the servo is active or not.  When set to 1 the oServo Object is active and will continuously output a control signal to the servo which results in the RC Servo turning to and holding at the specified position. When the Operate property is cleared to 0 the oServo Object is inactive and the specified I/O line is set to 0 volts which releases the servo.

It is possible to control all 20 possible oServoX servos at the same time.  But doing so will degrade the torque.   At best case, 13 servos can be controlled at the same time with a low torque setting and 6 oServoX servos at the same time while maintain the high torque setting.  Note that only the servos with their Operate property set to 1 will be counted as controlled.

The IOLine property specifies which one of the ooPIC's 31 digital I/O Lines is to be used. When set to 0, the control signal is not outputted.  When the IOLine property is > 0 and the Operate property is 1, the oServo Object will output the control signal.

The Position property is used to specify the relative position of the servo.  Its range is 0 to 63 which provides 64 steps over a 180 degree turning range. This works out to 2.8 degrees per step.  Internally, the Position property is adjusted by the Adjust, and Invert properties which are used to adjust the actual mechanical positioning.  Note that the Adjust, and Invert properties only need to be set once and that after they are set, the Position property is the only property used to position the servo.

It is important to keep in mind that different servos have different mechanical capabilities. Some servos can rotate more than 180 degrees, some less than 180 degrees. A servo manufacturer typically publishes that their servos are only able to rotate 90 degrees with some areas for adjustment. This area for adjustment is usually another 90 degrees or so, giving the servo a full swing capability of 180 degrees.  The oServo object can take advantage of the full rotational capability of the servo, whatever it may be.

The Adjust property adjusts the servo's position by offsetting the Position property. (see history) It must be adjusted for the mechanical differences of each different servo motor connected to the ooPIC. Its range is 0 to 63 which provides an additional 180 degree adjustment to the Position property. The default is 22 and it is also 2.8 degrees per step.

By adjusting the Adjust property, The 0-63 range of the Position property can be centered over the 180 degree range of the mechanical capability of the servo. Every servo is different.  Even with the same manufacturer and model of servo, the mechanical capability may translate to a different area of the servo, so it is important to make this adjustment for each servo in use.

The Invert property is used to reverse the direction that the servo will rotate in response to the Value and Adjust properties.

The Invert property is useful when two servos need to rotate in opposite directions when given the same position value. Such applications include Hexapod Walkers, or modified servos driving the wheels on a robotic base. When doing this, one servo's Invert property needs to be set to 0 and the second servo's Invert Property needs to be set to 1.

Note: If a servo's Adjust property has already been adjusted and then the Invert property is changed, the Adjust property will need to be recalculated for the other side of the servo's mechanical capabilities.

The Torque property controls how strong the servo's turning power is.  (see history)  Setting the Torque property to 1 (high-torque) will double the servo's turning power. Note that when the torque is set to high, the servo will draw twice the current from the battery.  Note that the torque property will be overridden when using several servos.  (see the oPWMS object for details.)

When created, the oServo Object also creates an instance of the oPWMS object which it uses to generate and output the signal that controls the servo.  Modifying any of the properties of the oPWMS instance will affect the oServo Object's operation.  See the oPWMS Help for more detail on how servos are controlled.

Back to top of pageProperties:
 

The following table lists the properties of the oServo Object:

Property

Description

Position
A value that specifies the position of the servo-motor
Object Class: oByte Value Range: 0 - 127
Data Type: Numeric Default Value: 0
IOLine
A value that specifies which I/O Line is used to control the Servo.
Object Class: oIOLine Value Range: 0 - 31
Data Type: Numeric Default Value: 0
Some I/O Lines have special purposes.  Be sure to see oIOLine help file for details.
Adjust
A value that adjusts where the servo's mechanical center is.
Object Class: oAdjust63 Value Range: 0 - 63
Data Type: Numeric Default Value: 22
Added in firmware Ver A.2
Invert
A value that specifies if the servo's physical position is inverted.
Object Class: oSelect0to1L Value Range: 0 - 1
Data Type: Numeric Default Value: 0
InvertConstantDescription
0cvFalse

The Servo positioning is normal

1cvTrue

The Servo positioning is reversed.

Torque
A value that specifies the servo's torque.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Availability: This property was added if firmware version B.2.
OperateConstantDescription
0cvFalse

The Servo is normal..

1cvTrue

The Servo's turning torque is doubled.

Operate
A value that specifies if the servo is on or off.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe servo is off.
1cvOnThe servo is on.
PWM
The I/O function object used to control the servo.
Object Class: oPWMS Value Range: 0 - 63
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, a Servo is moved back and forth.
'The servo connects to IOLine 31
'The servo continuously move to 0% then 180%.

Dim S1 As New oServo

Sub main()
  S1.IOLine = 31
  S1.Adjust = 28
  S1.Operate =cvTrue
  Do
     S1 = 0
     ooPIC.Delay = 1500
     S1 = 63
     ooPIC.Delay = 1500
  Loop
End Sub
Back to top of pageConnections:
 
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.

The IOLine property is used to specify which one of the ooPIC's 31 I/O lines will be used to connect to the control line of the servo. Any I/O lines can be used, but you may want to keep in mind that other Objects, such as the oA2D Object, can only use certain I/O lines. If you are planning to use these other Objects, you may need to avoid using those I/O lines.

RC servos normally have 3 wires: Power, Ground and Control. The Control wire is used to specify were the servo is positioned and is connected to the I/O lines specified by the IOLine property. This control wire is usually yellow or white, but can be any color other than red or black.

The I/O lines can be connected directly to the servo. However, if you are powering your servo with a power supply of less than +5 Volts, you will need to put a 1k resistor between the I/O line and the servo's control line.

Servos can be powered by a wide range of voltages between 4.8 and 6 volts. Be sure to consult the manufacturer's specifications before applying power. Also, be sure not to power the servo from the same power supply as the ooPIC. A servo will pull large amounts of power in quick surges causing the servo's power supply to periodically drop below 4.5 volts. The ooPIC has a brown out circuit that resets the ooPIC if its power supply goes under 4.5 volts. Using separate power supplies will prevent the ooPIC from resetting when driving a servo.

Multiple servos can be connected to the ooPIC by connecting each servo's control line to a different I/O line on the ooPIC.  Each of the servos can be driven from the same power source. When driving more than 1 servo, the control signal gets distributed evenly between the servos. As a result, the power surge that occurs when a servo gets refreshed will never be coming from more than one servo at the same time.

Back to top of pageRelated Items:

 The following table lists objects that use the oServo Object.
 ObjectDescriptionA1A2B1B2C1
oSrvSyncAn Object that sequences up to 16 servosxxxx
 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oRCIN(1-6)An Object that reads a Radio Receiver with up to 6 channels.x
oServoSEControls a Scott Edwards Serial Servo controller.xxx
oServoSPControls an RC Servo modified for continuous rotation.xx
oServoXControls an RC Servo-motor with a signed value.xxx
Back to top of pageVersion History and Bug List:
 Firmware Ver A1: Introduced.
Firmware Ver A2: Adjust property added.
Firmware Ver B2: Torque property added.

Bugs: No known bugs.


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