Class LnrActrFirgelliNXT
- java.lang.Object
-
- lejos.hardware.device.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 aNXTMotorusing the specified motor port.LnrActrFirgelliNXT(EncoderMotor encoderMotor)Create aLnrActrFirgelliNXTinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetPower()Returns the current actuator motor power setting.intgetTachoCount()Returns the absolute tachometer (encoder) position of the actuator shaft.booleanisMoving()Returns true if the actuator is in motion.booleanisStalled()Returns true if amove()ormoveTo()order ended due to a motor stall.voidmove(int distance, boolean immediateReturn)Causes the actuator to movedistancein encoder ticks.voidmoveTo(int position, boolean immediateReturn)Causes the actuator to move to absolutepositionin encoder ticks.voidresetTachoCount()Resets the tachometer (encoder) count to zero at the current actuator shaft position.voidsetPower(int power)Sets the power for the actuator.voidstop()Immediately stop any current actuator action.
-
-
-
Constructor Detail
-
LnrActrFirgelliNXT
public LnrActrFirgelliNXT(EncoderMotor encoderMotor)
Create aLnrActrFirgelliNXTinstance. Use this constructor to assign an instance ofEncoderMotorused to drive the actuater motor. This constructor allows any motor class that implements theEncoderMotorinterface to drive the actuator. You must instantiate theEncoderMotor-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 typeEncoderMotorwhich will drive the actuator- See Also:
UnregulatedMotor,MMXMotor,EncoderMotor
-
LnrActrFirgelliNXT
public LnrActrFirgelliNXT(Port port)
Convenience constructor that creates an instance of aNXTMotorusing 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 themove()ormoveTo()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:
setPowerin interfaceLinearActuator- 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:
getPowerin interfaceLinearActuator- Returns:
- current power 0-100%
-
isMoving
public boolean isMoving()
Returns true if the actuator is in motion.- Specified by:
isMovingin interfaceLinearActuator- Returns:
- true if the actuator is in motion.
-
isStalled
public boolean isStalled()
Returns true if amove()ormoveTo()order ended due to a motor stall. This behaves like a latch where the reset of the stall status is done on a newmove()ormoveTo()order.- Specified by:
isStalledin interfaceLinearActuator- Returns:
trueif actuator motor stalled during a movement order.falseotherwise.- See Also:
LinearActuator.move(int,boolean)
-
move
public void move(int distance, boolean immediateReturn)Causes the actuator to movedistancein encoder ticks. Thedistanceis 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
immediateReturnistrue, this method returns immediately (does not block) and the actuator stops when the strokedistanceis met [or a stall is detected]. If anothermoveaction is called before the stroke distance is reached, the current actuator action is cancelled and the new action is initiated.If the stroke
distancespecified 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:
movein interfaceLinearActuator- Parameters:
distance- The Stroke distance in encoder ticks.immediateReturn- Set totrueto cause the method to immediately return while the action is executed in the background.falsewill 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 absolutepositionin encoder ticks. Thepositionof the actuator shaft on startup or when set byresetTachoCount()is zero.- Specified by:
moveToin interfaceLinearActuator- Parameters:
position- The absolute shaft position in encoder ticks.immediateReturn- Set totrueto cause the method to immediately return while the action is executed in the background.- See Also:
move(int,boolean),resetTachoCount()
-
stop
public void stop()
Immediately stop any current actuator action.- Specified by:
stopin interfaceLinearActuator- See Also:
LinearActuator.move(int,boolean)
-
getTachoCount
public int getTachoCount()
Returns the absolute tachometer (encoder) position of the actuator shaft. The zero position of the actuator shaft is whereresetTachoCount()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:
getTachoCountin interfaceEncoder- Specified by:
getTachoCountin interfaceLinearActuator- Returns:
- tachometer count in encoder ticks.
- See Also:
resetTachoCount()
-
resetTachoCount
public void resetTachoCount()
Resets the tachometer (encoder) count to zero at the current actuator shaft position.- Specified by:
resetTachoCountin interfaceEncoder- Specified by:
resetTachoCountin interfaceLinearActuator- See Also:
getTachoCount()
-
-