Class LnrActrFirgelliNXT

  • All Implemented Interfaces:
    Encoder, LinearActuator

    public class LnrActrFirgelliNXT
    extends java.lang.Object
    implements LinearActuator
    A Linear Actuator class that provides blocking and non-blocking move actions with stall detection. Developed for the Firgelli L12-NXT-50 and L12-NXT-100 but may work for others. These linear actuators are self contained units which include an electric motor and encoder. They will push up to 25N and move at up to 12 mm/sec unloaded.

    This class in not thread-safe and it is up to the caller to properly handle synchronization when calling its methods in a multithreaded software implementation.

    This is not an endorsement: For informational purposes, see www.firgelli.com. for details on the actuators.

    Author:
    Kirk P. Thompson
    • Constructor Summary

      Constructors 
      Constructor Description
      LnrActrFirgelliNXT​(Port port)
      Convenience constructor that creates an instance of a NXTMotor using the specified motor port.
      LnrActrFirgelliNXT​(EncoderMotor encoderMotor)
      Create a LnrActrFirgelliNXT instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getPower()
      Returns the current actuator motor power setting.
      int getTachoCount()
      Returns the absolute tachometer (encoder) position of the actuator shaft.
      boolean isMoving()
      Returns true if the actuator is in motion.
      boolean isStalled()
      Returns true if a move() or moveTo() order ended due to a motor stall.
      void move​(int distance, boolean immediateReturn)
      Causes the actuator to move distance in encoder ticks.
      void moveTo​(int position, boolean immediateReturn)
      Causes the actuator to move to absolute position in encoder ticks.
      void resetTachoCount()
      Resets the tachometer (encoder) count to zero at the current actuator shaft position.
      void setPower​(int power)
      Sets the power for the actuator.
      void stop()
      Immediately stop any current actuator action.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LnrActrFirgelliNXT

        public LnrActrFirgelliNXT​(EncoderMotor encoderMotor)
        Create a LnrActrFirgelliNXT instance. Use this constructor to assign an instance of EncoderMotor used to drive the actuater motor. This constructor allows any motor class that implements the EncoderMotor interface to drive the actuator. You must instantiate the EncoderMotor-type motor before passing it to this constructor.

        When an instance of the MMXMotor class is used, the motor power curve is much different that with a NXTMotor (due to a different PWM output?) . The speed peaks out at about 20% power so in effect, the speed control granularity is coarser.

        The default power at instantiation is 100%.

        Parameters:
        encoderMotor - A motor instance of type EncoderMotor which will drive the actuator
        See Also:
        UnregulatedMotor, MMXMotor, EncoderMotor
      • LnrActrFirgelliNXT

        public LnrActrFirgelliNXT​(Port port)
        Convenience constructor that creates an instance of a NXTMotor using the specified motor port. This instance is then used to drive the actuator motor.

        The default power at instantiation is 100%.

        Parameters:
        port - The motor port that the linear actuator is attached to.
        See Also:
        MotorPort, UnregulatedMotor
    • Method Detail

      • setPower

        public void setPower​(int power)
        Sets the power for the actuator. This is called before the move() or moveTo() method is called to set the power. Using lower power values and pushing/pulling an excessive load may cause a stall and in this case, stall detection will stop the current actuator action and set the stalled condition flag.

        The default power value on instantiation is 100%.

        Specified by:
        setPower in interface LinearActuator
        Parameters:
        power - power setting: 0-100%
        See Also:
        LinearActuator.move(int,boolean), isStalled
      • getPower

        public int getPower()
        Returns the current actuator motor power setting.
        Specified by:
        getPower in interface LinearActuator
        Returns:
        current power 0-100%
      • isMoving

        public boolean isMoving()
        Returns true if the actuator is in motion.
        Specified by:
        isMoving in interface LinearActuator
        Returns:
        true if the actuator is in motion.
      • isStalled

        public boolean isStalled()
        Returns true if a move() or moveTo() order ended due to a motor stall. This behaves like a latch where the reset of the stall status is done on a new move() or moveTo() order.
        Specified by:
        isStalled in interface LinearActuator
        Returns:
        true if actuator motor stalled during a movement order. false otherwise.
        See Also:
        LinearActuator.move(int,boolean)
      • move

        public void move​(int distance,
                         boolean immediateReturn)
        Causes the actuator to move distance in encoder ticks. The distance is relative to the actuator shaft position at the time of calling this method. Positive values extend the actuator shaft while negative values retract it. The Firgelli L12-NXT-50 & 100 use 0.5 mm/encoder tick. eg: 200 ticks=100 mm.

        Stall detection stops the actuator in the event of a stall condition to help prevent damage to the actuator.

        If immediateReturn is true, this method returns immediately (does not block) and the actuator stops when the stroke distance is met [or a stall is detected]. If another move action is called before the stroke distance is reached, the current actuator action is cancelled and the new action is initiated.

        If the stroke distance specified exceeds the maximum stroke length (fully extended or retracted against an end stop), stall detection will stop the action. It is advisable not to extend or retract to the stop as this is hard on the actuator. If you must go all the way to an end stop and rely on stall detection to stop the action, use a lower power setting.

        Specified by:
        move in interface LinearActuator
        Parameters:
        distance - The Stroke distance in encoder ticks.
        immediateReturn - Set to true to cause the method to immediately return while the action is executed in the background. false will block until the action is completed, whether successfully or stalled.
        See Also:
        setPower(int), stop(), getTachoCount(), moveTo(int,boolean)
      • moveTo

        public void moveTo​(int position,
                           boolean immediateReturn)
        Causes the actuator to move to absolute position in encoder ticks. The position of the actuator shaft on startup or when set by resetTachoCount() is zero.
        Specified by:
        moveTo in interface LinearActuator
        Parameters:
        position - The absolute shaft position in encoder ticks.
        immediateReturn - Set to true to cause the method to immediately return while the action is executed in the background.
        See Also:
        move(int,boolean), resetTachoCount()
      • getTachoCount

        public int getTachoCount()
        Returns the absolute tachometer (encoder) position of the actuator shaft. The zero position of the actuator shaft is where resetTachoCount() was last called or the position of the shaft when instantiated.

        The Firgelli L12-NXT-50 & 100 use 0.5 mm/encoder tick. eg: 200 ticks=100 mm.

        Specified by:
        getTachoCount in interface Encoder
        Specified by:
        getTachoCount in interface LinearActuator
        Returns:
        tachometer count in encoder ticks.
        See Also:
        resetTachoCount()