Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.phidgets
Class ServoPhidget

    java.lang.Object
      com.phidgets.Phidget
          com.phidgets.ServoPhidget

    public final class ServoPhidget

extends Phidget

This class represents a Phidget servo Controller. All methods to control a Servo Controller are implemented in this class.

The Phidget Sevo controller simply outputs varying widths of PWM, which is what most servo motors take as an input driving signal.

Constructor Summary
`ServoPhidget()`

Method Summary
`void` | `addServoPositionChangeListener(ServoPositionChangeListener l)` Adds a servo position change listener.
`int` | `getMotorCount()` Returns the number of motors this Phidget can support.
`double` | `getPosition(int index)` Returns the position of a servo motor.
`void` | `removeServoPositionChangeListener(ServoPositionChangeListener l)`
`void` | `setPosition(int index, double position)` Sets the position of a servo motor.

Methods inherited from class com.phidgets.Phidget
`addAttachListener, addDetachListener, addErrorListener, close, equals, getDeviceName, getDeviceType, getDeviceVersion, getLibraryVersion, getSerialNumber, getTag, isAttached, open, openAny, removeAttachListener, removeDetachListener, removeErrorListener, setTag, toString, waitForAttachment`

Methods inherited from class java.lang.Object
`getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### ServoPhidget

    public ServoPhidget()
                 throws PhidgetException

Throws:
  `PhidgetException`

Method Detail

### getMotorCount

    public int getMotorCount()
                      throws PhidgetException

  Returns the number of motors this Phidget can support. Note that there is no way of programatically determining how many motors are actaully attached to the board.

  Returns:
    number of motors
  Throws:
    `PhidgetException`

### getPosition

    public double getPosition(int index)
                       throws PhidgetException

  Returns the position of a servo motor. Note that since servo motors do not offer any feedback in their interface, this value is simply whatever the servo was last set to. There is no way of determining the position of a servo that has been plugged in, until it's position has been set. Therefore, if an initial position is important, it should be set as part of initialization.

  The range here is -23 - 232, each corsponding aproximately to an angle in degrees. -23 corresponds to a PWM of 0, which means that the motor is not being driven at all, and so can be freely rotated. Note that most servos will not be able to operate accross this entire range.

  Parameters:
    `index` - index of the motor
  Returns:
    current position of the selected motor
  Throws:
    `PhidgetException` - If this Phidget is not opened and attached, or if the index is out of range. See `open` for information on determining if a device is attached.

### setPosition

    public void setPosition(int index,
                            double position)
                     throws PhidgetException

  Sets the position of a servo motor.

  The range here is -23 - 232, each corsponding aproximately to an angle in degrees. -23 corresponds to a PWM of 0, which means that the motor is not being driven at all, and so can be freely rotated. Note that most servos will not be able to operate accross this entire range. Typically, the range might be 25 - 180 degrees, but this depends on the servo

  Parameters:
    `index` - index of the motor
    `position` - desired position
  Throws:
    `PhidgetException` - If this Phidget is not opened and attached, or if the index or position is out of range. See `open` for information on determining if a device is attached.

### addServoPositionChangeListener

    public final void addServoPositionChangeListener(ServoPositionChangeListener l)

  Adds a servo position change listener. The servo position change handler is a method that will be called when the servo position has changed. The event will get fired after every call to `setPosition`.

  There is no limit on the number of servo position change handlers that can be registered for a particular Phidget.

  Parameters:
    `l` - An implemetation of the `ServoPositionChangeListener` interface

### removeServoPositionChangeListener

    public final void removeServoPositionChangeListener(ServoPositionChangeListener l)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD