edcon.edrive package

Submodules

edcon.edrive.com_base module

Contains ComBase class which contains common code for EDrive communication drivers.

class edcon.edrive.com_base.ComBase

Bases: object

Class that contains common functions for EDrive communication drivers.

read_pnu_raw(pnu: int, subindex: int = 0, num_elements: int = 1) bytes

Reads a PNU from the EDrive without interpreting the data

read_pnu(pnu: int, subindex: int = 0, forced_format=None) Any

Reads a PNU from the EDrive

write_pnu_raw(pnu: int, subindex: int = 0, num_elements: int = 1, value: bytes = b'\x00') bool

Writes raw bytes to a PNU on the EDrive

write_pnu(pnu: int, subindex: int = 0, value: Any = 0, forced_format=None) bool

Writes a value to a PNU to the EDrive

io_active()

Provides information about connection status.

start_io()

Configures and starts i/o data process

stop_io()

Stops i/o data process

send_io(data: bytes, nonblocking: bool = False)

Sends data to the output

Parameters:

nonblocking (bool) – If True, tasks returns immediately after starting the task. Otherwise function awaits for finish (or fault).

recv_io(nonblocking: bool = False) bytes

Receives data from the input

Parameters:

nonblocking (bool) – If True, tasks returns immediately after starting the task. Otherwise function awaits for finish (or fault).

edcon.edrive.com_ethernetip module

Contains ComEthernetip class to configure and communicate with EDrive devices.

This implementation uses the python-ethernetip library by Sebastian Block (https://codeberg.org/paperwork/python-ethernetip)

class edcon.edrive.com_ethernetip.EtherNetIPSingleton

Bases: object

Class to lazyly create an EtherNet/IP singleton object.

classmethod get_instance()

If no instace exists yet, create one. Returns instance.

class edcon.edrive.com_ethernetip.ComEthernetip(ip_address, cycle_time: int = 10)

Bases: ComBase

Class to configure and communicate with EDrive devices via EtherNet/IP.

Constructor of the ComEthernetip class.

Parameters:
  • ip_address (str) – Required IP address as string e.g. (‘192.168.0.1’)

  • cycle_time (int) – Cycle time (in ms) that should be used for I/O transfers

shutdown()

Tries stop the communication thread and closes the modbus connection

read_pnu_raw(pnu: int, subindex: int = 0, num_elements: int = 1) bytes

Reads a PNU from the EDrive without interpreting the data

write_pnu_raw(pnu: int, subindex: int = 0, num_elements: int = 1, value: bytes = b'\x00') bool

Writes raw bytes to a PNU on the EDrive

io_active()

Provides information about connection status.

start_io()

Configures and starts i/o data process

stop_io()

Stops i/o data process

send_io(data: bytes, nonblocking: bool = False)

Sends data to the output

Parameters:

nonblocking (bool) – If True, function returns immediately. Otherwise function awaits I/O thread to be executed.

recv_io(nonblocking: bool = False) bytes

Receives data from the input

Parameters:

nonblocking (bool) – If True, function returns immediately. Otherwise function awaits I/O thread to be executed.

edcon.edrive.com_modbus module

Contains ComModbus class to configure and communicate with EDrive devices.

This implementation uses the pymodbus library https://pymodbus.readthedocs.io/en/latest/index.html

class edcon.edrive.com_modbus.IOThread(perform_io=None, cycle_time: int = 10)

Bases: Thread

Class to handle I/O transfers in a separate thread.

Constructor of the IOThread class.

Parameters:
  • perform_io (function) – function that is called periodically (with interval cycle_time) and performs the I/O data transfer

  • cycle_time (int) – Cycle time (in ms) that should be used for I/O transfers

run()

Method that needs to be implemented by child.

start()

Starts the thread.

stop()

Stops the thread.

class edcon.edrive.com_modbus.ComModbus(ip_address, cycle_time: int = 10, timeout_ms: int = 1000)

Bases: ComBase

Class to configure and communicate with EDrive devices via Modbus.

Constructor of the ComModbus class.

Parameters:
  • ip_address (str) – Required IP address as string e.g. (‘192.168.0.1’)

  • cycle_time (int) – Cycle time (in ms) that should be used for I/O transfers

  • timeout_ms (int) – Modbus timeout (in ms) that should be configured on the slave

shutdown()

Tries stop the communication thread and closes the modbus connection

connected()

Provides information about connection status.

read_device_info() dict

Reads device info from the CMMT and returns dict with containing values

Returns:

Contains device information values

Return type:

dict

set_timeout(timeout_ms) bool

Sets the modbus timeout to the provided value

perform_io()

Reads input data from and writes output data to according modbus registers.

read_pnu_raw(pnu: int, subindex: int = 0, num_elements: int = 1) bytes

Reads a PNU from the EDrive without interpreting the data

write_pnu_raw(pnu: int, subindex: int = 0, num_elements: int = 1, value: bytes = b'\x00') bool

Writes raw bytes to a PNU on the EDrive

io_active()

Provides information about connection status.

start_io()

Starts i/o data process

stop_io()

Stops i/o data process

send_io(data: bytes, nonblocking: bool = False)

Sends data to the output

Parameters:

nonblocking (bool) – If True, function returns immediately. Otherwise function awaits I/O thread to be executed.

recv_io(nonblocking: bool = False) bytes

Receives data from the input

Parameters:

nonblocking (bool) – If True, function returns immediately. Otherwise function awaits I/O thread to be executed.

edcon.edrive.diagnosis module

Contains functions which provide corresponding name and remedy of ICP numbers.

edcon.edrive.diagnosis.read_icp_map_file(icp_map_file: str = None)

Creates a dict based on a provided ICP name map file

Parameters:

icp_map_file (str) – Optional file to use for mapping. If nothing provided try to load mapping shipped with package.

Returns:

With the first column values as keys and namedtuple values

Return type:

dict

edcon.edrive.diagnosis.diagnosis_name(icp_number: int, icp_map_file: str | None = None) str
Determines the corresponding name to a provided icp_number, can be

determined either via a provided icp_map_file or by the icp_map_file shipped with the package.

Parameters:
  • icp_number (int) – ICP number whose name should be determined.

  • icp_map_file (str) – Optional file name for icp_map. By default installed icp_map file is used.

Returns:

Name of corresponding ICP

Return type:

value

edcon.edrive.diagnosis.diagnosis_remedy(icp_number: int, icp_map_file: str | None = None) list
Determines the corresponding remedies to a provided icp_number, can be

determined either via a provided icp_map_file or by the icp_map_file shipped with the package.

Parameters:
  • icp_number (int) – ICP number whose remedy should be determined.

  • icp_map_file (str) – Optional file name for icp_map. By default installed icp_map file is used.

Returns:

List of str containing potential remedies for the corresponding ICP

Return type:

value

edcon.edrive.motion_handler module

Contains MotionHandler class to configure and control EDrive devices in position mode.

class edcon.edrive.motion_handler.MotionHandler(com: ComBase | None = None, config_mode=None)

Bases: Telegram111Handler

This class is used to control the EDrive devices in position mode (telegram 111). It provides a set of functions to control the position of the EDrive using different modes.

property over_v

Override velocity in percent

property over_acc

Override acceleration in percent

property over_dec

Override deceleration in percent

current_velocity()

Velocity scaled according to base velocity

Returns:

In order to get the correct velocity,

base_velocity (default: 3000.0) needs to be provided.

Output is calculated as follows:

base_velocity = Base Value Velocity (parameterized on device) raw_value = telegram.nist_b

current_velocity = raw_value * base_velocity / 0x40000000.

Return type:

int/float

edcon.edrive.parameter module

Contains Parameter class which is used to represent a parameter of EDrives.

class edcon.edrive.parameter.Parameter(axis: int, data_id: int, instance: int, subindex: int, value_raw: bytes)

Bases: object

Class representing a parameter.

axis: int
data_id: int
instance: int
subindex: int
value_raw: bytes
classmethod from_uid(uid: str, value: Any)

Function to create a Parameter by providing a uid and value.

Parameters:
  • uid (str) – uid of the parameter

  • value (Any) – value of the parameter

Returns:

Parameter object

classmethod from_uid_raw(uid: str, value_raw: bytes)

Function to create a Parameter by providing a uid and value.

Parameters:
  • uid (str) – uid of the parameter

  • value_raw (bytes) – value of the parameter

Returns:

Parameter object

property value: Any

Returns the value of the parameter.

Returns:

Value in correct data type

Return type:

Any

uid() str

Returns the uid of the parameter.

Returns:

uid

Return type:

str

edcon.edrive.parameter_handler module

Contains ParameterSet class which is used to represent parameter sets of EDrives.

class edcon.edrive.parameter_handler.ParameterHandler(com: ComBase)

Bases: object

Class for parameter handling activities.

validate(parameter_uid: str, value: Any) bool

Asserts that the provided pnu is actually configured

read(parameter_uid: str, subindex: int = 0)

Read value from parameter_uid

write(parameter: Parameter) bool

Write value to parameter_uid

edcon.edrive.parameter_mapping module

Contains functions which provide mapping of PNU types.

edcon.edrive.parameter_mapping.read_pnu_map_file(pnu_map_file: str = None) list

Creates a list of PNU map items based on a provided PNU type map file

Parameters:

pnu_map_file (str) – Optional file to use for mapping. If nothing provided try to load mapping shipped with package.

Returns:

Containing PNU map items with fieldnames created from the header pnu_map_file.

Return type:

list

edcon.edrive.parameter_mapping.create_pnu_map() dict
Creates a dict based on a provided PNU map item list.

It maps PNU ids to provided PNU map items

Returns:

PNU ids (key) and PNU items (value)

Return type:

dict

edcon.edrive.parameter_mapping.create_parameter_map() dict
Creates a dict based on a provided PNU map item list.

It maps parameter ids to provided PNU map items

Returns:

parameter ids (key) and PNU items (value)

Return type:

dict

class edcon.edrive.parameter_mapping.PnuMap

Bases: object

Class that provides a mapping from PNU to pnu_map_item.

class edcon.edrive.parameter_mapping.ParameterMap

Bases: object

Class that provides a mapping from parameter id to pnu_map_item.

sanitize_parameter_id(parameter_id)

Sanitizes the provided parameter_id by removing unwanted characters.

Parameters:

parameter_id (str) – Parameter id of the PNU type to be sanitized.

Returns:

sanitized parameter_id

Return type:

value

edcon.edrive.parameter_set module

Contains ParameterSet class which is used to represent parameter sets of EDrives.

class edcon.edrive.parameter_set.ParameterSet(parameterset_file, strip_null_terminators=True)

Bases: object

Class representing a parameter set.

strip_null_terminators()

Removes all parameters from the parameter set that represent null terminators.

edcon.edrive.pnu_packing module

Contains functions which provide mapping of PNU types.

edcon.edrive.pnu_packing.pnu_unpack(pnu: int, raw: bytes, forced_format: str | None = None) Any
Unpacks a raw byte value to specific type.

The type is determined by the pnu_map_file shipped with the package.

Parameters:
  • pnu (int) – PNU number of value that should be unpacked.

  • raw (bytes) – Raw bytes value that should be unpacked.

  • forced_format (str) – Optional format char (see struct) to force the unpacking strategy.

Returns:

Unpacked value with determined type

Return type:

value

edcon.edrive.pnu_packing.pnu_pack(pnu: int, value: Any, forced_format: str | None = None) bytes
Packs a provided value to raw bytes object.

The type is determined by the pnu_map_file shipped with the package.

Parameters:
  • pnu (int) – PNU number of value that should be unpacked.

  • value – Value that should be packed.

  • forced_format (str) – Optional format char (see struct) to force the packing strategy.

Returns:

Packed value

Return type:

bytes

edcon.edrive.position_telegram_handler module

Class definition containing position telegram execution functions.

class edcon.edrive.position_telegram_handler.PositionTelegramHandler(telegram, com)

Bases: TelegramHandler

Basic class for executing position telegrams.

position_info_string()

Returns string containing position information

Returns:

String containing position information

Return type:

str

velocity_info_string()

Returns string containing velocity information

Returns:

String containing velocity information

Return type:

str

configure_traversing_to_fixed_stop(active: bool)

Configures the traversing to fixed stop option (drive maintains parametrized torque)

Parameters:

active (bool) – True => activate fixed stop traveling, False => deactivate

referenced()

Gives information if drive is referenced

Returns:

True if drive home position is set, False otherwise

Return type:

bool

target_position_reached()

Gives information if drive has reached target position

Returns:

True if drive target position is reached, False otherwise

Return type:

bool

stopped()

Gives information if drive is stopped

Returns:

True if drive is stopped, False otherwise

Return type:

bool

wait_for_referencing_task_ack() bool

Waits for drive to be referenced

Returns:

True if succesful, False otherwise

Return type:

bool

wait_for_home_position_set() bool

Waits for drive to be referenced

Returns:

True if succesful, False otherwise

Return type:

bool

wait_for_traversing_task_ack() bool

Waits for drive to be referenced

Returns:

True if succesful, False otherwise

Return type:

bool

wait_for_target_position() bool

Waits for target position to be reached

Returns:

True if succesful, False otherwise

Return type:

bool

wait_for_stop() bool

Waits for target position to be reached

Returns:

True if succesful, False otherwise

Return type:

bool

wait_for_referencing_execution() bool

Waits for referencing to be finished

Returns:

True if succesful, False otherwise

Return type:

bool

wait_for_position_motion_execution() bool

Waits for position motion to be finished

Returns:

True if succesful, False otherwise

Return type:

bool

trigger_record_change()

Triggers the change to the next record of the record sequence

stop_motion_task()

Stops any currently active motion task

pause_motion_task()

Pauses any currently active motion task

resume_motion_task()

Resumes any currently active motion task

referencing_task(nonblocking: bool = False) bool

Perform the referencing sequence. If successful, the drive is referenced afterwards.

Parameters:

nonblocking (bool) – If True, tasks returns immediately after starting the task. Otherwise function awaits for finish (or fault).

Returns:

True if succesful, False otherwise

Return type:

bool

position_task(position: int, velocity: int, absolute: bool = False, nonblocking: bool = False) bool

Perform a position task with the given parameters

Parameters:
  • position (int) – position setpoint in user units (depends on parametrization)

  • velocity (int) – velocity setpoint in user units (depends on parametrization)

  • absolute (bool) – If true, position is considered absolute, otherwise relative to starting position

  • nonblocking (bool) – If True, tasks returns immediately after starting the task. Otherwise function awaits for finish (or fault).

Returns:

True if succesful, False otherwise

Return type:

bool

jog_task(jog_positive: bool = True, jog_negative: bool = False, incremental: bool = False, duration: float = 0.0) bool
Perform a jogging task with a given duration.

Please note that the jogging motion stops if jog_positive and jog_negative are equal.

Parameters:
  • jog_positive (bool) – If true, jog in positive direction.

  • jog_negative (bool) – If true, jog in negative direction.

  • duration (float) – Optional duration in seconds. A duration of 0 starts the task and returns immediately.

Returns:

True if succesful, False otherwise

Return type:

bool

edcon.edrive.telegram102_handler module

Class definition containing telegram 102 execution functions.

class edcon.edrive.telegram102_handler.Telegram102Handler(com, config_mode=None)

Bases: VelocityTelegramHandler

Basic class for executing telegram 102.

Parameters:
  • com (ComBase) – communication driver

  • config_mode (str) – configuration mode (None, “write”, “validate”)

velocity_info_string() str

Returns string containing velocity information

Returns:

String containing velocity information

Return type:

str

edcon.edrive.telegram111_handler module

Class definition containing telegram 111 execution functions.

class edcon.edrive.telegram111_handler.Telegram111Handler(com, config_mode=None)

Bases: PositionTelegramHandler

Basic class for executing telegram 111.

Parameters:
  • com (ComBase) – communication driver

  • config_mode (str) – configuration mode (None, “write”, “validate”)

fault_string() str

Returns string containing fault reason

Returns:

String containing the fault reason

Return type:

str

configure_hardware_limit_switch(active: bool)

Configures the hardware limit switch

Parameters:

active (bool) – True => activate limit, False => deactivate limit

configure_software_limit_switch(active: bool)

Configures the software limit switch

Parameters:

active (bool) – True => activate limit, False => deactivate limit

configure_measuring_probe(falling_edge: bool = False, measuring_probe: str = 'first')

Configures the measuring probes. Be aware that only one probe is configurable simultaneously. In order to configure both probes:

  1. Configure probe ‘first’

  2. Send using update_outputs()

  3. Configure probe ‘second’

Parameters:
  • falling_edge (bool) – Determines whether to trigger on rising or falling edge

  • measuring_probe (str) – One of [‘first’, ‘second’], determines the probe to configure

configure_continuous_update(active: bool)

Configures the continuous update option i.e. setpoints are immediately updated without need of starting a new traversing task

Parameters:

active (bool) – True => activate continuous update, False => deactivate continuous update

configure_tracking_mode(active: bool)

Configures the tracking mode i.e. setpoint continuously tracks the current value

Parameters:

active (bool) – True => activate tracking mode, False => deactivate tracking mode

fix_stop_reached()

Gives information if drive has reached fix stop

Returns:

True if drive is at fix stop, False otherwise

Return type:

bool

clamping_torque_reached()

Gives information if drive has reached clamping torque

Returns:

True if drive torque reached the clamping torque, False otherwise

Return type:

bool

current_position()

Read the current position

Returns:

Current position in user units

Return type:

int

current_fault_code() int

Read the current fault code position

Returns:

Current fault code

Return type:

int

await_fault_code(timeout=0.5)

Waits for fault code to be available and produces log afterwards.

Returns:

True if succesful, False otherwise

Return type:

bool

wait_for_referencing_task_ack() bool

Waits for drive to be referenced

Returns:

True if succesful, False otherwise

Return type:

bool

set_current_position_task(nonblocking: bool = False) bool

Perform the referencing sequence. If successful, the drive is referenced afterwards.

Parameters:

nonblocking (bool) – If True, tasks returns immediately after starting the task. Otherwise function awaits for finish (or fault).

Returns:

True if succesful, False otherwise

Return type:

bool

velocity_task(velocity: int, duration: float = 0.0) bool

Perform a velocity task with the given parameters using setup mode.

Parameters:
  • velocity (int) – velocity setpoint in user units (depends on parametrization). The sign determines the direction of the motion.

  • duration (float) – Optional duration in seconds. A duration of 0 starts the task and returns immediately.

Returns:

True if succesful, False otherwise

Return type:

bool

record_task(record_number: int, nonblocking: bool = True) bool

Perform a preconfigured record task by providing the corresponding record number

Parameters:
  • record_number (int) – The record number determining the record table entry that should be executed.

  • nonblocking (bool) – If True, tasks returns immediately after starting the task. Otherwise function awaits for finish (or fault).

Returns:

True if succesful, False otherwise

Return type:

bool

edcon.edrive.telegram1_handler module

Class definition containing telegram 1 execution functions.

class edcon.edrive.telegram1_handler.Telegram1Handler(com, config_mode=None)

Bases: VelocityTelegramHandler

Basic class for executing telegram 1.

Parameters:
  • com (ComBase) – communication driver

  • config_mode (str) – configuration mode (None, “write”, “validate”)

velocity_info_string() str

Returns string containing velocity information

Returns:

String containing velocity information

Return type:

str

edcon.edrive.telegram9_handler module

Class definition containing telegram 9 execution functions.

class edcon.edrive.telegram9_handler.Telegram9Handler(com, config_mode=None)

Bases: PositionTelegramHandler

Basic class for executing telegram 9.

Parameters:
  • com (ComBase) – communication driver

  • config_mode (str) – configuration mode (None, “write”, “validate”)

edcon.edrive.telegram_handler module

Class definition containing generic telegram execution functions.

class edcon.edrive.telegram_handler.TelegramHandler(telegram, com)

Bases: object

Basic class for executing telegrams.

shutdown()

Tries to disable the powerstage and stops the communication thread

update_inputs()

Reads current input process data and updates telegram

update_outputs()

Writes current telegram value to output process data

update_io()

Updates process data in both directions (I/O)

wait_until_or_fault(cond, timeout: float = 0.0, info_string: Callable[[], str] | None = None)

Waits for condition to be met until fault is present.

wait_until_or_not_operational(cond, timeout: float = 0.0, info_string: Callable[[], str] | None = None)

Waits for condition to be met until not_operational is present.

fault_string() str

Returns string containing fault reason

Returns:

String containing the fault reason

Return type:

str

fault_present() bool

Gives information whether a fault is present

Returns:

True if fault presens, False otherwise

Return type:

bool

not_operational() bool

Gives information whether a fault is present

Returns:

True if fault present, False otherwise

Return type:

bool

plc_control_granted() bool

Gives information if PLC control is granted

Returns:

True if succesful, False otherwise

Return type:

bool

ready_for_motion()

Gives information if motion tasks can be started

Returns:

True if drive is ready for motion tasks, False otherwise

Return type:

bool

configure_coast_stop(active: bool)

Configures the coast stop option

Parameters:

active (bool) – True => activate coasting, False => deactivate coasting

configure_quick_stop(active: bool)

Configures the quick stop option

Parameters:

active (bool) – True => activate quick stop, False => deactivate quick stop

configure_brake(active: bool)

Configures the holding brake

Parameters:

active (bool) – True => activate brake, False => release brake

acknowledge_faults(timeout: float = 5.0) bool

Send telegram to acknowledge present faults of the EDrive

Parameter:

timeout (float): time that should be waited for acknowledgement

Returns:

True if succesful, False otherwise

Return type:

bool

enable_powerstage(timeout: float = 10.0) bool

Send telegram to enable the power stage

Parameter:

timeout (float): time that should be waited for enabling

Returns:

True if succesful, False otherwise

Return type:

bool

disable_powerstage(timeout: float = 5.0) bool

Send telegram to disable the power stage

edcon.edrive.velocity_telegram_handler module

Class definition containing velocity telegram execution functions.

class edcon.edrive.velocity_telegram_handler.VelocityTelegramHandler(telegram, com)

Bases: TelegramHandler

Basic class for executing velocity telegrams.

velocity_info_string() str

Returns string containing velocity information

Returns:

String containing velocity information

Return type:

str

stop_motion_task()

Stops any currently active motion task

velocity_task(velocity: int, duration: float = 0.0) bool

Perform a velocity task with the given parameters using setup mode.

Parameters:
  • velocity (int) – velocity setpoint in user units (depends on parametrization). The sign determines the direction of the motion.

  • duration (float) – Optional duration in seconds. A duration of 0 starts the task and returns immediately.

Returns:

True if succesful, False otherwise

Return type:

bool

Module contents