icommand.nxt
Class Motor

java.lang.Object
  extended by icommand.nxt.Motor
All Implemented Interfaces:
NXTProtocol

public class Motor
extends java.lang.Object
implements NXTProtocol

Motor class. Contains three instances of Motor. Usage: Motor.A.forward(5000);

Version:
0.2 4-September-2006
Author:
Brian Bagnall

Field Summary
static Motor A
          Motor A.
static Motor B
          Motor B.
static Motor C
          Motor C.
 byte turnRatio
           
 
Fields inherited from interface icommand.nxt.comm.NXTProtocol
ANGLE, ANGLESTEPSMODE, BOOLEANMODE, BOOT, BRAKE, CELSIUSMODE, CLOSE, CUSTOM, DELETE, DELETE_USER_FLASH, DIRECT_COMMAND_NOREPLY, DIRECT_COMMAND_REPLY, FAHRENHEITMODE, FIND_FIRST, FIND_NEXT, GET_BATTERY_LEVEL, GET_CURRENT_PROGRAM_NAME, GET_DEVICE_INFO, GET_FIRMWARE_VERSION, GET_INPUT_VALUES, GET_OUTPUT_STATE, HIGH_SPEED_BUFFER, KEEP_ALIVE, LIGHT_ACTIVE, LIGHT_INACTIVE, LOWSPEED, LOWSPEED_9V, LS_GET_STATUS, LS_READ, LS_WRITE, MESSAGE_READ, MESSAGE_WRITE, MODEMASK, MOTOR_RUN_STATE_IDLE, MOTOR_RUN_STATE_RAMPDOWN, MOTOR_RUN_STATE_RAMPUP, MOTOR_RUN_STATE_RUNNING, MOTORON, NO_OF_SENSOR_TYPES, NO_SENSOR, NXJ_DEFRAG, NXJ_DISCONNECT, OPEN_APPEND_DATA, OPEN_READ, OPEN_READ_LINEAR, OPEN_WRITE, OPEN_WRITE_DATA, OPEN_WRITE_LINEAR, PCTFULLSCALEMODE, PERIODCOUNTERMODE, PLAY_SOUND_FILE, PLAY_TONE, POLL, POLL_BUFFER, POLL_LENGTH, RAWMODE, READ, REFLECTION, REGULATED, REGULATION_MODE_IDLE, REGULATION_MODE_MOTOR_SPEED, REGULATION_MODE_MOTOR_SYNC, REPLY_COMMAND, RESET_MOTOR_POSITION, RESET_SCALED_INPUT_VALUE, SET_BRICK_NAME, SET_INPUT_MODE, SET_OUTPUT_STATE, SLOPEMASK, SOUND_DB, SOUND_DBA, START_PROGRAM, STOP_PROGRAM, STOP_SOUND_PLAYBACK, SWITCH, SYSTEM_COMMAND_NOREPLY, SYSTEM_COMMAND_REPLY, TEMPERATURE, TRANSITIONCNTMODE, WRITE
 
Method Summary
 int backward()
          Causes motor to rotate backward.
 int flt()
          Stops the motor without using brakes.
 int forward()
          Causes motor to rotate forward indefinitely.
 int getBlockTacho()
          Deprecated.  
 char getId()
          Get the ID of the motor.
 int getRotationCount()
          Deprecated.  
 int getSpeed()
           
 int getTachoCount()
          Returns the rotation count for the motor.
 boolean isMoving()
           
 boolean isRotating()
          CURRENTLY NOT IMPLEMENTED! Use isMoving() for now.
 int resetBlockTacho()
          Deprecated.  
 int resetRotationCounter()
          Deprecated.  
 int resetTachoCount()
          Resets the rotation counter to zero.
 int rotate(long count)
          Causes the motor to rotate a certain count.
 int rotate(long count, boolean returnNow)
          Causes the motor to rotate a certain count.
 int rotateTo(long target)
          Rotates to a desired tacho count.
 int rotateTo(long target, boolean returnNow)
          Rotates to a desired tacho count.
 void setRegulationMode(int mode)
          This method determines if and how the motor will be regulated.
 void setSpeed(int speed)
          Sets motor speed , in degrees per second; Up to 900 is posssible with 8 volts.
 int stop()
          Stops the motor using brakes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

turnRatio

public byte turnRatio

A

public static final Motor A
Motor A.


B

public static final Motor B
Motor B.


C

public static final Motor C
Motor C.

Method Detail

getId

public final char getId()
Get the ID of the motor. One of 'A', 'B' or 'C'.


forward

public int forward()
Causes motor to rotate forward indefinitely.

Returns:
Error value. 0 means succcess. See icommand.nxtcomm.ErrorMessages for details.

backward

public int backward()
Causes motor to rotate backward.

Returns:
Error value. 0 means succcess. See icommand.nxtcomm.ErrorMessages for details.

setSpeed

public void setSpeed(int speed)
Sets motor speed , in degrees per second; Up to 900 is posssible with 8 volts. NOTE: If using LEGO firmware this will convert the number into power. 900 = 100% power, 450 = 50% power.

Parameters:
speed - value in degrees/sec

getSpeed

public int getSpeed()

getTachoCount

public int getTachoCount()
Returns the rotation count for the motor. NOTE: If you are using leJOS NXJ firmware this will return the same value as getRotationCount() because the leJOS NXJ firmware only uses one Tachometer variable.

Returns:
Tachometer count.

getRotationCount

public int getRotationCount()
Deprecated. 

Returns the rotation count for the motor. The rotation count is something like the trip odometer on your car. This count is reset each time a new function is called in Pilot.

Returns:
rotation count.
See Also:
Pilot

getBlockTacho

public int getBlockTacho()
Deprecated. 

Block Tachometer Count is the count used to synchronize motors with one another. NOTE: If you are using leJOS NXJ firmware this will always return 0 because this variable is not used in in leJOS NXJ firmware. Use getRotationCount() instead.

Returns:
Block Tachometer count.

rotate

public int rotate(long count,
                  boolean returnNow)
Causes the motor to rotate a certain count. The motor will also backtrack to the desired count when done. NOTE: This method returns almost immediately if returnNow = true.

Parameters:
count - Number of counts to rotate motor.
returnNow - When true, method returns before the rotation is complete.
Returns:
Error value. 0 means succcess. See icommand.nxtcomm.ErrorMessages for details.

isMoving

public boolean isMoving()

isRotating

public boolean isRotating()
CURRENTLY NOT IMPLEMENTED! Use isMoving() for now. returns true when motor is rotating toward a specified angle


rotate

public int rotate(long count)
Causes the motor to rotate a certain count. This method returns after the rotation is completed. NOTE: This method currently doesn't work well with the LEGO firmware.

Parameters:
count - Number of counts to rotate motor.
Returns:
Error value. 0 means succcess. See icommand.nxtcomm.ErrorMessages for details.

setRegulationMode

public void setRegulationMode(int mode)
This method determines if and how the motor will be regulated. REGULATION_MODE_IDLE turns off regulation REGULATION_MODE_MOTOR_SPEED regulates the speed (I think) REGULATION_MODE_MOTOR_SYNC synchronizes this and any other motor with SYNC enabled.

Parameters:
mode - See NXTProtocol for enumerations: REGULATION_MODE_MOTOR_SYNC, REGULATION_MODE_MOTOR_SPEED, REGULATION_MODE_IDLE

rotateTo

public int rotateTo(long target)
Rotates to a desired tacho count. Does not return until rotation done. Note: The tachocount can not be reset to zero.

Parameters:
target -

rotateTo

public int rotateTo(long target,
                    boolean returnNow)
Rotates to a desired tacho count. Returns before the rotation is done if you include true as the argument.

Parameters:
target -

resetTachoCount

public int resetTachoCount()
Resets the rotation counter to zero.

Returns:
Error value. 0 means succcess. See icommand.nxtcomm.ErrorMessages for details.

resetRotationCounter

public int resetRotationCounter()
Deprecated. 

Calls resetTachoCount().

Returns:

resetBlockTacho

public int resetBlockTacho()
Deprecated. 

Resets the block tachometer. NOTE: If you are using leJOS NXJ firmware this will not do anything because BlockTacho is not used in the leJOS NXJ firmware. Use resetRotationCounter() instead.

Returns:
Error value. 0 means succcess. See icommand.nxtcomm.ErrorMessages for details.

stop

public int stop()
Stops the motor using brakes.

Returns:
Error value. 0 means succcess. See icommand.nxtcomm.ErrorMessages for details.

flt

public int flt()
Stops the motor without using brakes. UNTESTED

Returns:


Copyright © 2006. All Rights Reserved.