Class TetrixServoController
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.I2CSensor
-
- lejos.hardware.device.tetrix.TetrixServoController
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SensorConstants,SensorMode,SensorModes,SampleProvider
public class TetrixServoController extends I2CSensor
HiTechnic Servo Controller abstraction. ProvidesTetrixServoinstances 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 aTetrixControllerFactory.newServoController()TetrixServoControllerinstance.- Author:
- Kirk P. Thompson
- See Also:
TetrixControllerFactory
-
-
Field Summary
Fields Modifier and Type Field Description static intSERVO_1Represents the servo connected to Channel 1 as indicated on the controllerstatic intSERVO_2Represents the servo connected to Channel 2 as indicated on the controllerstatic intSERVO_3Represents the servo connected to Channel 3 as indicated on the controllerstatic intSERVO_4Represents the servo connected to Channel 4 as indicated on the controllerstatic intSERVO_5Represents the servo connected to Channel 5 as indicated on the controllerstatic intSERVO_6Represents the servo connected to Channel 6 as indicated on the controller-
Fields inherited from class lejos.hardware.sensor.I2CSensor
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION, retryCount
-
Fields inherited from class lejos.hardware.sensor.BaseSensor
currentMode, modes
-
Fields inherited from interface lejos.hardware.sensor.SensorConstants
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 Summary
Constructors Constructor Description TetrixServoController(I2CPort port, int daisyChainPosition)Instantiate for a HiTechnic TETRIX Servo Controller connected to the givenportand daisy chain position.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidflt()Set all servos connected to this controller to float mode.TetrixServogetServo(int servoID)Get theTetrixServoinstance that is associated with the passedservoID.intgetStepTime()Gets the step time used for all servos on this controller.booleanisMoving()Returns whether or not there are servos on this controller that are moving.voidsetStepTime(int step)Sets the step time used for all servos on this controller.-
Methods inherited from class lejos.hardware.sensor.I2CSensor
fetchString, getAddress, getData, getData, getPort, getProductID, getRetryCount, getVendorID, getVersion, sendData, sendData, sendData, setAddress, setRetryCount
-
Methods inherited from class lejos.hardware.sensor.BaseSensor
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
-
Methods inherited from class lejos.hardware.Device
close, releaseOnClose
-
-
-
-
Field Detail
-
SERVO_1
public static final int SERVO_1
Represents the servo connected to Channel 1 as indicated on the controller- See Also:
- Constant Field Values
-
SERVO_2
public static final int SERVO_2
Represents the servo connected to Channel 2 as indicated on the controller- See Also:
- Constant Field Values
-
SERVO_3
public static final int SERVO_3
Represents the servo connected to Channel 3 as indicated on the controller- See Also:
- Constant Field Values
-
SERVO_4
public static final int SERVO_4
Represents the servo connected to Channel 4 as indicated on the controller- See Also:
- Constant Field Values
-
SERVO_5
public static final int SERVO_5
Represents the servo connected to Channel 5 as indicated on the controller- See Also:
- Constant Field Values
-
SERVO_6
public static final int SERVO_6
Represents the servo connected to Channel 6 as indicated on the controller- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TetrixServoController
public TetrixServoController(I2CPort port, int daisyChainPosition)
Instantiate for a HiTechnic TETRIX Servo Controller connected to the givenportand daisy chain position.- Parameters:
port- The sensor port the controller (if daisy-chained, the first) is connected to.daisyChainPosition- The position of the controller in the daisy chain.- Throws:
java.lang.IllegalStateException- if a Servo Controller was not found with givenportanddaisyChainPosition- See Also:
TetrixControllerFactory.DAISY_CHAIN_POSITION_1,TetrixControllerFactory.DAISY_CHAIN_POSITION_2,TetrixControllerFactory.DAISY_CHAIN_POSITION_3,TetrixControllerFactory.DAISY_CHAIN_POSITION_4
-
-
Method Detail
-
getServo
public TetrixServo getServo(int servoID)
Get theTetrixServoinstance that is associated with the passedservoID.
-
isMoving
public boolean isMoving()
Returns whether or not there are servos on this controller that are moving. This method always returnsfalsewhen the step time is set to 0 (disabled).- Returns:
trueif any servo is moving to position.- See Also:
setStepTime(int)
-
flt
public void flt()
Set all servos connected to this controller to float mode. This means they are powered down and will not attempt to hold their current position. The next call to any motion command for any servo will re-enable power to all servo channels.
-
setStepTime
public void setStepTime(int step)
Sets the step time used for all servos on this controller. This sets the step time for the servo channel which has the furthest to move. Other servo channels which are not at their designated positions yet will run at a slower rate to ensure they reach their destination positions at the same time. The controller defaults to 0 on power-up.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 returnsfalseif the step time is set to zero.- Parameters:
step- Step Time, 0-15. Setting to 0 disables step time.- Throws:
java.lang.IllegalArgumentException- If step is not in the range 0 to 15- See Also:
getStepTime(),isMoving()
-
getStepTime
public int getStepTime()
Gets the step time used for all servos on this controller.- Returns:
- The step time 0-15. 0 means step is disabled.
- See Also:
setStepTime(int)
-
-