public interface MotorController
EazyCNC calls these methods to delegate the associated tasks to the motor controller.
The implementing class needs to adhere to the specification set out in this javadoc and fulfill the contract it makes.
Modifier and Type | Interface and Description |
---|---|
static class |
MotorController.MotorState
defines the possible states a motor can be in.
|
Modifier and Type | Method and Description |
---|---|
void |
abortAll()
Stops all movements abruptly (possibly causing accuracy loss) and empties
all movement queues, disarms probe and stops jogging.
|
void |
armProbe()
arm the probe so that the next activation of the probe input stops movements and captures the motor positions.
|
void |
forceConfig()
Deprecated.
|
ConnectionState |
getConnectionState()
returns the connection state of the motor controller.
|
int[] |
getMotorPosition()
gets the motor position counter of the specified motor.
|
MotorController.MotorState |
getMotorState(int motor)
Deprecated.
|
int[] |
getProbePosition()
if the probe input has been armed and then activated this return the capture motor positions.
|
double |
getVelocityFactor()
returns a constant that is used to convert movement and time to a speed value.
|
java.lang.String |
getVersion()
return a string that can be displayed to the EazyCNC user to identify the motor controller and version
|
void |
queueMove(int[] move)
This method is called to pass an axis move command to the motor controller.
|
void |
setConnectionState(ConnectionState reqState)
requests the motor controller to enter the connection state specified.
|
void |
setPosition(int motor,
int position)
sets the specified motors position counter to the specified value.
|
void |
startHoming(int motor) |
boolean |
startJogging(int motor,
boolean forward) |
void |
stopJogging(int motor) |
java.lang.String getVersion()
ConnectionState getConnectionState()
void setConnectionState(ConnectionState reqState)
Request the motor controller to enter the connection state specified
by the reqState
parameter.
If the motor controller is in the requested state it should just ignore the request, but if it is not then it should attempt to enter the requested state.
This may involve for example opening a USB device or a serial port. The motor controller does not need to and indeed should *not* make multiple attempts to establish the connection as EezyCNC will take care of re-trying by calling this method until it succeeds.
reqState
- the requested statevoid queueMove(int[] move) throws java.lang.Exception
The command specifies both the speed and position for each axis.
The motion planner calculates new move commands as fast as it can and passes them to the motor controller with this call, therefore this method must block if it is unable to queue the move for, on the other hand it should provide a reasonably sized internal queue so that the planner can proceed to calculate new movements in advance.
A reasonably sized queue is one that never gets empty even if the system pauses for garbage collection but is not too long so that if the system needs to enter the feed HOLD state it can happen in a reasonable time. About 100 to 200 msec worth of moves is a good queue length.
move
- an array of requested motor positions and speedsjava.lang.Exception
- if the queuing was aborted because abortAll
has been calledboolean startJogging(int motor, boolean forward) throws java.lang.Exception
java.lang.Exception
void stopJogging(int motor) throws java.lang.Exception
java.lang.Exception
void startHoming(int motor)
void abortAll()
void setPosition(int motor, int position)
motor
- the motor numberposition
- the new position counter valueint[] getMotorPosition()
Note that if the motor is running/moving the position is always lagging behind the physical motor position.
void armProbe()
int[] getProbePosition()
If this call returns an array of positions (instead of null) this is an indication of a successful probing move. Subsequent calls to this method will return null unless the probe is re-armed and triggers again.
double getVelocityFactor()
This method returns value which when multiplied by distance in steps divided by
time in seconds gives the speed value required for e.g. queueMove
.
MotorController.MotorState getMotorState(int motor)
motor
- -void forceConfig()