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 MotorControlPhidget

    java.lang.Object
      com.phidgets.Phidget
          com.phidgets.MotorControlPhidget

    public final class MotorControlPhidget

extends Phidget

This class represents a Phidget Motor Controller. All methods to to control a motor controller and read back motor data are implemented in this class.

The Motor Control Phidget is able to control 1 or more DC motors. Both speed and acceleration are controllable. Speed is controlled via PWM. The size of the motors that can be driven depends on the motor controller. See your hardware documentation for more information.

The motor Controller boards also has 0 or more digital inputs.

Constructor Summary
`MotorControlPhidget()`

Method Summary
`void` | `addCurrentChangeListener(CurrentChangeListener l)` Adds a current change listener.
`void` | `addInputChangeListener(InputChangeListener l)` Adds an input change listener.
`void` | `addMotorVelocityChangeListener(MotorVelocityChangeListener l)` Adds a velocity change listener.
`double` | `getAcceleration(int index)` Returns a motor's acceleration.
`int` | `getInputCount()` Returns the number of digital inputs.
`boolean` | `getInputState(int index)` Returns the state of a digital input.
`int` | `getMotorCount()` Returns the number of motors supported by this Phidget.
`double` | `getSpeed(int index)` Returns a motor's speed.
`void` | `removeCurrentChangeListener(CurrentChangeListener l)`
`void` | `removeInputChangeListener(InputChangeListener l)`
`void` | `removeMotorVelocityChangeListener(MotorVelocityChangeListener l)`
`void` | `setAcceleration(int index, double acceleration)` Sets a motor's acceleration.
`void` | `setSpeed(int index, double speed)` Sets a motor's speed.

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

### MotorControlPhidget

    public MotorControlPhidget()
                        throws PhidgetException

Throws:
  `PhidgetException`

Method Detail

### getMotorCount

    public int getMotorCount()
                      throws PhidgetException

  Returns the number of motors supported by this Phidget. This does not neccesarily correspond to the number of motors actually attached to the board.

  Returns:
    number of supported motors
  Throws:
    `PhidgetException` - If this Phidget is not opened and attached. See `open` for information on determining if a device is attached.

### getInputCount

    public int getInputCount()
                      throws PhidgetException

  Returns the number of digital inputs. Not all Motor Controllers have digital inputs.

  Returns:
    number of digital inputs
  Throws:
    `PhidgetException` - If this Phidget is not opened and attached. See `open` for information on determining if a device is attached.

### getInputState

    public boolean getInputState(int index)
                          throws PhidgetException

  Returns the state of a digital input. True means that the input is activated, and False indicated the default state.

  Parameters:
    `index` - index of the input
  Returns:
    state of the input
  Throws:
    `PhidgetException` - If this Phidget is not opened and attached, or if the index is invalid. See `open` for information on determining if a device is attached.

### getAcceleration

    public double getAcceleration(int index)
                           throws PhidgetException

  Returns a motor's acceleration. The valid range is 0-100, and refers to how fast the Motor Controller will change the speed of a motor.

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

### setAcceleration

    public void setAcceleration(int index,
                                double acceleration)
                         throws PhidgetException

  Sets a motor's acceleration. Th valid range is from 0-100. This controls how fast the motor changes speed.

  Parameters:
    `index` - index of the motor
    `acceleration` - requested acceleration for that motor
  Throws:
    `PhidgetException` - If this Phidget is not opened and attached, or if the index or acceleration value are invalid. See `open` for information on determining if a device is attached.

### getSpeed

    public double getSpeed(int index)
                    throws PhidgetException

  Returns a motor's speed. The valid range is -100 - 100, with 0 being stopped.

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

### setSpeed

    public void setSpeed(int index,
                         double speed)
                  throws PhidgetException

  Sets a motor's speed. The valid range is from -100 to 100, with 0 being stopped. -100 and 100 both corespond to full voltage, with the value in between corresponding to different widths of PWM.

  Parameters:
    `index` - index of the motor
    `speed` - requested speed foe the motor
  Throws:
    `PhidgetException` - If this Phidget is not opened and attached, or if the index or speed value are invalid. See `open` for information on determining if a device is attached.

### addMotorVelocityChangeListener

    public final void addMotorVelocityChangeListener(MotorVelocityChangeListener l)

  Adds a velocity change listener. The velocity change handler is a method that will be called when the velocity of a motor changes. These velocity changes are reported back from the Motor Controller and so correspond to actual motor speeds over time.

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

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

### removeMotorVelocityChangeListener

    public final void removeMotorVelocityChangeListener(MotorVelocityChangeListener l)

### addCurrentChangeListener

    public final void addCurrentChangeListener(CurrentChangeListener l)

  Adds a current change listener. The current change handler is a method that will be called when the current consumed by a motor changes. Note that this event is not supported with the current motor controller, but will be supported in the future

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

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

### removeCurrentChangeListener

    public final void removeCurrentChangeListener(CurrentChangeListener l)

### addInputChangeListener

    public final void addInputChangeListener(InputChangeListener l)

  Adds an input change listener. The input change handler is a method that will be called when an input on this Motor Controller board has changed.

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

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

### removeInputChangeListener

    public final void removeInputChangeListener(InputChangeListener l)

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