Servo

class ingenialink.canopen.servo.CanopenServo(target, node, dictionary_path=None, eds=None, servo_status_listener=False)[source]

CANopen Servo instance.

Parameters
  • node (canopen.RemoteNode) – Remote Node of the drive.

  • dictionary_path (str) – Path to the dictionary.

  • servo_status_listener (bool) – Boolean to initialize the ServoStatusListener and check the drive status.

disable(subnode=1, timeout=1000)[source]

Disable PDS.

Parameters
  • subnode (int) – Subnode of the drive.

  • timeout (int) – Timeout in milliseconds.

Raises
disturbance_disable()[source]

Disable disturbance process.

disturbance_enable()[source]

Enable disturbance process.

disturbance_get_num_mapped_registers()[source]

Obtain the number of disturbance mapped registers.

Returns

Actual number of mapped registers.

Return type

int

disturbance_remove_all_mapped_registers()[source]

Remove all disturbance mapped registers.

disturbance_remove_data()[source]

Remove disturbance data.

disturbance_set_mapped_register(channel, address, subnode, dtype, size)[source]

Set monitoring mapped register.

Parameters
  • channel (int) – Identity channel number.

  • address (int) – Register address to map.

  • subnode (int) – Subnode to be targeted.

  • dtype (int) – Register data type.

  • size (int) – Size of data in bytes.

disturbance_write_data(channels, dtypes, data_arr)[source]

Write disturbance data.

Parameters
  • channels (int or list of int) – Channel identifier.

  • dtypes (int or list of int) – Data type.

  • data_arr (list or list of list) – Data array.

emcy_subscribe(cb)[source]

Subscribe to emergency messages.

Parameters

cb – Callback

Returns

Assigned slot.

Return type

int

emcy_unsubscribe(slot)[source]

Unsubscribe from emergency messages.

Parameters

slot (int) – Assigned slot when subscribed.

enable(subnode=1, timeout=1000)[source]

Enable PDS.

Args:

subnode (int): Subnode of the drive. timeout (int): Timeout in milliseconds.

Raises
fault_reset(subnode=1, timeout=1000)[source]

Executes a fault reset on the drive.

Parameters
  • subnode (int) – Subnode of the drive.

  • timeout (int) – Timeout in milliseconds.

Raises
get_state(subnode=1)[source]

SERVO_STATE: Current drive state.

is_alive()[source]

Checks if the servo responds to a reading a register.

Returns

Return code with the result of the read.

Return type

bool

load_configuration(config_file, subnode=None)[source]

Write current dictionary storage to the servo drive.

Parameters
  • config_file (str) – Path to the dictionary.

  • subnode (int) – 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.

monitoring_actual_number_bytes()[source]

Get the number of monitoring bytes left to be read.

monitoring_channel_data(channel, dtype=None)[source]

Obtain processed monitoring data of a channel.

Parameters
  • channel (int) – Identity channel number.

  • dtype (REG_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.

Return type

List

monitoring_disable()[source]

Disable monitoring process.

monitoring_enable()[source]

Enable monitoring process.

monitoring_get_bytes_per_block()[source]

Obtain Bytes x Block configured.

Returns

Actual number of Bytes x Block configured.

Return type

int

monitoring_get_num_mapped_registers()[source]

Obtain the number of monitoring mapped registers.

Returns

Actual number of mapped registers.

Return type

int

monitoring_read_data()[source]

Obtain processed monitoring data.

Returns

Actual processed monitoring data.

Return type

array

monitoring_remove_all_mapped_registers()[source]

Remove all monitoring mapped registers.

monitoring_remove_data()[source]

Remove monitoring data.

monitoring_set_mapped_register(channel, address, subnode, dtype, size)[source]

Set monitoring mapped register.

Parameters
  • channel (int) – Identity channel number.

  • address (int) – Register address to map.

  • subnode (int) – Subnode to be targeted.

  • dtype (int) – Register data type.

  • size (int) – Size of data in bytes.

read(reg, subnode=1)[source]

Read from servo.

Parameters

reg (str, Register) – Register.

Returns

Error code of the read operation.

Return type

int

Raises
  • TypeError – If the register type is not valid.

  • ILAccessError – Wrong access to the register.

  • ILIOError – Error reading the register.

reload_errors(dictionary)[source]

Force to reload all dictionary errors.

Parameters

dictionary (str) – Dictionary.

replace_dictionary(dictionary)[source]

Deletes and creates a new instance of the dictionary.

Parameters

dictionary (str) – Dictionary.

restore_parameters(subnode=None)[source]

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 (int) – Subnode of the axis. None by default which restores

  • the parameters. (all) –

Raises
save_configuration(config_file, subnode=None)[source]

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

Parameters
  • config_file (str) – Destination path for the configuration file.

  • subnode (int) – Subnode of the axis.

start_status_listener()[source]

Start listening for servo status events (SERVO_STATE).

static status_word_decode(status_word)[source]

Decodes the status word to a known value.

Parameters

status_word (int) – Read value for the status word.

Returns

Status word value.

Return type

SERVO_STATE

status_word_wait_change(status_word, timeout, subnode=1)[source]

Waits for a status word change.

Parameters
  • status_word (int) – Status word to wait for.

  • timeout (int) – Maximum value to wait for the change.

  • subnode (int) – Subnode of the drive.

Returns

Error code.

Return type

int

stop_status_listener()[source]

Stop listening for servo status events (SERVO_STATE).

store_parameters(subnode=None, sdo_timeout=3)[source]

Store all the current parameters of the target subnode.

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

  • the parameters. (all) –

  • sdo_timeout (int) – Timeout value for each SDO response.

Raises
subscribe_to_status(callback)[source]

Subscribe to state changes.

Parameters

callback (function) – Callback function.

Returns

Assigned slot.

Return type

int

unsubscribe_from_status(callback)[source]

Unsubscribe from state changes.

Parameters

callback (function) – Callback function.

write(reg, data, subnode=1)[source]

Writes a data to a target register.

Parameters
  • reg (CanopenRegister, str) – Target register to be written.

  • data (int, str, float) – Data to be written.

  • subnode (int) – Target axis of the drive.

Raises
property dictionary

Returns dictionary object

property disturbance_data

Obtain disturbance data.

Returns

Current disturbance data.

Return type

array

property disturbance_data_size

Obtain disturbance data size.

Returns

Current disturbance data size.

Return type

int

property disturbance_number_mapped_registers

Get the number of mapped disturbance registers.

property errors

Errors.

Type

dict

property full_name

Drive full name.

Type

str

property info

Servo information.

Type

dict

property monitoring_data_size

Obtain monitoring data size.

Returns

Current monitoring data size in bytes.

Return type

int

property monitoring_number_mapped_registers

Get the number of mapped monitoring registers.

name

Obtains the servo name.

Type

str

property node

Remote node of the servo.

Type

canopen.RemoteNode

property status

Servo status and state flags.

Type

tuple

property subnodes

Number of subnodes.

Type

int

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.canopen.servo.ServoStatusListener(servo)[source]

Reads the status word to check if the drive is alive.

Parameters

servo (CanopenServo) – Servo instance of the drive.

run()[source]

Checks if the drive is alive by reading the status word register

stop()[source]

Stops the loop that reads the status word register