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.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
- 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.
- set_axis_parameter(parameter, value, addr=0)[source]
Set a given axis parameter (volatile; resets on power cycling)
- store_axis_parameter(parameter, value=None, addr=0)[source]
Store a given axis parameter in EEPROM (by default, value is the current value)
- get_global_parameter(parameter, result_format='i', bank=0, addr=0)[source]
Get 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.
- set_position_reference(pos=0, addr=0)[source]
Set the current axis position as a reference (the actual motor position stays the same)
- jog(direction, speed=None, 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. Ifspeed is None
, use the standard speed value.
- get_microstep_resolution(addr=0)[source]
Get the number of microsteps per full step (always a power of 2)
- set_microstep_resolution(resolution, addr=0)[source]
Set the number of microsteps per full step (rounded to a nearest power of 2)
- get_current_parameters(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 maximal generated current current (which is either 1A or 2.8A depending on the hardware jumper).standby_current
is given as a fraction ofdrive_current
.
- setup_current(drive_current=None, standby_current=None, 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 maximal generated current current (which is either 1A or 2.8A depending on the hardware jumper).standby_current
is given as a fraction ofdrive_current
. AnyNone
parameters are left unchanged.
- get_limit_switches_parameters(addr=0)[source]
Return limit switch parameters
(left_enable, right_enable)
- setup_limit_switches(left_enable=None, right_enable=None, addr=0)[source]
Setup limit switch parameters
- get_home_parameters(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
andswitch_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, 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
andswitch_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, 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 whenwait==True
, but needs to be done manually otherwise.
- get_velocity_parameters(addr=0)[source]
Return velocity parameters
(speed, accel, pulse_divisor, ramp_divisor)
.speed
andaccel
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 (seeget_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 (seeget_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, addr=0)[source]
Setup velocity parameters
(speed, accel, pulse_divisor, ramp_divisor)
.speed
andaccel
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 (seeget_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 (seeget_acceleration_factor()
); rounded to the nearest power of 2, higher values mean slower acceleration.None
values are left unchanged.
- get_velocity_factor(addr=0)[source]
Get the ratio between the real speed (in microsteps/s) and the internal units
- get_acceleration_factor(addr=0)[source]
Get the ratio between the real acceleration (in microsteps/s^2) and the internal units
- 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, settinginclude=-10
queries all available variables, which is equivalent toinclude="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, settinginclude=-10
queries all available variables, which is equivalent toinclude="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, settinginclude=-10
queries all available variables, which is equivalent toinclude="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)