oServoSP Object

Back to top of page Description:
 

An oServoSP Object is a Hardware Object that controls the direction and speed of a RC servo-motor that has been modified for continuous rotation.  It is capable of driving the Motor at multiple speeds, in forward or reverse plus free spinning.

The primary function of the oServoSP Object is to allow a stepper motor to be used with the URCP Speed values. 

The oServoSP Object uses a single digital I/O lines to communicate with the RC Servo which handles the voltage and current requirements of the Motor it contains.

How fast the servo motor turns and in which direction it turns is controlled by a single value with a range of  -128 to +127.  When this value is 0, the motor is at free-spinning rest (although turning it will require overcoming the gearing).  When the value is a positive number from 1 to 127, the motor turns forward at the speed indicated by the value.  The higher the value, the faster the motor turns.  When the value is a negative number from -1 to -128, the motor turns backwards at the speed indicated by the value.  The lower the number, the faster the motor turns in reverse.

The physical direction that the motor will turn can be configured to:  forward turns clockwise and reverse turns counter-clockwise  or  forward turns counter-clockwise and reverse turns clockwise.

 The following table lists the size and availability of the oServoSP Object.
 ObjectSizeDescriptionA1A2B1B2C1
oServoSP6 BytesControls an RC Servo modified for continuous rotation.xx
oServoSP26 BytesControls an RC Servo modified for continuous rotation.xx
Back to top of page Operation:
 

The oServoSP and oServoSP2 Objects rotate a modified RC servo motor connected to the I/O Line specified by the IOLine property at a speed specified by the Speed and Invert properties.  This object is fairly identical to oServoX with the exception that a Speed of 0 causes the servo to go into a dormant state.  This is useful when using a hobby servo as a drive motor on a robot, there is no "drift" if you don't have the center set perfectly. The oServoSP2 is additionally different in that is uses a radically different control system than the oServoSP does.

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.

When the Speed property is set to 0, the control signals that cause the servo to rotate are suppressed which results in the servo being at rest.  As the Speed property increases, the control signals are adjusted so that the servo will turn forward increasing in speed as the value approaches 127.  And as the Speed property decreases, the control signals are adjusted so that the servo will turn in reverse increasing in speed as the value approaches -128.

When the Operate property is set to 1, the control signals are continuously output to the I/O Line specified by the IOLine  property. This results in the modified RC servo rotating at the specified rate. When the Operate property is cleared to 0, the control signals are suppressed.  This results in the modified RC servo rotating freely.

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

The oServoSP2 Object uses a different control signal.  Normally the servo control signal is composed of pulses that are sent to the servo at regular intervals and a change in the duration of each pulse controls the servo.  The oServoSP2 differs in that the pulse duration stays the same, but the intervals change to control the servo.  (See the oPWMS Help for more detail on how the control signals for servos work.)

When created, the oServoSP and oServoSP2 Objects also create an instance of the oPWMS object which is used 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 page Properties:

The following table lists the properties of the oServoSP Object:

Property

Description

Speed
A value that specifies the speed of the modified servo-motor
Object Class: oPower Value Range: -128 to 127
Data Type: Numeric Default Value: 0
When operating, a 0 in the Speed property will cause the motor to be at a full stop. When the Speed property is greater than 0, the motor will go forward at a speed specified by the magnitude of the Speed property. The higher the number (up to 127), the faster the motor will turn. If the Speed property is less than 0, then the motor to go backwards at a speed specified by the magnitude of the Speed property. The lower the number (down to negative 128), the faster the motor will turn in reverse.
SpeedDescription
-128Full Reverse
-96 
-64Half Reverse
-32 
0Stopped
32 
64Half Forward
96 
127Full Forward
The Speed property is an oPower object which has properties and methods such as SetFullForward and Stop that can also be used to control the speed of the motor.  Examples: 

 

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 specifies where the servo's mechanical center is.
Object Class: oAdjust127 Value Range: 0 - 127
Data Type: Numeric Default Value: 0
Invert
A value that selects if the physical direction the servo turns is inverted.
Object Class: oSelect0to1L Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Operate
A value that specifies whether or not the modified servo-motor is turning.
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 page Examples:
In the following example, the oServoSP Object is used.
'This program moves a servo.
Dim S As New oServoSP

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
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.

More diagrams can be found on the help page for oServo

Back to top of page Related Items:

 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
oServoControls an RC Servo-motor.xxxxx
oServoSEControls a Scott Edwards Serial Servo controller.xxx
oServoXControls an RC Servo-motor with a signed value.xxx
Back to top of page Version History and Bug List:
 Firmware Ver B2: Introduced.

Bugs: Compiler version 5.0.1 did not allow the property Refresh in this object. Fixed in Ver 6.0 by allowing access to the oPWMS object.


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