Class TetrixServoController

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, SensorConstants, SensorMode, SensorModes, SampleProvider

    public class TetrixServoController
    extends I2CSensor
    HiTechnic Servo Controller abstraction. Provides 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 TetrixControllerFactory.newServoController() to retrieve a TetrixServoController instance.

    Author:
    Kirk P. Thompson
    See Also:
    TetrixControllerFactory
    • 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
    • Method Detail

      • getServo

        public TetrixServo getServo​(int servoID)
        Get the TetrixServo instance that is associated with the passed servoID.
        Parameters:
        servoID - The motor ID number SERVO_1 to SERVO_6. This is indicated on the HiTechnic Servo Controller.
        Returns:
        The TetrixServo instance associated with the labeled channel
        See Also:
        SERVO_1, SERVO_2, SERVO_3, SERVO_4, SERVO_5, SERVO_6
      • isMoving

        public boolean isMoving()
        Returns whether or not there are servos on this controller that are moving. This method always returns false when the step time is set to 0 (disabled).
        Returns:
        true if 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 returns false if 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)