public class LnrActrFirgelliNXT extends java.lang.Object implements LinearActuator
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.
Constructor and Description |
---|
LnrActrFirgelliNXT(EncoderMotor encoderMotor)
Create a
LnrActrFirgelliNXT instance. |
LnrActrFirgelliNXT(Port port)
Convenience constructor that creates an instance of a
NXTMotor using the specified motor port. |
Modifier and Type | Method and 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.
|
public LnrActrFirgelliNXT(EncoderMotor encoderMotor)
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%.
encoderMotor
- A motor instance of type EncoderMotor
which will drive the actuatorUnregulatedMotor
,
MMXMotor
,
EncoderMotor
public LnrActrFirgelliNXT(Port port)
NXTMotor
using the specified motor port. This instance is then
used to drive the actuator motor.
The default power at instantiation is 100%.
port
- The motor port that the linear actuator is attached to.MotorPort
,
UnregulatedMotor
public void setPower(int power)
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%.
setPower
in interface LinearActuator
power
- power setting: 0-100%LinearActuator.move(int,boolean)
,
isStalled
public int getPower()
getPower
in interface LinearActuator
public boolean isMoving()
isMoving
in interface LinearActuator
public boolean isStalled()
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.isStalled
in interface LinearActuator
true
if actuator motor stalled during a movement order. false
otherwise.LinearActuator.move(int,boolean)
public void move(int distance, boolean immediateReturn)
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.
move
in interface LinearActuator
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.setPower(int)
,
stop()
,
getTachoCount()
,
moveTo(int,boolean)
public void moveTo(int position, boolean immediateReturn)
position
in encoder ticks. The position
of the actuator
shaft on startup or when set by resetTachoCount()
is zero.moveTo
in interface LinearActuator
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.move(int,boolean)
,
resetTachoCount()
public void stop()
stop
in interface LinearActuator
LinearActuator.move(int,boolean)
public int getTachoCount()
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.
getTachoCount
in interface Encoder
getTachoCount
in interface LinearActuator
resetTachoCount()
public void resetTachoCount()
resetTachoCount
in interface Encoder
resetTachoCount
in interface LinearActuator
getTachoCount()