lejos.nxt.addon
Class NXTMMXMotor

java.lang.Object
  extended by lejos.nxt.addon.NXTMMXMotor

public class NXTMMXMotor
extends java.lang.Object

Supports Mindsensors NXTMMX. this device allows you to connect two additional motors to your robot. Multiple NXTMMXs can be chained together.

Author:
Michael D. Smith mdsmitty@gmail.com

Constructor Summary
NXTMMXMotor(NXTMMX mux, int motor)
          Constructor, you don't have to worry about this its called two times by the constructor in the NXTMMX class to create each motor instance.
 
Method Summary
 void backward()
          Causes motor to rotate backwards.
 void flt()
          Causes motor to float.
 void forward()
          Causes motor to rotate forward.
 int getLimitAngle()
          Return the angle that a Motor is rotating to.
 int getMode()
          Returns the mode
 int getRotationSpeed()
          same as get speed I need to work on this still
 int getSpeed()
          return the set speed of the motor.
 int getTachoCount()
          Returns the tachometer count.
 boolean isMoving()
          Returns true if the motor is in motion.
 boolean isOverloaded()
          Determines if the motor stalled due to over load.
 boolean isRamping()
          Determines if the motor is ramping up or down.
 boolean isRegulating()
          Determine whether speed control is on or not
 boolean isSmoothAcceleration()
          Determines if speed ramping is enabled
 boolean isStalled()
          Determines if the motor is stalled or not
 boolean isTaskRunning()
          Determines if the motor is running a task.
 void lock()
          Locks the motor in current position.
 void regulateSpeed(boolean controlSpeed)
          turns speed regulation on and off for tacho and time methods.
 void resetTachoCount()
          Resets the tachometer count to zero.
 void rotate(int deg)
          Causes motor to rotate by a specified angle.
 void rotate(int deg, boolean immediateReturn)
          same as rotate but returns immediately
 void rotateTime(int time, boolean direction)
          Rotates the motor for specified amount of time
 void rotateTime(int time, boolean direction, boolean immediateReturn)
          runs motor for specified amount of time and immediately returns
 void rotateTo(int deg)
          rotates to the tacho position indicated.
 void rotateTo(int deg, boolean immediateReturn)
          rotates to the tacho position that you want and immediately returns.
 void setSpeed(int speed)
          sets motor speed.
 void setTachoBreak(boolean tachoBreak)
          when this bit is set after tacho methods the motor will break.
 void setTachoLock(boolean tachoLock)
          when using this bit after tacho methods force feed back will be used to hold the motor in place.
 void smoothAcceleration(boolean rampUp)
          enables and disables speed ramping
 void stop()
          stops the motor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NXTMMXMotor

public NXTMMXMotor(NXTMMX mux,
                   int motor)
Constructor, you don't have to worry about this its called two times by the constructor in the NXTMMX class to create each motor instance.

Parameters:
mux - the motor multiplexor
motor - the index of the motor
Method Detail

backward

public void backward()
Causes motor to rotate backwards.


flt

public void flt()
Causes motor to float.


forward

public void forward()
Causes motor to rotate forward. TODO


getLimitAngle

public int getLimitAngle()
Return the angle that a Motor is rotating to.

Returns:
the limit angle

getMode

public int getMode()
Returns the mode

Returns:
the mode : 1 = forward, 2= backward, 3 = stop, 4 = float

isRegulating

public boolean isRegulating()
Determine whether speed control is on or not

Returns:
true if speed control is on, else false

isMoving

public boolean isMoving()
Returns true if the motor is in motion.

Returns:
true if the motor is currently in motion, else false

isStalled

public boolean isStalled()
Determines if the motor is stalled or not

Returns:
true if stalled, else false

isOverloaded

public boolean isOverloaded()
Determines if the motor stalled due to over load.

Returns:
true if overload, else false

isTaskRunning

public boolean isTaskRunning()
Determines if the motor is running a task. this does not mean the motor is moving.

Returns:
true if the motor is running a task, else false

stop

public void stop()
stops the motor


getTachoCount

public int getTachoCount()
Returns the tachometer count.

Returns:
tachometer count in degrees

resetTachoCount

public void resetTachoCount()
Resets the tachometer count to zero.


getRotationSpeed

public int getRotationSpeed()
same as get speed I need to work on this still


getSpeed

public int getSpeed()
return the set speed of the motor.

Returns:
0 - 100 has nothing to do with rpm or rps

regulateSpeed

public void regulateSpeed(boolean controlSpeed)
turns speed regulation on and off for tacho and time methods. forwards and backwards are not affected because if its off they just wont work.


rotate

public void rotate(int deg)
Causes motor to rotate by a specified angle. The resulting tachometer count should be within +- 2 degrees on the NXT. This method does not return until the rotation is completed.

Parameters:
deg - - by which the motor will rotate.

rotate

public void rotate(int deg,
                   boolean immediateReturn)
same as rotate but returns immediately

Parameters:
deg - - number of deg to rotate.
immediateReturn - - does not matter if true or false it will return after mux is programmed.

rotateTo

public void rotateTo(int deg)
rotates to the tacho position indicated.

Parameters:
deg - - the tacho position that you want.

rotateTo

public void rotateTo(int deg,
                     boolean immediateReturn)
rotates to the tacho position that you want and immediately returns.


rotateTime

public void rotateTime(int time,
                       boolean direction)
Rotates the motor for specified amount of time

Parameters:
time - 1 - 255 sec
direction - true is forward false is backward.

rotateTime

public void rotateTime(int time,
                       boolean direction,
                       boolean immediateReturn)
runs motor for specified amount of time and immediately returns

Parameters:
time - = 1 - 255 sec
direction - true is forward false is backward.
immediateReturn - - does not matter if true or false

setSpeed

public void setSpeed(int speed)
sets motor speed. this has nothing to do with rpm or rps its just a percentage speed type of value

Parameters:
speed - 0 - 100

smoothAcceleration

public void smoothAcceleration(boolean rampUp)
enables and disables speed ramping

Parameters:
rampUp - true turns it on false turns it off

isSmoothAcceleration

public boolean isSmoothAcceleration()
Determines if speed ramping is enabled

Returns:
true if smooth acceleration is on, else false

isRamping

public boolean isRamping()
Determines if the motor is ramping up or down. This is different than isSmoothAcceleration() as it returns the current status not what is enabled.

Returns:
if ramping up or down, else false

setTachoLock

public void setTachoLock(boolean tachoLock)
when using this bit after tacho methods force feed back will be used to hold the motor in place. if the motor is moved it will move back to the specified position.

Parameters:
tachoLock - true turns it on

setTachoBreak

public void setTachoBreak(boolean tachoBreak)
when this bit is set after tacho methods the motor will break.

Parameters:
tachoBreak - turns it on.

lock

public void lock()
Locks the motor in current position. Uses active feed back to hold it.