lejos.nxt.addon
Class LinearActuator

java.lang.Object
  extended by lejos.nxt.addon.LinearActuator

public class LinearActuator
extends java.lang.Object

A Linear Actuator class that provides non-blocking actions and 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 12mm/s unloaded. See www.firgelli.com..

Author:
Kirk P. Thompson, 3/3/2011 <lejos@mosen.net>

Constructor Summary
LinearActuator(MotorPort motorPort)
          Create a LinearActuator instance.
 
Method Summary
 void extend(int distance, boolean immediateReturn)
          Causes the actuator to extend distance in encoder ticks.
 int getTachoCount()
          Returns the tachometer (encoder) count.
 boolean isMoving()
          Returns true if the actuator is in motion.
 void retract(int distance, boolean immediateReturn)
          Causes the actuator to retract distance in encoder ticks.
 void setPower(int power)
          Sets the power for the actuator.
 void shutdown()
          Shut down the worker threads for this class and null the MotorPort ref.
 void stopActuator()
          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

LinearActuator

public LinearActuator(MotorPort motorPort)
Create a LinearActuator instance. Use this constructor to assign a variable of type MotorPort connected to a particular port.

Parameters:
motorPort - The MotorPort (A,B,C) port to which the linear actuator is connected
Method Detail

setPower

public void setPower(int power)
Sets the power for the actuator. This must be called before the extend() and retract() methods are called. Values below 50 will be set as 50. Using lower power values and pushing/pulling an excessive load may cause a stall. Stall detection will stop the current actuator action.

Parameters:
power - power setting: 50 - 100
See Also:
extend(int, boolean), retract(int, boolean)

isMoving

public boolean isMoving()
Returns true if the actuator is in motion.

Returns:
true if the actuator is in motion.

extend

public void extend(int distance,
                   boolean immediateReturn)
Causes the actuator to extend distance in encoder ticks. The distance is relative to the actuator shaft position at the time calling this method. Stall detection stops the actuator in the event of a stall condition.

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 extend or retract is called before the stroke distance is reached, the current extension action is canceled.

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

Parameters:
distance - The Stroke distance in encoder ticks. See getTachoCount().
immediateReturn - Set to true to cause the extension to occur in its own thread and immediately return.
See Also:
retract(int, boolean), setPower(int)

retract

public void retract(int distance,
                    boolean immediateReturn)
Causes the actuator to retract distance in encoder ticks. The distance is relative to the actuator shaft position at the time calling this method. Stall detection stops the actuator in the event of a stall condition.

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 extend or retract is called before the stroke distance is reached, the current retraction action is canceled.

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

Parameters:
distance - The Stroke distance in encoder ticks. See getTachoCount().
immediateReturn - Set to true to cause the retraction to occur in its own thread and immediately return.
See Also:
extend(int, boolean), setPower(int)

shutdown

public void shutdown()
Shut down the worker threads for this class and null the MotorPort ref. After this is called, a new instance must be created,


stopActuator

public void stopActuator()
Immediately stop any current actuator action.


getTachoCount

public int getTachoCount()
Returns the tachometer (encoder) count. The Firgelli L12-NXT-50 & 100 use 0.5 mm/encoder tick. eg: 200 ticks=100 mm.

Returns:
tachometer count in encoder ticks.