Servo Motor Controller
A standard Radio Control (RC) Servo is a motorized device that moves its actuator to a position specified by a controlling electronic signal. Inside is a complete servo system including motor, gearbox, feedback device (pot), servo control circuitry, and drive circuit. Several sizes of servos exist that range from very fast to very powerful.  These devices were popularized by the Radio Control hobbyist movement and, as a result, are very inexpensive. 
The OOPic's oServo Object is used to control RC Servos. It has 5 properties that are used to control a servo connected to the OOPic.
  • IOLine - Specifies which I/O Line to use.
  • Value - Specifies the position of the servo.
  • Center - Specifies the mechanical center of the servo.
  • InvertOut - Specifies the rotational direction of the servo.
  • Operate - Specifies if the servo is refreshed.

The following program shows a servo connected to I/O line 31 being positioned.

Dim ThingA As New oServo



Sub Main()

  ThingA.IOLine = 31 ' Specify the I/O Line.

  ThingA.Center = 28 ' Specify the center.

  ThingA.Operate = cvTrue ' Turn the servo on.



  ' At this point in the program, anytime 

  ' that the Value property is set, the

  ' servo will move to that position. 



  ThingA.Value = 32 ' Move to position 32.



End Sub 

IOLine Property

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.

Value Property

The Value Property is used to specify the 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.

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 OOPic will take advantage of the full rotational capability of the servo, whatever it may be.

Center Property

The Center property is used to adjust the mechanical starting point of the 0 position. Its range is 0 to 63 which provides an additional 180 degree adjustment to the Value property. It is also 2.8 degrees per step. This value is typically set to a value between 20 and 40 and must be customized for each servo.

By adjusting the Center property, The 0-63 range of the Value 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 you use.

When adjusting the Center Value to find the proper value, first set the Center property to 40 and the Value property to 0. Slowly move the Center property down until the actuator on the servo hits its mechanical stop. Then bring the Center property up by 1.

InvertOut Property

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

The InvertOut 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 InvertOut property needs to be set to 0 and the second servo's InvertOut Property needs to be set to 1.

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

Operate Property

The Operate property specifies whether or not the oServo Object refreshes the position of the servo. If the Operate property is set to 0, then the servo is not sent a refresh signal. If the Operate property is set to 1, then the servo is sent a refresh signal 30 times every second.

The following example shows a servo connected to I/O line 31 being positioned to correspond to the position of a potentiometer connected to I/O line 1.

Dim S As New oServo

Dim P As New oA2D



Sub Main()

  Srv.IOLine = 31 ' Specify the I/O Line.

  Srv.Center = 28 ' Specify the center.

  Srv.Operate = cvTrue ' Turn the servo on.

  Pot.IOLine = 1  ' Specify the I/O Line.

  Pot.Operate = cvTrue ' Turn the A2D on.

  Do

    Srv.Value = Pot.Value / 4' Move servo.

  Loop

End Sub 
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 refresh 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.


    Send mail and comments to: Savage Innovations.