Servo

class ingenialink.ethercat.servo.EthercatServo(slave: CdefSlave, slave_id: int, dictionary_path: str, connection_timeout: float, servo_status_listener: bool = False)[source]

Ethercat Servo instance.

Parameters
  • slave – Slave to be connected.

  • slave_id – Slave ID.

  • dictionary_path – Path to the dictionary.

  • connection_timeout – Time in seconds of the connection timeout.

  • servo_status_listener – Toggle the listener of the servo for its status, errors, faults, etc.

Raises

ImportError – WinPcap is not installed

disable(subnode: int = 1, timeout: int = 1000)None

Disable PDS.

Parameters
  • subnode – Subnode of the drive.

  • timeout – Timeout in milliseconds.

Raises
disturbance_disable()None

Disable disturbance process.

disturbance_enable()None

Enable disturbance process.

disturbance_get_num_mapped_registers()int

Obtain the number of disturbance mapped registers.

Returns

Actual number of mapped registers.

disturbance_remove_all_mapped_registers()None

Remove all disturbance mapped registers.

disturbance_remove_data()None

Remove disturbance data.

disturbance_set_mapped_register(channel: int, address: int, subnode: int, dtype: int, size: int)None

Set monitoring mapped register.

Parameters
  • channel – Identity channel number.

  • address – Register address to map.

  • subnode – Subnode to be targeted.

  • dtype – Register data type.

  • size – Size of data in bytes.

disturbance_write_data(channels: Union[int, List[int]], dtypes: Union[ingenialink.enums.register.REG_DTYPE, List[ingenialink.enums.register.REG_DTYPE]], data_arr: Union[List[Union[int, float]], List[List[Union[int, float]]]])None

Write disturbance data.

Parameters
  • channels – Channel identifier.

  • dtypes – Data type.

  • data_arr – Data array.

enable(subnode: int = 1, timeout: int = 1000)None

Enable PDS.

Args:

subnode: Subnode of the drive. timeout: Timeout in milliseconds.

Raises
fault_reset(subnode: int = 1, timeout: int = 1000)None

Executes a fault reset on the drive.

Parameters
  • subnode – Subnode of the drive.

  • timeout – Timeout in milliseconds.

Raises
generate_pdo_outputs()None[source]

Process the PDO outputs.

It should call _process_tpdo method using the received bytes as argument.

get_state(subnode: int = 1)ingenialink.enums.servo.SERVO_STATE

Current drive state.

is_alive()bool

Checks if the servo responds to a reading a register.

Returns

Return code with the result of the read.

is_listener_started()bool

Check if servo listener is started

Returns

True if listener is started, else False

load_configuration(config_file: str, subnode: Optional[int] = None)None

Write current dictionary storage to the servo drive.

Parameters
  • config_file – Path to the dictionary.

  • subnode – Subnode of the axis.

Raises
  • FileNotFoundError – If the configuration file cannot be found.

  • ValueError – If a configuration file from a subnode different from 0 is attempted to be loaded to subnode 0.

  • ValueError – If an invalid subnode is provided.

map_pdos(slave_index: int)None

Map RPDO and TPDO register into the slave.

Parameters

slave_index – salve index.

map_rpdos()None

Map the RPDO registers into the servo slave. It takes the first available RPDO assignment slot of the slave.

Raises

ILError – If there are no available PDOs.

map_tpdos()None

Map the TPDO registers into the servo slave. It takes the first available TPDO assignment slot of the slave.

Raises

ILError – If there are no available PDOs.

monitoring_actual_number_bytes()int

Get the number of monitoring bytes left to be read.

monitoring_channel_data(channel: int, dtype: Optional[ingenialink.enums.register.REG_DTYPE] = None)List[float]

Obtain processed monitoring data of a channel.

Parameters
  • channel – Identity channel number.

  • dtype – Data type of the register to map.

Note

The dtype argument is not necessary for this function, it was added to maintain compatibility with IPB’s implementation of monitoring.

Returns

Monitoring data.

monitoring_disable()None

Disable monitoring process.

monitoring_enable()None

Enable monitoring process.

monitoring_get_bytes_per_block()int

Obtain Bytes x Block configured.

Returns

Actual number of Bytes x Block configured.

monitoring_get_num_mapped_registers()int

Obtain the number of monitoring mapped registers.

Returns

Actual number of mapped registers.

monitoring_read_data()None

Obtain processed monitoring data.

Returns

Actual processed monitoring data.

monitoring_remove_all_mapped_registers()None

Remove all monitoring mapped registers.

monitoring_remove_data()None

Remove monitoring data.

monitoring_set_mapped_register(channel: int, address: int, subnode: int, dtype: int, size: int)None

Set monitoring mapped register.

Parameters
  • channel – Identity channel number.

  • address – Register address to map.

  • subnode – Subnode to be targeted.

  • dtype – Register data type.

  • size – Size of data in bytes.

process_pdo_inputs()None[source]

Process the PDO inputs.

It should call _process_rpdo method to obtain the bytes to be sent to the slave.

read(reg: Union[str, ingenialink.register.Register], subnode: int = 1, **kwargs: Any)Union[int, float, str, bytes]

Read a register value from servo.

Parameters
  • reg – Register.

  • subnode – Target axis of the drive.

Returns

int, float or Value stored in the register.

Raises
reload_errors(dictionary: str)None

Force to reload all dictionary errors.

Parameters

Dictionary.

remove_rpdo_map(rpdo_map: Optional[ingenialink.pdo.RPDOMap] = None, rpdo_map_index: Optional[int] = None)None

Remove a RPDOMap from the RPDOMap list.

Parameters
  • rpdo_map – The RPDOMap instance to be removed.

  • rpdo_map_index – The index of the RPDOMap list to be removed.

Raises
  • ValueError – If the RPDOMap instance is not in the RPDOMap list.

  • IndexError – If the index is out of range.

remove_tpdo_map(tpdo_map: Optional[ingenialink.pdo.TPDOMap] = None, tpdo_map_index: Optional[int] = None)None

Remove a TPDOMap from the TPDOMap list.

Parameters
  • tpdo_map – The TPDOMap instance to be removed.

  • tpdo_map_index – The index of the TPDOMap list to be removed.

Raises
  • ValueError – If the TPDOMap instance is not in the TPDOMap list.

  • IndexError – If the index is out of range.

replace_dictionary(dictionary: str)None

Deletes and creates a new instance of the dictionary.

Parameters

dictionary – Path to the dictionary.

reset_pdo_mapping()None

Reset the RPDO and TPDO mapping in the slave.

reset_rpdo_mapping()None

Delete the RPDO mapping stored in the servo slave.

reset_tpdo_mapping()None

Delete the TPDO mapping stored in the servo slave.

restore_parameters(subnode: Optional[int] = None)None

Restore all the current parameters of all the slave to default.

Note

The drive needs a power cycle after this in order for the changes to be properly applied.

Parameters

subnode – Subnode of the axis. None by default which restores all the parameters.

Raises
save_configuration(config_file: str, subnode: Optional[int] = None)None

Read all dictionary registers content and put it to the dictionary storage.

Parameters
  • config_file – Destination path for the configuration file.

  • subnode – Subnode of the axis.

set_pdo_map_to_slave(rpdo_maps: List[ingenialink.pdo.RPDOMap], tpdo_maps: List[ingenialink.pdo.TPDOMap])None[source]

Callback called by the slave to configure the map.

Parameters
  • rpdo_maps – List of RPDO maps.

  • tpdo_maps – List of TPDO maps.

set_pdo_watchdog_time(timeout: float)None[source]

Set the process data watchdog time.

Parameters

timeout – Time in seconds.

start_status_listener()None

Start listening for servo status events (SERVO_STATE).

state_wait_change(state: ingenialink.enums.servo.SERVO_STATE, timeout: int, subnode: int = 1)ingenialink.enums.servo.SERVO_STATE

Waits for a state change.

Parameters
  • state – Servo state before calling this function.

  • timeout – Maximum value to wait for the change.

  • subnode – Subnode of the drive.

Returns

The last read state.

Raises

ILTimeoutError – If state does not change in the given time.

static status_word_decode(status_word: int)ingenialink.enums.servo.SERVO_STATE

Decodes the status word to a known value.

Parameters

status_word – Read value for the status word.

Returns

Status word value.

status_word_wait_change(status_word: int, timeout: int, subnode: int = 1)None

Waits for a status word change.

Parameters
  • status_word – Status word to wait for.

  • timeout – Maximum value to wait for the change.

  • subnode – Subnode of the drive.

Raises

ILTimeoutError – If status word does not change in the given time.

stop_status_listener()None

Stop listening for servo status events (SERVO_STATE).

store_parameters(subnode: Optional[int] = None)None

Store all the current parameters of the target subnode.

Parameters
  • subnode – Subnode of the axis. None by default which stores

  • the parameters. (all) –

Raises
subscribe_to_status(callback: Callable[[ingenialink.enums.servo.SERVO_STATE, None, int], Any])None

Subscribe to state changes.

Parameters

callback – Callback function.

Returns

Assigned slot.

unsubscribe_from_status(callback: Callable[[ingenialink.enums.servo.SERVO_STATE, None, int], Any])None

Unsubscribe from state changes.

Parameters

function. (Callback) –

write(reg: Union[str, ingenialink.register.Register], data: Union[int, float, str, bytes], subnode: int = 1, **kwargs: Any)None

Writes a data to a target register.

Parameters
  • reg – Target register to be written.

  • data – Data to be written.

  • subnode – Target axis of the drive.

Raises
property dictionary

Returns dictionary object

property disturbance_data

Obtain disturbance data.

Returns

Current disturbance data.

property disturbance_data_size

Obtain disturbance data size.

Returns

Current disturbance data size.

property disturbance_number_mapped_registers

Get the number of mapped disturbance registers.

property errors

Errors.

property full_name

Drive full name.

property info

Servo information.

property monitoring_data_size

Obtain monitoring data size.

Returns

Current monitoring data size in bytes.

property monitoring_number_mapped_registers

Get the number of mapped monitoring registers.

property slave

Ethercat slave

property status

Servo status.

property subnodes

Dictionary of subnode ids and their type

units_acc

Acceleration units.

Type

SERVO_UNITS_ACC

units_pos

Position units.

Type

SERVO_UNITS_POS

units_torque

Torque units.

Type

SERVO_UNITS_TORQUE

units_vel

Velocity units.

Type

SERVO_UNITS_VEL

class ingenialink.ethercat.servo.SDO_OPERATION_MSG(value)[source]

Message for exceptions depending on the operation type.