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
ILTimeoutError – The servo could not be disabled due to timeout.
ILError – Failed to disable PDS.
-
enable
(subnode=1, timeout=1000)[source]¶ Enable PDS.
- Args:
subnode (int): Subnode of the drive. timeout (int): Timeout in milliseconds.
- Raises
ILTimeoutError – The servo could not be enabled due to timeout.
ILError – Failed to enable PDS.
-
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
ILTimeoutError – If fault reset spend too much time.
ILError – Failed to fault reset.
-
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.
-
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
ILError – Invalid subnode.
ILObjectNotExist – Failed to write to the registers.
-
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.
-
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
-
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
-
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
ILError – Invalid subnode.
ILObjectNotExist – Failed to write to the registers.
-
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
TypeError – If the register type is not valid.
ILAccessError – Wrong access to the register.
ILIOError – Error reading the register.
-
property
dictionary
¶ Returns dictionary object
-
property
errors
¶ Errors.
- Type
dict
-
property
full_name
¶ Drive full name.
- Type
str
-
property
info
¶ Servo information.
- Type
dict
-
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
-
units_pos
¶ Position units.
- Type
-
units_torque
¶ Torque units.
- Type
-
units_vel
¶ Velocity units.
- Type
-
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.