ximc_instrument
Libximc/pyximc Instrument interface/implementation. May be subclassed, but can be used directly for most libximc-compliant motor controllers or translation stages.
This module contains the XimcInstrument class, and associated Enums and Exceptions.
Warning
Importing this module attempts to load both the local pyximc interface, and the system libximc dynamic linked library. If either does not exist or is not installed, the import will fail.
Classes
|
Implementation of the Instrument Class that wraps libximc to control Standa and similar motor controllers. |
Exceptions
Issue reading or processing calibration procedure for XimcInstrument. |
|
Generic libXIMC/XimcInstrument error class. |
|
Readback inconsistency after sending XimcInstrument command. |
|
|
Error returned from libXIMC as pyximc.Result. |
XimcInstrument
- class icicle.ximc_instrument.XimcInstrument(*args, **kwargs)
Bases:
Instrument
Implementation of the Instrument Class that wraps libximc to control Standa and similar motor controllers.
Warning
All subclasses of XimcInstrument must have the ‘key’ keyword class argument defined to specify which ‘__init__’ keyword argument should be used as the Multiton key.
- __init__(resource='', calibration=None, microstep_mode=None, user_units='mm')
Note
All arguments must be provided as explicit keyword argument.
- Parameters:
resource – libximc controller name. See libximc docs for examples.
calibration – user unit multiplier value to overrride value read from controller. (Not recommended)
microstep_mode – custom microstep mode to override value read from controller. (Not recommended)
user_units – user_units to use for this device.
- class MicrostepMode(*values)
Bases:
IntEnum
Libximc engine microstep modes.
- MICROSTEP_MODE_FRAC_128 = 8
- MICROSTEP_MODE_FRAC_16 = 5
- MICROSTEP_MODE_FRAC_2 = 2
- MICROSTEP_MODE_FRAC_256 = 9
- MICROSTEP_MODE_FRAC_32 = 6
- MICROSTEP_MODE_FRAC_4 = 3
- MICROSTEP_MODE_FRAC_64 = 7
- MICROSTEP_MODE_FRAC_8 = 4
- MICROSTEP_MODE_FULL = 1
- NO_SIMULATION = True
- STAGE_CALIBRATIONS = {'STANDA': {'8MT175-150': {'cm': 0.00025, 'mm': 0.0025, 'um': 2.5}}}
Currently Unused - initial implementation of stage calibrations. Now read from stage/engine setting stored on device on __enter__()
- USER_UNITS = {'NM': 5.39957e-07, 'cm': 10.0, 'inch': 0.0393701, 'm': 1000.0, 'mm': 1.0, 'um': 0.001}
Conversion factors for different choices of user units.
Assume base unit in calibration is mm.
- classmethod devices()
Enumerate ximc devices.
- Returns:
list of ximc devices; each device is a dict with fields idx, resource, name.
- get_movement_settings(raw_object=False)
Get current movement settings for controller.
- Parameters:
raw_object – Whether to return a raw pyximc.move_settings_t object instead of a python dict.
- Returns:
movement settings as dict with fields speed, microspeed, acceleration, deceleration, antiplay_speed, antiplay_microspeed, movement_flags. See https://libximc.xisupport.com/doc-en/structmove__settings__t.html
- get_position()
Read current position of device in steps and microsteps.
- Returns:
Position as dict with fields steps, microsteps.
- get_position_user()
Read current position of device and encoder (if applicable) in user units.
- Returns:
Position as dict with fields position, encoder_position.
- property has_calibration
- Returns:
Whether an active calibration has been loaded from the controller memory or set during instantiation.
- home()
Go to home position of device.
- Returns:
success or failure.
- identify()
Return identification information about controller that this device corresponds to.
- Returns:
Information as dict with fields manufacturer, manufacturer_id, description, major, `minor, release.
- classmethod library_version()
Get libximc version.
- Returns:
libximc version
- move(steps, microsteps, wait_and_readback=True)
Move device to provided position in steps and microsteps (location = steps * calibration + microsteps * calibration / microsteps_per_step).
- Parameters:
steps – location to move to in steps.
microsteps – sub-location to move to in microsteps.
wait_and_readback – whether to wait for move to complete and readback/check new position.
- Returns:
Position as dict with fields steps, microsteps if wait_and_readback is True, else None.
- move_user(user_units, wait_and_readback=True)
Move device to provided position in user units (location = steps * calibration + microsteps * calibration / microsteps_per_step).
- Parameters:
user_units – location to move to in currently set user units (default: mm; see __init__()).
wait_and_readback – whether to wait for move to complete and readback/check new position.
- Returns:
Position as dict with fields position, encoder_position if wait_and_readback is True, else None.
- read_calibration()
Read screw pitch, engine steps per revolution, and microstep mode from connected controller, and generate calibration info.
- Returns:
Calibration as dict with fields multiplier, microstep_mode.
- set_microstep_mode(microstep_mode, skip_calibration_update=False, readback=True)
Set engine microstep mode.
- Parameters:
microstep_mode – microstep mode to set.
skip_calibration_update – if set to True, does not trigger an update of the user units calibration.
readback – whether to readback/check new value.
- Returns:
Readback microstep mode if readback is True, else None.
- set_movement_settings()
- wait()
Wait for device to complete current action.
- write_profile(profile=None, profile_vendor=None, profile_device=None, skip_calibration_update=False)
Load and/or write profile from deps/custom_profiles/<vendor>/<device> or deps/pyximc_profiles/<vendor>/<device> to connected controller.
- Parameters:
profile – pyximc profile function (callable) to execute.
profile_vendor – vendor of device to fetch profile from deps/(custom|pyximc)_profiles/<vendor>/<device>
profile_device – vendor of device to fetch profile from deps/(custom|pyximc)_profiles/<vendor>/<device>
skip_calibration_update – if set to True, does not trigger an update of the user units calibration.
- property ximc_calibration
- Returns:
pyximc.calibration_t object corresponding to current calibration to be used in libximc command_*_calb() methods. Returns None if not has_calibration.
- zero()
Zero axis of device.
- Returns:
success or failure.
XimcCalibrationError
- icicle.ximc_instrument.XimcCalibrationError()
Issue reading or processing calibration procedure for XimcInstrument.
XimcError
- icicle.ximc_instrument.XimcError()
Generic libXIMC/XimcInstrument error class.
XimcReadbackError
- icicle.ximc_instrument.XimcReadbackError()
Readback inconsistency after sending XimcInstrument command.
XimcResultError
- icicle.ximc_instrument.XimcResultError(resultcode, msg=None)
Error returned from libXIMC as pyximc.Result.