pt.citar.diablu.nxt.protocol
Class NXTCommandSetOutputState

java.lang.Object
  extended by pt.citar.diablu.nxt.protocol.NXTCommand
      extended by pt.citar.diablu.nxt.protocol.NXTCommandSetOutputState

public class NXTCommandSetOutputState
extends NXTCommand

This command allows you to set the output state, i.e., to control the NXT motors.

Author:
Jorge Cardoso

Field Summary
static byte MODE_BRAKE
          The brake mode (bit field - can be combined with other modes).
static byte MODE_MOTOR_ON
          The motor on mode (bit field - can be combined with other modes).
static byte MODE_REGULATED
          The regulated mode (bit field - can be combined with other modes).
static byte REGULATION_MODE_IDLE
          The idle regulation mode mode.
static byte REGULATION_MODE_MOTOR_SPEED
          The motor speed regulation mode mode.
static byte REGULATION_MODE_MOTOR_SYNC
          The motor sync regulation mode mode.
static byte RUN_STATE_IDLE
          The idle run state.
static byte RUN_STATE_RAMP_DOWN
          The ramp down run state.
static byte RUN_STATE_RAMP_UP
          The ramp up run state.
static byte RUN_STATE_RUNNING
          The running run state.
 
Constructor Summary
NXTCommandSetOutputState()
          Creates a new instance of NXTCommandSetOutputState
NXTCommandSetOutputState(byte outputPort, byte powerSetPoint, byte modeByte, byte regulationMode, byte turnRatio, byte runState, long tachoLimit)
          Constructs a new NXTCommandSetOutputState object with output port, power set point, mode byte, regulation mode, turn ration, run state and tacho limit and with no response requirement.
 
Method Summary
 byte getMode()
           
 byte getPowerSetPoint()
           
 byte getRunState()
           
 long getTachoLimit()
          TODO: Check.
 void setMode(byte mode)
          Sets the mode.
 void setPowerSetPoint(byte power)
          Sets the power set point.
 void setRegulationMode(byte regulationMode)
          Sets the regulation mode of the motor.
 void setRunState(byte runState)
          Sets the run state of the motor.
 void setTachoLimit(long tachoLimit)
          Sets the tacho limit.
 
Methods inherited from class pt.citar.diablu.nxt.protocol.NXTCommand
getPacketLength, isResponseRequired, sendCommand, setResponseRequired, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MODE_MOTOR_ON

public static final byte MODE_MOTOR_ON
The motor on mode (bit field - can be combined with other modes).

See Also:
Constant Field Values

MODE_BRAKE

public static final byte MODE_BRAKE
The brake mode (bit field - can be combined with other modes).

See Also:
Constant Field Values

MODE_REGULATED

public static final byte MODE_REGULATED
The regulated mode (bit field - can be combined with other modes).

See Also:
Constant Field Values

REGULATION_MODE_IDLE

public static final byte REGULATION_MODE_IDLE
The idle regulation mode mode. No regulation will be enabled.

See Also:
Constant Field Values

REGULATION_MODE_MOTOR_SPEED

public static final byte REGULATION_MODE_MOTOR_SPEED
The motor speed regulation mode mode. Power control will be enabled on specific output.

See Also:
Constant Field Values

REGULATION_MODE_MOTOR_SYNC

public static final byte REGULATION_MODE_MOTOR_SYNC
The motor sync regulation mode mode. Synchronization will be enabled. (Needs enabled on two outputs).

See Also:
Constant Field Values

RUN_STATE_IDLE

public static final byte RUN_STATE_IDLE
The idle run state.

See Also:
Constant Field Values

RUN_STATE_RAMP_UP

public static final byte RUN_STATE_RAMP_UP
The ramp up run state.

See Also:
Constant Field Values

RUN_STATE_RUNNING

public static final byte RUN_STATE_RUNNING
The running run state.

See Also:
Constant Field Values

RUN_STATE_RAMP_DOWN

public static final byte RUN_STATE_RAMP_DOWN
The ramp down run state.

See Also:
Constant Field Values
Constructor Detail

NXTCommandSetOutputState

public NXTCommandSetOutputState()
Creates a new instance of NXTCommandSetOutputState


NXTCommandSetOutputState

public NXTCommandSetOutputState(byte outputPort,
                                byte powerSetPoint,
                                byte modeByte,
                                byte regulationMode,
                                byte turnRatio,
                                byte runState,
                                long tachoLimit)
Constructs a new NXTCommandSetOutputState object with output port, power set point, mode byte, regulation mode, turn ration, run state and tacho limit and with no response requirement.

Parameters:
outputPort - The output port on which the motor is connected. Range: 0 - 2; 0xff is a special value that means ALL.
powerSetPoint - The power set point (-100 to 100).
modeByte - The mode byte (bit field). See MODE constants.
regulationMode - The regulation mode. See REGULATION_MODE constants.
turnRatio - The turn ratio (-100 to 100).
runState - The run state. See RUN_STATE constants.
tachoLimit - The tacho limit. 0 means forever.
Method Detail

setPowerSetPoint

public void setPowerSetPoint(byte power)
Sets the power set point.

Parameters:
power - The power set point. Range: -100; 100.

getPowerSetPoint

public byte getPowerSetPoint()
Returns:
The current power set point.

setRunState

public void setRunState(byte runState)
Sets the run state of the motor.

Parameters:
runState - The run state. See RUN_STATE constants.

getRunState

public byte getRunState()
Returns:
The current run state.

setRegulationMode

public void setRegulationMode(byte regulationMode)
Sets the regulation mode of the motor.

Parameters:
regulationMode - The regulation mode. See REGULATION_MODE constants.

setMode

public void setMode(byte mode)
Sets the mode.

Parameters:
mode - The mode. See MODE constants.

getMode

public byte getMode()
Returns:
The current mode.

setTachoLimit

public void setTachoLimit(long tachoLimit)
Sets the tacho limit.

Parameters:
tachoLimit - The tacho limit to set.

getTachoLimit

public long getTachoLimit()
TODO: Check.

Returns:
The current tacho limit.


Processing library NXTComm by Jorge C. S. Cardoso. (c) 2014