Package lejos.hardware.device
Class MMXMotor
- java.lang.Object
-
- lejos.hardware.device.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 voidbackward()Causes motor to rotate backwards untilstop()orflt()is called.voidflt()Motor loses all power, causing the rotor to float freely to a stop.voidforward()Causes motor to rotate forward untilstop()orflt()is called.intgetPower()Returns the current motor power setting.intgetTachoCount()Returns the tachometer count.booleanisMoving()Returntrueif the motor is moving.voidresetTachoCount()Reset the the tachometer count.voidsetPower(int power)Set the power level 0%-100% to be applied to the motorvoidsetRamping(boolean doRamping)Sets speed ramping is enabled/disabled for this motor.voidsetRegulate(boolean regulate)Disable or Enable internal motor controller speed regulation.voidstop()Causes motor to stop immediately.
-
-
-
Method Detail
-
setPower
public void setPower(int power)
Description copied from interface:DCMotorSet the power level 0%-100% to be applied to the motor
-
setRamping
public void setRamping(boolean doRamping)
Sets speed ramping is enabled/disabled for this motor. Default at instantiation is ramping enabled.- Parameters:
doRamping-trueto enable,falseto disable
-
getPower
public int getPower()
Description copied from interface:DCMotorReturns the current motor power setting.
-
forward
public void forward()
Description copied from interface:BaseMotorCauses motor to rotate forward untilstop()orflt()is called.
-
backward
public void backward()
Description copied from interface:BaseMotorCauses motor to rotate backwards untilstop()orflt()is called.
-
stop
public void stop()
Description copied from interface:BaseMotorCauses motor to stop immediately. It will resist any further motion. Cancels any rotate() orders in progress.
-
flt
public void flt()
Description copied from interface:BaseMotorMotor loses all power, causing the rotor to float freely to a stop. This is not the same as stopping, which locks the rotor.
-
isMoving
public boolean isMoving()
Returntrueif 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 returntrue.
-
getTachoCount
public int getTachoCount()
Description copied from interface:EncoderReturns the tachometer count.- Specified by:
getTachoCountin interfaceEncoder- 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:
resetTachoCountin interfaceEncoder
-
setRegulate
public void setRegulate(boolean regulate)
Disable or Enable internal motor controller speed regulation. Setting this totruewill 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 isfalse.- Parameters:
regulate-trueto enable regulation,trueotherwise.
-
-