public class TetrixServoController extends I2CSensor
TetrixServo
instances which are used to control
the Tetrix servos.
Servos are driven by a PWM signal with varying pulse widths controlling the rotational position of the servo actuator. The pulse nominally ranges from 1.0 ms to 2.0 ms with 1.5 ms always being center of range. Pulse widths outside this range can be used for "overtravel" -moving the servo beyond its normal range.
As an example, for a servo with a 90 deg. travel range, a pulse width of 1.5 ms (1500 microseconds) will typically set the servo to its "neutral" position or 45 degrees, a pulse of 1.25 ms could set it to 0 degrees and a pulse of 1.75 ms to 90 degrees. The physical limits and timings of the servo hardware varies between brands and models, but a general 90 degree servo's angular motion will travel somewhere in the range of 90 deg. - 120 deg. and the neutral position is almost always at 1.5 ms. This is the "standard pulse servo mode" used by all hobby analog servos.
The HiTechic Servo Controller allows setting of the PWM output from 0.75 - 2.25ms. Note that some servos may hit their internal mechanical limits at each end of this range causing them to consume excessive current and potentially be damaged.
Use
to retrieve a TetrixControllerFactory.newServoController()
TetrixServoController
instance.
TetrixControllerFactory
Modifier and Type | Field and Description |
---|---|
static int |
SERVO_1
Represents the servo connected to Channel 1 as indicated on the controller
|
static int |
SERVO_2
Represents the servo connected to Channel 2 as indicated on the controller
|
static int |
SERVO_3
Represents the servo connected to Channel 3 as indicated on the controller
|
static int |
SERVO_4
Represents the servo connected to Channel 4 as indicated on the controller
|
static int |
SERVO_5
Represents the servo connected to Channel 5 as indicated on the controller
|
static int |
SERVO_6
Represents the servo connected to Channel 6 as indicated on the controller
|
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION, retryCount
currentMode, modes
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, BROWN, GREEN, GREEN_INDEX, MAX_TYPE, MIN_TYPE, MODE_RAW, NXT_ADC_RES, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HIGHSPEED, TYPE_HIGHSPEED_9V, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
Constructor and Description |
---|
TetrixServoController(I2CPort port,
int daisyChainPosition)
Instantiate for a HiTechnic TETRIX Servo Controller connected to the given
port and daisy chain position. |
Modifier and Type | Method and Description |
---|---|
void |
flt()
Set all servos connected to this controller to float mode.
|
TetrixServo |
getServo(int servoID)
Get the
TetrixServo instance that is associated with the passed servoID . |
int |
getStepTime()
Gets the step time used for all servos on this controller.
|
boolean |
isMoving()
Returns whether or not there are servos on this controller that are moving.
|
void |
setStepTime(int step)
Sets the step time used for all servos on this controller.
|
fetchString, getAddress, getData, getData, getPort, getProductID, getRetryCount, getVendorID, getVersion, sendData, sendData, sendData, setAddress, setRetryCount
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
close, releaseOnClose
public static final int SERVO_1
public static final int SERVO_2
public static final int SERVO_3
public static final int SERVO_4
public static final int SERVO_5
public static final int SERVO_6
public TetrixServoController(I2CPort port, int daisyChainPosition)
port
and daisy chain position.port
- The sensor port the controller (if daisy-chained, the first) is connected to.daisyChainPosition
- The position of the controller in the daisy chain.java.lang.IllegalStateException
- if a Servo Controller was not found with given port
and daisyChainPosition
TetrixControllerFactory.DAISY_CHAIN_POSITION_1
,
TetrixControllerFactory.DAISY_CHAIN_POSITION_2
,
TetrixControllerFactory.DAISY_CHAIN_POSITION_3
,
TetrixControllerFactory.DAISY_CHAIN_POSITION_4
public TetrixServo getServo(int servoID)
TetrixServo
instance that is associated with the passed servoID
.public boolean isMoving()
false
when the step time is set to 0 (disabled).true
if any servo is moving to position.setStepTime(int)
public void flt()
public void setStepTime(int step)
The step time can be considered a delay before progressing to the next step. For example, if a servo is positioned at 1500 microseconds pulse width, and you give it a new position command of 2000 microseconds, it will normally go as fast as it can to get to the new position. If you want it to go to the new position but not at the maximum output, you can set the step to a value from 0 to 15.
One of the main things it could be useful for, is if you have two servos with different loads, and you want them to be as much in sync as possible. You can set the speed to slow the controller from changing the servo signals instantly.
The isMoving()
method always returns false
if the step time is set to zero.
step
- Step Time, 0-15. Setting to 0 disables step time.java.lang.IllegalArgumentException
- If step is not in the range 0 to 15getStepTime()
,
isMoving()
public int getStepTime()
setStepTime(int)