pylablib.devices.Trinamic package

Submodules

pylablib.devices.Trinamic.base module

exception pylablib.devices.Trinamic.base.TrinamicError[source]

Bases: DeviceError

Generic Trinamic error

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception pylablib.devices.Trinamic.base.TrinamicBackendError(exc)[source]

Bases: TrinamicError, DeviceBackendError

Generic Trinamic backend communication error

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception pylablib.devices.Trinamic.base.TrinamicTimeoutError[source]

Bases: TrinamicError

Generic Trinamic timeout error

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class pylablib.devices.Trinamic.base.TLimitSwitchParams(left_enable, right_enable)

Bases: tuple

left_enable
right_enable
class pylablib.devices.Trinamic.base.TVelocityParams(speed, accel, pulse_divisor, ramp_divisor)

Bases: tuple

accel
pulse_divisor
ramp_divisor
speed
class pylablib.devices.Trinamic.base.THomeParams(mode, search_speed, switch_speed)

Bases: tuple

mode
search_speed
switch_speed
class pylablib.devices.Trinamic.base.TTMCM1110ReplyData(comm, status, value, addr, module)

Bases: tuple

addr
comm
module
status
value
class pylablib.devices.Trinamic.base.TMCM1110(conn)[source]

Bases: ICommBackendWrapper, IStage

Trinamic stepper motor controller TMCM-1110 controlled using TMCL Firmware.

Parameters:

conn – serial connection parameters (usually port or a tuple containing port and baudrate)

Error

alias of TrinamicError

open()[source]

Open the backend

query(comm, comm_type, value, result_format='i', bank=0, addr=0)[source]

Send a query to the stage and return the reply.

For details, see TMCM-1110 firmware manual.

get_axis_parameter(parameter, result_format='i', axis=0, addr=0)[source]

Get a given axis parameter at the given axis and device address

set_axis_parameter(parameter, value, axis=0, addr=0)[source]

Set a given axis parameter at the given axis and device address (volatile; resets on power cycling)

store_axis_parameter(parameter, value=None, axis=0, addr=0)[source]

Store a given axis parameter in EEPROM at the given axis and device address (by default, value is the current value)

get_global_parameter(parameter, result_format='i', bank=0, addr=0)[source]

Get a given global parameter

set_global_parameter(parameter, value, bank=0, addr=0)[source]

Set a given global parameter

get_general_input(port=0, bank=0, addr=0)[source]

Get value of an input at a given bank (0-2) and port.

Bank 0 is digital input (7 ports), bank 1 is analog input (1 port, value from 0 to 2**16-1), bank 2 is digital output (8 ports). For port assignments, see TMCM-1110 firmware manual.

set_general_output(value, port=0, bank=2, addr=0)[source]

Set value of a digital input at a given bank (only bank 2 is available) and port.

For port assignments, see TMCM-1110 firmware manual.

move_to(position, axis=0, addr=0)[source]

Move to a given position

move_by(steps=1, axis=0, addr=0)[source]

Move by a given number of steps

get_position(axis=0, addr=0)[source]

Get the current axis position

set_position_reference(pos=0, axis=0, addr=0)[source]

Set the current axis position as a reference (the actual motor position stays the same)

jog(direction, speed=None, axis=0, addr=0)[source]

Jog in a given direction with a given speed.

direction can be either "-" (negative, left) or "+" (positive, right). The motion continues until it is explicitly stopped, or until a limit is hit. If speed is None, use the standard speed value.

stop(axis=0, addr=0)[source]

Stop motion

get_microstep_resolution(axis=0, addr=0)[source]

Get the number of microsteps per full step (always a power of 2)

set_microstep_resolution(resolution, axis=0, addr=0)[source]

Set the number of microsteps per full step (rounded to a nearest power of 2)

get_current_parameters(max_current=1, axis=0, addr=0)[source]

Return diving current parameter (drive_current, standby_current).

drive_current is the maximal drive current, which is given as a fraction of the max_current (which is either 1A or 2.8A depending on the hardware jumper). standby_current is given as a fraction of drive_current.

setup_current(drive_current=None, standby_current=None, max_current=1.0, axis=0, addr=0)[source]

Set drive and standby currents.

WARNING: too high of a setting might damage the motor. drive_current is the maximal drive current, which is given as a fraction of the max_current (which is either 1A or 2.8A depending on the hardware jumper, as described in the hardware manual). standby_current is given as a fraction of drive_current. Any None parameters are left unchanged.

get_limit_switches_parameters(axis=0, addr=0)[source]

Return limit switch parameters (left_enable, right_enable)

setup_limit_switches(left_enable=None, right_enable=None, axis=0, addr=0)[source]

Setup limit switch parameters

get_limit_switches_state(axis=0, addr=0)[source]

Get the state of the left and right limit switches

get_switch_polarity(axis=0, addr=0)[source]

Get end switch polarity (False for normal, True for reversed).

Note that for 3-axis controller (TMCM-3110) the polarity is the same for all axes, and for 6-axis controller (TMCM-6110) it has to be the same for the first 3 and the last 3 axes

set_switch_polarity(polarity=False, axis=0, addr=0)[source]

Set end switch polarity (False for normal, True for reversed).

Note that for 3-axis controller (TMCM-3110) the polarity is the same for all axes, and for 6-axis controller (TMCM-6110) it has to be the same for the first 3 and the last 3 axes

get_home_parameters(axis=0, addr=0)[source]

Return homing parameters (mode, search_speed, switch_speed).

mode is one of 16 different values, which can start with "lim_" indicating reliance on limit switches, or with "home_" indicating usage of home switches. Home-based switches can also be inverted (with "_inv" in the end), indicating that the homing switch function is inverted (0 instead of 1 means that the switch is engaged). More details can be found in the manual. search_speed and switch_speed describe, respectively, the initial speed while searching for the switch, and the final homing speed while searching for the edge of the switch action. Both are given in internal units.

setup_home(home_mode=None, search_speed=None, switch_speed=None, axis=0, addr=0)[source]

Setup homing parameters (mode, search_speed, switch_speed).

mode is one of 16 different values, which can start with "lim_" indicating reliance on limit switches, or with "home_" indicating usage of home switches. Home-based switches can also be inverted (with "_inv" in the end), indicating that the homing switch function is inverted (0 instead of 1 means that the switch is engaged). More details can be found in the manual. search_speed and switch_speed describe, respectively, the initial speed while searching for the switch, and the final homing speed while searching for the edge of the switch action. Both are given in internal units.

home(wait=True, timeout=30.0, axis=0, addr=0)[source]

Home the given axis.

If wait==True, wait until the homing is complete or until timeout is passed. Note that homing affects the velocity parameters, which need to be re-established after the homing is complete. This is done automatically when wait==True, but needs to be done manually otherwise.

is_homing(axis=0, addr=0)[source]

Check if homing is in progress at the given address

get_last_home_position(axis=0, addr=0)[source]

Get the last readout position when the homing operation was complete (0 upon startup)

get_velocity_parameters(axis=0, addr=0)[source]

Return velocity parameters (speed, accel, pulse_divisor, ramp_divisor).

speed and accel denote, correspondingly, maximal (i.e., steady regime) moving speed and acceleration in internal units. pulse_divisor is the driver pulse divisor, which defines how internal velocity units translate into microsteps/s (see get_velocity_factor()); can only be a power of 2, higher values mean slower motion. ramp_divisor is the driver ramp divisor, which, together with the pulse divisor, defines how internal acceleration units translate into microsteps/s^2 (see get_acceleration_factor()); rounded to the nearest power of 2, higher values mean slower acceleration.

setup_velocity(speed=None, accel=None, pulse_divisor=None, ramp_divisor=None, axis=0, addr=0)[source]

Setup velocity parameters (speed, accel, pulse_divisor, ramp_divisor).

speed and accel denote, correspondingly, maximal (i.e., steady regime) moving speed and acceleration in internal units. pulse_divisor is the driver pulse divisor, which defines how internal velocity units translate into microsteps/s (see get_velocity_factor()); rounded to the nearest power of 2, higher values mean slower motion. ramp_divisor is the driver ramp divisor, which, together with the pulse divisor, defines how internal acceleration units translate into microsteps/s^2 (see get_acceleration_factor()); rounded to the nearest power of 2, higher values mean slower acceleration. None values are left unchanged.

get_velocity_factor(axis=0, addr=0)[source]

Get the ratio between the real speed (in microsteps/s) and the internal units

get_acceleration_factor(axis=0, addr=0)[source]

Get the ratio between the real acceleration (in microsteps/s^2) and the internal units

get_current_speed(axis=0, addr=0)[source]

Get the instantaneous speed in internal units

is_moving(axis=0, addr=0)[source]

Check if the motor is moving

wait_move(axis=0, addr=0)[source]

Wait until motion is done

apply_settings(settings)

Apply the settings.

settings is the dict {name: value} of the device available settings. Non-applicable settings are ignored.

close()

Close the backend

get_device_variable(key)

Get the value of a settings, status, or full info parameter

get_full_info(include=0)

Get dict {name: value} containing full device information (including status and settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_full_status(include=0)

Get dict {name: value} containing the device status (including settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_settings(include=0)

Get dict {name: value} containing all the device settings.

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

is_opened()

Check if the device is connected

lock(timeout=None)

Lock the access to the device from other threads/processes (isn’t necessarily implemented)

locking(timeout=None)

Context manager for lock & unlock

set_device_variable(key, value)

Set the value of a settings parameter

unlock()

Unlock the access to the device from other threads/processes (isn’t necessarily implemented)

class pylablib.devices.Trinamic.base.TMCMx110(conn, naxes=None)[source]

Bases: TMCM1110, IMultiaxisStage

Trinamic multi-axis stepper motor controller TMCM-x110 (1110, 3110, 6110) controlled using TMCL Firmware.

The main difference from the single-axis TMCM1110 is that it determines the number of axes upon the connection, and that the device variables return dictionaries {axis: value} instead of a single value (even for single-axis controller for consistency).

Parameters:
  • conn – serial connection parameters (usually port or a tuple containing port and baudrate)

  • naxes – maximal number of axes to check for upon connection; if the actual number is larger, use only first naxes axes

Error

alias of TrinamicError

apply_settings(settings)

Apply the settings.

settings is the dict {name: value} of the device available settings. Non-applicable settings are ignored.

close()

Close the backend

get_acceleration_factor(axis=0, addr=0)

Get the ratio between the real acceleration (in microsteps/s^2) and the internal units

get_all_axes()

Get the list of all available axes (taking mapping into account)

get_axis_parameter(parameter, result_format='i', axis=0, addr=0)

Get a given axis parameter at the given axis and device address

get_current_parameters(max_current=1, axis=0, addr=0)

Return diving current parameter (drive_current, standby_current).

drive_current is the maximal drive current, which is given as a fraction of the max_current (which is either 1A or 2.8A depending on the hardware jumper). standby_current is given as a fraction of drive_current.

get_current_speed(axis=0, addr=0)

Get the instantaneous speed in internal units

get_device_variable(key)

Get the value of a settings, status, or full info parameter

get_full_info(include=0)

Get dict {name: value} containing full device information (including status and settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_full_status(include=0)

Get dict {name: value} containing the device status (including settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_general_input(port=0, bank=0, addr=0)

Get value of an input at a given bank (0-2) and port.

Bank 0 is digital input (7 ports), bank 1 is analog input (1 port, value from 0 to 2**16-1), bank 2 is digital output (8 ports). For port assignments, see TMCM-1110 firmware manual.

get_global_parameter(parameter, result_format='i', bank=0, addr=0)

Get a given global parameter

get_home_parameters(axis=0, addr=0)

Return homing parameters (mode, search_speed, switch_speed).

mode is one of 16 different values, which can start with "lim_" indicating reliance on limit switches, or with "home_" indicating usage of home switches. Home-based switches can also be inverted (with "_inv" in the end), indicating that the homing switch function is inverted (0 instead of 1 means that the switch is engaged). More details can be found in the manual. search_speed and switch_speed describe, respectively, the initial speed while searching for the switch, and the final homing speed while searching for the edge of the switch action. Both are given in internal units.

get_last_home_position(axis=0, addr=0)

Get the last readout position when the homing operation was complete (0 upon startup)

get_limit_switches_parameters(axis=0, addr=0)

Return limit switch parameters (left_enable, right_enable)

get_limit_switches_state(axis=0, addr=0)

Get the state of the left and right limit switches

get_microstep_resolution(axis=0, addr=0)

Get the number of microsteps per full step (always a power of 2)

get_position(axis=0, addr=0)

Get the current axis position

get_settings(include=0)

Get dict {name: value} containing all the device settings.

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_switch_polarity(axis=0, addr=0)

Get end switch polarity (False for normal, True for reversed).

Note that for 3-axis controller (TMCM-3110) the polarity is the same for all axes, and for 6-axis controller (TMCM-6110) it has to be the same for the first 3 and the last 3 axes

get_velocity_factor(axis=0, addr=0)

Get the ratio between the real speed (in microsteps/s) and the internal units

get_velocity_parameters(axis=0, addr=0)

Return velocity parameters (speed, accel, pulse_divisor, ramp_divisor).

speed and accel denote, correspondingly, maximal (i.e., steady regime) moving speed and acceleration in internal units. pulse_divisor is the driver pulse divisor, which defines how internal velocity units translate into microsteps/s (see get_velocity_factor()); can only be a power of 2, higher values mean slower motion. ramp_divisor is the driver ramp divisor, which, together with the pulse divisor, defines how internal acceleration units translate into microsteps/s^2 (see get_acceleration_factor()); rounded to the nearest power of 2, higher values mean slower acceleration.

home(wait=True, timeout=30.0, axis=0, addr=0)

Home the given axis.

If wait==True, wait until the homing is complete or until timeout is passed. Note that homing affects the velocity parameters, which need to be re-established after the homing is complete. This is done automatically when wait==True, but needs to be done manually otherwise.

is_homing(axis=0, addr=0)

Check if homing is in progress at the given address

is_moving(axis=0, addr=0)

Check if the motor is moving

is_opened()

Check if the device is connected

jog(direction, speed=None, axis=0, addr=0)

Jog in a given direction with a given speed.

direction can be either "-" (negative, left) or "+" (positive, right). The motion continues until it is explicitly stopped, or until a limit is hit. If speed is None, use the standard speed value.

lock(timeout=None)

Lock the access to the device from other threads/processes (isn’t necessarily implemented)

locking(timeout=None)

Context manager for lock & unlock

move_by(steps=1, axis=0, addr=0)

Move by a given number of steps

move_to(position, axis=0, addr=0)

Move to a given position

open()

Open the backend

query(comm, comm_type, value, result_format='i', bank=0, addr=0)

Send a query to the stage and return the reply.

For details, see TMCM-1110 firmware manual.

remap_axes(mapping, accept_original=True)

Rename axes to the new labels.

mapping is the new axes mapping, which can be a list of new axes name (corresponding to the old axes in order returned by get_all_axes()), or a dictionary {alias: original} of the new axes aliases.

set_axis_parameter(parameter, value, axis=0, addr=0)

Set a given axis parameter at the given axis and device address (volatile; resets on power cycling)

set_device_variable(key, value)

Set the value of a settings parameter

set_general_output(value, port=0, bank=2, addr=0)

Set value of a digital input at a given bank (only bank 2 is available) and port.

For port assignments, see TMCM-1110 firmware manual.

set_global_parameter(parameter, value, bank=0, addr=0)

Set a given global parameter

set_microstep_resolution(resolution, axis=0, addr=0)

Set the number of microsteps per full step (rounded to a nearest power of 2)

set_position_reference(pos=0, axis=0, addr=0)

Set the current axis position as a reference (the actual motor position stays the same)

set_switch_polarity(polarity=False, axis=0, addr=0)

Set end switch polarity (False for normal, True for reversed).

Note that for 3-axis controller (TMCM-3110) the polarity is the same for all axes, and for 6-axis controller (TMCM-6110) it has to be the same for the first 3 and the last 3 axes

setup_current(drive_current=None, standby_current=None, max_current=1.0, axis=0, addr=0)

Set drive and standby currents.

WARNING: too high of a setting might damage the motor. drive_current is the maximal drive current, which is given as a fraction of the max_current (which is either 1A or 2.8A depending on the hardware jumper, as described in the hardware manual). standby_current is given as a fraction of drive_current. Any None parameters are left unchanged.

setup_home(home_mode=None, search_speed=None, switch_speed=None, axis=0, addr=0)

Setup homing parameters (mode, search_speed, switch_speed).

mode is one of 16 different values, which can start with "lim_" indicating reliance on limit switches, or with "home_" indicating usage of home switches. Home-based switches can also be inverted (with "_inv" in the end), indicating that the homing switch function is inverted (0 instead of 1 means that the switch is engaged). More details can be found in the manual. search_speed and switch_speed describe, respectively, the initial speed while searching for the switch, and the final homing speed while searching for the edge of the switch action. Both are given in internal units.

setup_limit_switches(left_enable=None, right_enable=None, axis=0, addr=0)

Setup limit switch parameters

setup_velocity(speed=None, accel=None, pulse_divisor=None, ramp_divisor=None, axis=0, addr=0)

Setup velocity parameters (speed, accel, pulse_divisor, ramp_divisor).

speed and accel denote, correspondingly, maximal (i.e., steady regime) moving speed and acceleration in internal units. pulse_divisor is the driver pulse divisor, which defines how internal velocity units translate into microsteps/s (see get_velocity_factor()); rounded to the nearest power of 2, higher values mean slower motion. ramp_divisor is the driver ramp divisor, which, together with the pulse divisor, defines how internal acceleration units translate into microsteps/s^2 (see get_acceleration_factor()); rounded to the nearest power of 2, higher values mean slower acceleration. None values are left unchanged.

stop(axis=0, addr=0)

Stop motion

store_axis_parameter(parameter, value=None, axis=0, addr=0)

Store a given axis parameter in EEPROM at the given axis and device address (by default, value is the current value)

unlock()

Unlock the access to the device from other threads/processes (isn’t necessarily implemented)

wait_move(axis=0, addr=0)

Wait until motion is done

Module contents