Class MMXMotor

  • All Implemented Interfaces:
    BaseMotor, DCMotor, Encoder, EncoderMotor
    Direct Known Subclasses:
    MMXRegulatedMotor

    public class MMXMotor
    extends java.lang.Object
    implements EncoderMotor
    Abstraction to drive a basic encoder motor with the NXTMMX motor multiplexer. The NXTMMX motor multiplexer device allows you to connect two additional motors to your robot using a sensor port. Multiple NXTMMXs can be chained together.

    Use the NXTMMX.getBasicMotor() factory method to retrieve an instance of this class.

    Author:
    Kirk P. Thompson
    See Also:
    NXTMMX, MMXRegulatedMotor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void backward()
      Causes motor to rotate backwards until stop() or flt() is called.
      void flt()
      Motor loses all power, causing the rotor to float freely to a stop.
      void forward()
      Causes motor to rotate forward until stop() or flt() is called.
      int getPower()
      Returns the current motor power setting.
      int getTachoCount()
      Returns the tachometer count.
      boolean isMoving()
      Return true if the motor is moving.
      void resetTachoCount()
      Reset the the tachometer count.
      void setPower​(int power)
      Set the power level 0%-100% to be applied to the motor
      void setRamping​(boolean doRamping)
      Sets speed ramping is enabled/disabled for this motor.
      void setRegulate​(boolean regulate)
      Disable or Enable internal motor controller speed regulation.
      void stop()
      Causes motor to stop immediately.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setPower

        public void setPower​(int power)
        Description copied from interface: DCMotor
        Set the power level 0%-100% to be applied to the motor
        Specified by:
        setPower in interface DCMotor
        Parameters:
        power - new motor power 0-100
      • setRamping

        public void setRamping​(boolean doRamping)
        Sets speed ramping is enabled/disabled for this motor. Default at instantiation is ramping enabled.
        Parameters:
        doRamping - true to enable, false to disable
      • getPower

        public int getPower()
        Description copied from interface: DCMotor
        Returns the current motor power setting.
        Specified by:
        getPower in interface DCMotor
        Returns:
        current power 0-100
      • forward

        public void forward()
        Description copied from interface: BaseMotor
        Causes motor to rotate forward until stop() or flt() is called.
        Specified by:
        forward in interface BaseMotor
      • backward

        public void backward()
        Description copied from interface: BaseMotor
        Causes motor to rotate backwards until stop() or flt() is called.
        Specified by:
        backward in interface BaseMotor
      • stop

        public void stop()
        Description copied from interface: BaseMotor
        Causes motor to stop immediately. It will resist any further motion. Cancels any rotate() orders in progress.
        Specified by:
        stop in interface BaseMotor
      • flt

        public void flt()
        Description copied from interface: BaseMotor
        Motor loses all power, causing the rotor to float freely to a stop. This is not the same as stopping, which locks the rotor.
        Specified by:
        flt in interface BaseMotor
      • isMoving

        public boolean isMoving()
        Return true if the motor is moving. Note that this method reports based on the current control state (i.e. commanded to move) and not if the motor is actually moving. This means a motor may be stalled but this method would return true.
        Specified by:
        isMoving in interface BaseMotor
        Returns:
        true if the motor is executing a movement command, false if stopped.
      • getTachoCount

        public int getTachoCount()
        Description copied from interface: Encoder
        Returns the tachometer count.
        Specified by:
        getTachoCount in interface Encoder
        Returns:
        tachometer count in degrees
      • resetTachoCount

        public void resetTachoCount()
        Reset the the tachometer count. TODO verify => Calling this method will stop any current motor action. This is imposed by the HiTechic Motor Controller firmware.
        Specified by:
        resetTachoCount in interface Encoder
      • setRegulate

        public void setRegulate​(boolean regulate)
        Disable or Enable internal motor controller speed regulation. Setting this to true will cause the motor controller firmware to adjust the motor power to compensate for changing loads in order to maintain a constant motor speed. Default at instantiation is false.
        Parameters:
        regulate - true to enable regulation, true otherwise.