hvl_ccb.dev.se_ils2t.se_ils2t

Inheritance diagram of hvl_ccb.dev.se_ils2t.se_ils2t

Device class for controlling a Schneider Electric ILS2T stepper drive over modbus TCP.

class ILS2T(com, dev_config=None)[source]

Bases: SingleCommDevice

Schneider Electric ILS2T stepper drive class.

ACTION_JOG_VALUE = 0

The single action value for ILS2T.Mode.JOG

class ActionsPtp(value)[source]

Bases: IntEnum

Allowed actions in the point to point mode (ILS2T.Mode.PTP).

ABSOLUTE_POSITION = 0
RELATIVE_POSITION_MOTOR = 2
RELATIVE_POSITION_TARGET = 1
DEFAULT_IO_SCANNING_CONTROL_VALUES = {'action': 2, 'continue_after_stop_cu': 0, 'disable_driver_di': 0, 'enable_driver_en': 0, 'execute_stop_sh': 0, 'fault_reset_fr': 0, 'mode': 3, 'quick_stop_qs': 0, 'ref_16': 1500, 'ref_32': 0, 'reset_stop_ch': 0}

Default IO Scanning control mode values

class Mode(value)[source]

Bases: IntEnum

ILS2T device modes

JOG = 1
PTP = 3
class Ref16Jog(value)[source]

Bases: Flag

Allowed values for ILS2T ref_16 register (the shown values are the integer representation of the bits), all in Jog mode = 1

FAST = 4
NEG = 2
NEG_FAST = 6
NONE = 0
POS = 1
POS_FAST = 5
RegAddr

Modbus Register Adresses

alias of ILS2TRegAddr

RegDatatype

Modbus Register Datatypes

alias of ILS2TRegDatatype

class State(value)[source]

Bases: IntEnum

State machine status values

ON = 6
QUICKSTOP = 7
READY = 4
static config_cls()[source]

Return the default configdataclass class.

Returns:

a reference to the default configdataclass class

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns:

the type of the standard communication protocol for this device

disable(log_warn: bool = True, wait_sec_max: int | None = None) bool[source]

Disable the driver of the stepper motor and enable the brake.

Note: the driver cannot be disabled if the motor is still running.

Parameters:
  • log_warn – if log a warning in case the motor cannot be disabled.

  • wait_sec_max – maximal wait time for the motor to stop running and to disable it; by default, with None, use a config value

Returns:

True if disable request could and was sent, False otherwise.

do_ioscanning_write(**kwargs: int) None[source]

Perform a write operation using IO Scanning mode.

Parameters:

kwargs – Keyword-argument list with options to send, remaining are taken from the defaults.

enable() None[source]

Enable the driver of the stepper motor and disable the brake.

execute_absolute_position(position: int) bool[source]

Execute a absolute position change, i.e. enable motor, perform absolute position change, wait until done and disable motor afterwards.

Check position at the end if wrong do not raise error; instead just log and return check result.

Parameters:

position – absolute position of motor in user defined steps.

Returns:

True if actual position is as expected, False otherwise.

execute_relative_step(steps: int) bool[source]

Execute a relative step, i.e. enable motor, perform relative steps, wait until done and disable motor afterwards.

Check position at the end if wrong do not raise error; instead just log and return check result.

Parameters:

steps – Number of steps.

Returns:

True if actual position is as expected, False otherwise.

get_dc_volt() float[source]

Read the DC supply voltage of the motor.

Returns:

DC input voltage.

get_error_code() dict[int, dict[str, Any]][source]

Read all messages in fault memory. Will read the full error message and return the decoded values. At the end the fault memory of the motor will be deleted. In addition, reset_error is called to re-enable the motor for operation.

Returns:

Dictionary with all information

get_position() int[source]

Read the position of the drive and store into status.

Returns:

Position step value

get_status() dict[str, int][source]

Perform an IO Scanning read and return the status of the motor.

Returns:

dict with status information.

get_temperature() int[source]

Read the temperature of the motor.

Returns:

Temperature in degrees Celsius.

jog_run(direction: bool = True, fast: bool = False) None[source]

Slowly turn the motor in positive direction.

jog_stop() None[source]

Stop turning the motor in Jog mode.

quickstop() None[source]

Stops the motor with high deceleration rate and falls into error state. Reset with reset_error to recover into normal state.

reset_error() None[source]

Resets the motor into normal state after quick stop or another error occured.

set_jog_speed(slow: int = 60, fast: int = 180) None[source]

Set the speed for jog mode. Default values correspond to startup values of the motor.

Parameters:
  • slow – RPM for slow jog mode.

  • fast – RPM for fast jog mode.

set_max_acceleration(rpm_minute: int) None[source]

Set the maximum acceleration of the motor.

Parameters:

rpm_minute – revolution per minute per minute

set_max_deceleration(rpm_minute: int) None[source]

Set the maximum deceleration of the motor.

Parameters:

rpm_minute – revolution per minute per minute

set_max_rpm(rpm: int) None[source]

Set the maximum RPM.

Parameters:

rpm – revolution per minute ( 0 < rpm <= RPM_MAX)

Raises:

ILS2TError – if RPM is out of range

set_ramp_type(ramp_type: int = -1) None[source]
Set the ramp type. There are two options available:

0: linear ramp -1: motor optimized ramp

Parameters:

ramp_type – 0: linear ramp | -1: motor optimized ramp

start() None[source]

Start this device.

stop() None[source]

Stop this device. Disables the motor (applies brake), disables access and closes the communication protocol.

user_steps(steps: int = 16384, revolutions: int = 1) None[source]

Define steps per revolution. Default is 16384 steps per revolution. Maximum precision is 32768 steps per revolution.

Parameters:
  • steps – number of steps in revolutions.

  • revolutions – number of revolutions corresponding to steps.

write_absolute_position(position: int) None[source]

Write instruction to turn the motor until it reaches the absolute position. This function does not enable or disable the motor automatically.

Parameters:

position – absolute position of motor in user defined steps.

write_relative_step(steps: int) None[source]

Write instruction to turn the motor the relative amount of steps. This function does not enable or disable the motor automatically.

Parameters:

steps – Number of steps to turn the motor.

class ILS2TConfig(rpm_max_init: Integral = 1500, wait_sec_post_enable: int | float = 1, wait_sec_max_disable: int | float = 10, wait_sec_post_cannot_disable: int | float = 1, wait_sec_post_relative_step: int | float = 2, wait_sec_post_absolute_position: int | float = 2)[source]

Bases: object

Configuration for the ILS2T stepper motor device.

clean_values()[source]
force_value(fieldname, value)

Forces a value to a dataclass field despite the class being frozen.

NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.

Parameters:
  • fieldname – name of the field

  • value – value to assign

is_configdataclass = True
classmethod keys() Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns:

a list of strings containing all keys.

classmethod optional_defaults() dict[str, object]

Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.

Returns:

a list of strings containing all optional keys.

classmethod required_keys() Sequence[str]

Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.

Returns:

a list of strings containing all required keys.

rpm_max_init: Integral = 1500

initial maximum RPM for the motor, can be set up to 3000 RPM. The user is allowed to set a new max RPM at runtime using ILS2T.set_max_rpm(), but the value must never exceed this configuration setting.

wait_sec_max_disable: int | float = 10
wait_sec_post_absolute_position: int | float = 2
wait_sec_post_cannot_disable: int | float = 1
wait_sec_post_enable: int | float = 1
wait_sec_post_relative_step: int | float = 2
exception ILS2TError[source]

Bases: DeviceError

Error to indicate problems with the SE ILS2T stepper motor.

class ILS2TModbusTcpCommunication(configuration)[source]

Bases: ModbusTcpCommunication

Specific implementation of Modbus/TCP for the Schneider Electric ILS2T stepper motor.

static config_cls()[source]

Return the default configdataclass class.

Returns:

a reference to the default configdataclass class

class ILS2TModbusTcpCommunicationConfig(host: str | IPv4Address | IPv6Address, unit: int = 255, port: int = 502)[source]

Bases: ModbusTcpCommunicationConfig

Configuration dataclass for Modbus/TCP communciation specific for the Schneider Electric ILS2T stepper motor.

force_value(fieldname, value)

Forces a value to a dataclass field despite the class being frozen.

NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.

Parameters:
  • fieldname – name of the field

  • value – value to assign

classmethod keys() Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns:

a list of strings containing all keys.

classmethod optional_defaults() dict[str, object]

Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.

Returns:

a list of strings containing all optional keys.

classmethod required_keys() Sequence[str]

Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.

Returns:

a list of strings containing all required keys.

unit: int = 255

The unit has to be 255 such that IO scanning mode works.

class ILS2TRegAddr(value)[source]

Bases: IntEnum

Modbus Register Adresses for for Schneider Electric ILS2T stepper drive.

ACCESS_ENABLE = 282
FLT_INFO = 15362
FLT_MEM_DEL = 15112
FLT_MEM_RESET = 15114
IO_SCANNING = 6922
JOGN_FAST = 10506
JOGN_SLOW = 10504
POSITION = 7706
RAMP_ACC = 1556
RAMP_DECEL = 1558
RAMP_N_MAX = 1554
RAMP_TYPE = 1574
SCALE = 1550
TEMP = 7200
VOLT = 7198
class ILS2TRegDatatype(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Modbus Register Datatypes for Schneider Electric ILS2T stepper drive.

From the manual of the drive:

datatype

byte

min

max

INT8

1 Byte

-128

127

UINT8

1 Byte

0

255

INT16

2 Byte

-32_768

32_767

UINT16

2 Byte

0

65_535

INT32

4 Byte

-2_147_483_648

2_147_483_647

UINT32

4 Byte

0

4_294_967_295

BITS

just 32bits

N/A

N/A

INT32 = (-2147483648, 2147483647)
is_in_range(value: int) bool[source]
exception IoScanningModeValueError[source]

Bases: ILS2TError

Erorr to indicate that the selected IO scanning mode is invalid.

exception ScalingFactorValueError[source]

Bases: ILS2TError

Error to indicate that a scaling factor value is invalid.