cork.device.control
Class ContinuousRotationServo

java.lang.Object
  |
  +--cork.device.control.ContinuousRotationServo
All Implemented Interfaces:
Device, Motor, java.lang.Runnable

public class ContinuousRotationServo
extends java.lang.Object
implements java.lang.Runnable, Motor

Driver for Continuous Rotation Servos. Servos of this type have been modified so that they can rotate in a 360 degree circle continuously. They are often used in robotics for drive motors on small robots.

Version:
0.1.0
Author:
Brill Pappin

Field Summary
static int PULSE_INTERVAL
          Description of the Field
 
Fields inherited from interface cork.device.Motor
DIRECTION_FORWARD, DIRECTION_REVERSE
 
Constructor Summary
ContinuousRotationServo(com.ajile.drivers.gpio.GpioPin pin)
          Constructor for the ContinuousRotationServo object
 
Method Summary
 void destroy()
          Destroyes this object.
 java.lang.String getDeviceDestription()
          Gets the destription attribute of the Device object
 java.lang.String getDeviceName()
          Gets the title attribute of the Device object
 int getDirection()
          Get the direction the servo will rotate in.
 int getSpeed()
          Speed has no meaning in this context.
 void run()
          Main processing method for the ContinuousRotationServo object
 void setDirection(int direction)
          Sets the direction the servo will rotate in.
 void setSpeed(int speed)
          Speed has no meaning in this context.
 void start()
          Starts the servo rotating.
 void stop()
          Stops the servo rotating.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PULSE_INTERVAL

public static final int PULSE_INTERVAL
Description of the Field
Since:
0.1.0
Constructor Detail

ContinuousRotationServo

public ContinuousRotationServo(com.ajile.drivers.gpio.GpioPin pin)
Constructor for the ContinuousRotationServo object
Parameters:
pin - com.ajile.drivers.gpio.GpioPin the pin the servos control line is attached to (usually the white or orange wire).
Since:
0.1.0
Method Detail

destroy

public void destroy()
Destroyes this object. call this method if you want to remove this objects resources from the system, but are not shutting down the processor. If you are exiting teh processor, there is no need to call this method.
Since:
0.1.0

run

public void run()
Main processing method for the ContinuousRotationServo object
Specified by:
run in interface java.lang.Runnable
Since:
0.1.0

start

public void start()
Starts the servo rotating. The direction that the servo rotates depends on the properties of the object.
Specified by:
start in interface Motor
Since:
0.1.0

stop

public void stop()
Stops the servo rotating. The servo will still be viable after this call, and a call to start() will start the servo running again.
Specified by:
stop in interface Motor
Since:
0.1.0

getDirection

public int getDirection()
Get the direction the servo will rotate in. See: setDirection(int) for more info.
Specified by:
getDirection in interface Motor
Returns:
int the direction of rotation.
Since:
0.1.0

getDeviceName

public java.lang.String getDeviceName()
Gets the title attribute of the Device object
Specified by:
getDeviceName in interface Device
Returns:
The title value
Since:
0.1.0

getDeviceDestription

public java.lang.String getDeviceDestription()
Gets the destription attribute of the Device object
Specified by:
getDeviceDestription in interface Device
Returns:
The destription value
Since:
0.1.0

getSpeed

public int getSpeed()
Speed has no meaning in this context. This method does nothing.
Specified by:
getSpeed in interface Motor
Returns:
int The speed value
Since:
0.1.0

setDirection

public void setDirection(int direction)
Sets the direction the servo will rotate in.

Because the servo can be oriented in any way, it is impossible for this code to know ahead of time which direction is "forward" and which is "backward" the concepts do not apply at this level of abstraction.

For those who understand how servos work, setting a value of "forward" sends the control a long pulse, wehre setting the value to "reverse" sends a short pulse. Because we're dealing with a Continuous Rotation Servo we don't really care how long the long and short pulses are, we only care that they are above and below the center pulse length.

If you don't understand how servos work, look them up. Any search engine will give you data on them, and you can also find descriptions of how to modify a normal servo for continuous rotation.

Specified by:
setDirection in interface Motor
Parameters:
direction - int one of the direction constants from the Motor interface.
Since:
0.1.0

setSpeed

public void setSpeed(int speed)
Speed has no meaning in this context. This method does nothing.
Specified by:
setSpeed in interface Motor
Parameters:
speed - int The new speed value
Since:
0.1.0