API Reference v9.2.0

Axisclass

Module: ZaberMotionAscii

Represents an axis of motion associated with a device.

The following example illustrates how you can obtain an instance of this type:

import ZaberMotionAscii

let connection = try await Connection.openSerialPort(portName: "COM3")
let device = try connection.getDevice(deviceAddress: 1)
let axis = try device.getAxis(axisNumber: 1)

Properties

p

axisNumber

readonly
axis.axisNumber
Int The axis number identifies the axis on the device. The first axis has the number one.
p

axisType

readonlythrows
try axis.axisType
AxisType Determines the type of an axis and units it accepts.
p

device

readonly
axis.device
Device Device that controls this axis.
p

identity

readonlythrows
try axis.identity
AxisIdentity Identity of the axis.
p

isPeripheral

readonlythrows
try axis.isPeripheral
Bool Indicates whether the axis is a peripheral or part of an integrated device.
p

label

readonlythrows
try axis.label
String User-assigned label of the peripheral.
p

peripheralId

readonlythrows
try axis.peripheralId
Int Unique ID of the peripheral hardware.
p

peripheralName

readonlythrows
try axis.peripheralName
String Name of the peripheral.
p

peripheralSerialNumber

readonlythrows
try axis.peripheralSerialNumber
UInt Serial number of the peripheral, or 0 when not applicable.
p

resolution

readonlythrows
try axis.resolution
UInt The number of microsteps per full step for motion axes. Always equal to 0 for non-motion axes.
p

settings

readonly
axis.settings
AxisSettings Settings and properties of this axis.
p

storage

readonly
axis.storage
AxisStorage Key-value storage of this axis. Requires at least Firmware 7.30.
p

warnings

readonly
axis.warnings
Warnings Warnings and faults of this axis.

Methods

m

activate()

asyncthrows
try await axis.activate()
Activates a peripheral on this axis. Removes all identity information for the device. Run the identify method on the device after activating to refresh the information.
m

driverDisable()

asyncthrows
try await axis.driverDisable()
Disables the driver, which prevents current from being sent to the motor or load. If the driver is already disabled, the driver remains disabled.
m

driverEnable()

asyncthrows
try await axis.driverEnable(timeout = 10)
Attempts to enable the driver repeatedly for the specified timeout. If the driver is already enabled, the driver remains enabled.
Arguments
NameTypeDescription
timeoutDoubleTimeout in seconds. Specify 0 to attempt to enable the driver once.
m

genericCommand()

asyncthrows
try await axis.genericCommand(command, checkErrors = true, timeout = 0)
Sends a generic ASCII command to this axis. For more information refer to: ASCII Protocol Manual.
Arguments
NameTypeDescription
commandStringCommand and its parameters.
checkErrorsBoolControls whether to throw an exception when the device rejects the command.
timeoutIntThe timeout, in milliseconds, for a device to respond to the command. Overrides the connection default request timeout.
Return Value
Response A response to the command.
m

genericCommandMultiResponse()

asyncthrows
try await axis.genericCommandMultiResponse(command, checkErrors = true, timeout = 0)
Sends a generic ASCII command to this axis and expect multiple responses. Responses are returned in order of arrival. For more information refer to: ASCII Protocol Manual.
Arguments
NameTypeDescription
commandStringCommand and its parameters.
checkErrorsBoolControls whether to throw an exception when a device rejects the command.
timeoutIntThe timeout, in milliseconds, for a device to respond to the command. Overrides the connection default request timeout.
Return Value
[Response] All responses to the command.
m

genericCommandNoResponse()

asyncthrows
try await axis.genericCommandNoResponse(command)
Sends a generic ASCII command to this axis without expecting a response and without adding a message ID For more information refer to: ASCII Protocol Manual.
Arguments
NameTypeDescription
commandStringCommand and its parameters.
m

getCommandUnitConversionDescriptors()

throws
try axis.getCommandUnitConversionDescriptors(commandTemplate)
Retrieves unit conversion descriptors for a command, allowing unit conversion without a device. The descriptors can be used with the ConvertTo/FromNativeUnits methods of the UnitTable class. Parameters in the command template are denoted by a question mark. For more information refer to: ASCII Protocol Manual.
Arguments
NameTypeDescription
commandTemplateStringTemplate of the command. Parameters are denoted by question marks.
Return Value
[UnitConversionDescriptor?] Unit conversion descriptor for each parameter in the command. Nil if a parameter does not have conversion.
m

getIndexPosition()

asyncthrows
try await axis.getIndexPosition()
Returns current axis index position.
Return Value
Int Index position starting from 1 or 0 if the position is not an index position.
m

getNumberOfIndexPositions()

asyncthrows
try await axis.getNumberOfIndexPositions()
Gets number of index positions of the axis.
Return Value
Int Number of index positions.
m

getPosition()

asyncthrows
try await axis.getPosition(unit = Units.native)
Returns current axis position.
Arguments
NameTypeDescription
unitUnitsUnits of position.
Return Value
Double Axis position.
m

getState()

asyncthrows
try await axis.getState()
Returns a serialization of the current axis state that can be saved and reapplied.
Return Value
String A serialization of the current state of the axis.
m

home()

asyncthrows
try await axis.home(waitUntilIdle = true)
Homes axis. Axis returns to its homing position.
Arguments
NameTypeDescription
waitUntilIdleBoolDetermines whether function should return after the movement is finished or just started.
m

isBusy()

asyncthrows
try await axis.isBusy()
Returns bool indicating whether the axis is executing a motion command.
Return Value
Bool True if the axis is currently executing a motion command.
m

isHomed()

asyncthrows
try await axis.isHomed()
Returns bool indicating whether the axis has position reference and was homed.
Return Value
Bool True if the axis has position reference and was homed.
m

isParked()

asyncthrows
try await axis.isParked()
Returns bool indicating whether the axis is parked or not.
Return Value
Bool True if the axis is currently parked. False otherwise.
m

moveAbsolute()

asyncthrows
try await axis.moveAbsolute(position, unit = Units.native, waitUntilIdle = true, velocity = 0, velocityUnit = Units.native, acceleration = 0, accelerationUnit = Units.native, cyclicDirection = nil, extraCycles = nil)
Move axis to absolute position.
Arguments
NameTypeDescription
positionDoubleAbsolute position.
unitUnitsUnits of position.
waitUntilIdleBoolDetermines whether function should return after the movement is finished or just started.
velocityDoubleMovement velocity. Default value of 0 indicates that the maxspeed setting is used instead.
velocityUnitUnitsUnits of velocity.
accelerationDoubleMovement acceleration. Default value of 0 indicates that the accel setting is used instead.
accelerationUnitUnitsUnits of acceleration.
cyclicDirectionCyclicDirection?Which direction a cyclic device should take to get to the target position.
extraCyclesInt?Number of extra cycles to complete before stopping at the target.
m

moveIndex()

asyncthrows
try await axis.moveIndex(index, waitUntilIdle = true, velocity = 0, velocityUnit = Units.native, acceleration = 0, accelerationUnit = Units.native)
Moves the axis to index position.
Arguments
NameTypeDescription
indexIntIndex position. Index positions are numbered from 1.
waitUntilIdleBoolDetermines whether function should return after the movement is finished or just started.
velocityDoubleMovement velocity. Default value of 0 indicates that the maxspeed setting is used instead.
velocityUnitUnitsUnits of velocity.
accelerationDoubleMovement acceleration. Default value of 0 indicates that the accel setting is used instead.
accelerationUnitUnitsUnits of acceleration.
m

moveMax()

asyncthrows
try await axis.moveMax(waitUntilIdle = true, velocity = 0, velocityUnit = Units.native, acceleration = 0, accelerationUnit = Units.native)
Moves the axis to the maximum position as specified by limit.max.
Arguments
NameTypeDescription
waitUntilIdleBoolDetermines whether function should return after the movement is finished or just started.
velocityDoubleMovement velocity. Default value of 0 indicates that the maxspeed setting is used instead.
velocityUnitUnitsUnits of velocity.
accelerationDoubleMovement acceleration. Default value of 0 indicates that the accel setting is used instead.
accelerationUnitUnitsUnits of acceleration.
m

moveMin()

asyncthrows
try await axis.moveMin(waitUntilIdle = true, velocity = 0, velocityUnit = Units.native, acceleration = 0, accelerationUnit = Units.native)
Moves the axis to the minimum position as specified by limit.min.
Arguments
NameTypeDescription
waitUntilIdleBoolDetermines whether function should return after the movement is finished or just started.
velocityDoubleMovement velocity. Default value of 0 indicates that the maxspeed setting is used instead.
velocityUnitUnitsUnits of velocity.
accelerationDoubleMovement acceleration. Default value of 0 indicates that the accel setting is used instead.
accelerationUnitUnitsUnits of acceleration.
m

moveRelative()

asyncthrows
try await axis.moveRelative(position, unit = Units.native, waitUntilIdle = true, velocity = 0, velocityUnit = Units.native, acceleration = 0, accelerationUnit = Units.native)
Move axis to position relative to current position.
Arguments
NameTypeDescription
positionDoubleRelative position.
unitUnitsUnits of position.
waitUntilIdleBoolDetermines whether function should return after the movement is finished or just started.
velocityDoubleMovement velocity. Default value of 0 indicates that the maxspeed setting is used instead.
velocityUnitUnitsUnits of velocity.
accelerationDoubleMovement acceleration. Default value of 0 indicates that the accel setting is used instead.
accelerationUnitUnitsUnits of acceleration.
m

moveSin()

asyncthrows
try await axis.moveSin(amplitude, amplitudeUnits, period, periodUnits, count = 0, waitUntilIdle = true)
Moves the axis in a sinusoidal trajectory.
Arguments
NameTypeDescription
amplitudeDoubleAmplitude of the sinusoidal motion (half of the motion's peak-to-peak range).
amplitudeUnitsUnitsUnits of position.
periodDoublePeriod of the sinusoidal motion in milliseconds.
periodUnitsUnitsUnits of time.
countDoubleNumber of sinusoidal cycles to complete. Must be a multiple of 0.5 If count is not specified or set to 0, the axis will move indefinitely.
waitUntilIdleBoolDetermines whether function should return after the movement is finished or just started.
m

moveSinStop()

asyncthrows
try await axis.moveSinStop(waitUntilIdle = true)
Stops the axis at the end of the sinusoidal trajectory. If the sinusoidal motion was started with an integer-plus-half cycle count, the motion ends at the half-way point of the sinusoidal trajectory.
Arguments
NameTypeDescription
waitUntilIdleBoolDetermines whether function should return after the movement is finished.
m

moveVelocity()

asyncthrows
try await axis.moveVelocity(velocity, unit = Units.native, acceleration = 0, accelerationUnit = Units.native)
Begins to move axis at specified speed.
Arguments
NameTypeDescription
velocityDoubleMovement velocity.
unitUnitsUnits of velocity.
accelerationDoubleMovement acceleration. Default value of 0 indicates that the accel setting is used instead.
accelerationUnitUnitsUnits of acceleration.
m

park()

asyncthrows
try await axis.park()
Parks the axis in anticipation of turning the power off. It can later be powered on, unparked, and moved without first having to home it.
m

prepareCommand()

throws
try axis.prepareCommand(commandTemplate, ...parameters)
Formats parameters into a command and performs unit conversions. Parameters in the command template are denoted by a question mark. Command returned is only valid for this axis and this device. For more information refer to: ASCII Protocol Manual.
Arguments
NameTypeDescription
commandTemplateStringTemplate of a command to prepare. Parameters are denoted by question marks.
...parameters[Measurement]Variable number of command parameters.
Return Value
String Command with converted parameters.
m

restore()

asyncthrows
try await axis.restore()
Restores all axis settings to their default values. Deletes all zaber axis storage keys. Disables lockstep if the axis is part of one. Unparks the axis. Preserves storage. The device needs to be identified again after the restore.
m

setLabel()

asyncthrows
try await axis.setLabel(label)
Sets the user-assigned peripheral label. The label is stored on the controller and recognized by other software.
Arguments
NameTypeDescription
labelStringLabel to set.
m

setState()

asyncthrows
try await axis.setState(state)
Applies a saved state to this axis.
Arguments
NameTypeDescription
stateStringThe state object to apply to this axis.
Return Value
SetStateAxisResponse Reports of any issues that were handled, but caused the state to not be exactly restored.
m

stop()

asyncthrows
try await axis.stop(waitUntilIdle = true)
Stops ongoing axis movement. Decelerates until zero speed.
Arguments
NameTypeDescription
waitUntilIdleBoolDetermines whether function should return after the movement is finished or just started.
m

toString()

throws
try axis.toString()
Returns a string that represents the axis.
Return Value
String A string that represents the axis.
m

unpark()

asyncthrows
try await axis.unpark()
Unparks axis. Axis will now be able to move.
m

waitUntilIdle()

asyncthrows
try await axis.waitUntilIdle(throwErrorOnFault = true)
Waits until axis stops moving.
Arguments
NameTypeDescription
throwErrorOnFaultBoolDetermines whether to throw error when fault is observed.