PDO
- class ingeniamotion.pdo.PDOPoller(mc, servo, refresh_time, watchdog_timeout, buffer_size)
Bases:
objectPoll register values using PDOs.
- property data: tuple[list[float], list[list[int | float | bytes]]]
Get the poller data. After the data is retrieved, the data buffers are cleared.
- add_channels(registers)
Configure the PDOs with the registers to be read.
- subscribe_to_exceptions(callback)
Get notified when an exception occurs on the PDO thread.
- class ingeniamotion.pdo.PDONetwork(alias, network, refresh_rate, watchdog_timeout, _PDONetwork__pdo_thread_status=False)
Bases:
objectRepresents a PDO network.
- network: EthercatNetwork
- property is_active: bool
Check if the PDO thread is active.
- Return type:
- Returns:
True if the PDO thread is active. False otherwise.
- compare_configuration(refresh_rate, watchdog_timeout)
Compares the current PDO thread configuration with another.
- Parameters:
- Return type:
- Returns:
True if the configurations are equal, False otherwise.
- classmethod create_and_subscribe(alias, network, refresh_rate=None, watchdog_timeout=None)
Creates a new PDONetwork instance and subscribes to EtherCAT network PDO thread status.
- Parameters:
alias (
str) – The network alias.network (
EthercatNetwork) – The EthercatNetwork instance.refresh_rate (
Optional[float]) – Determines how often (seconds) the PDO values will be updated.watchdog_timeout (
Optional[float]) – The PDO watchdog time. If not provided it will be set proportional to the refresh rate.
- Return type:
- Returns:
A new PDONetwork instance.
- class ingeniamotion.pdo.PDONetworksTracker
Bases:
objectTracks the different networks that have been required to activate PDOs.
- is_network_tracked(alias)
Checks if a network is being tracked.
- add_network(alias, network, refresh_rate=None, watchdog_timeout=None)
Add a network to the tracker.
- Parameters:
alias (
str) – The network alias.network (
EthercatNetwork) – The EthercatNetwork instance.refresh_rate (
Optional[float]) – Determines how often (seconds) the PDO values will be updated.watchdog_timeout (
Optional[float]) – The PDO watchdog time. If not provided it will be set proportional to the refresh rate.
- Raises:
IMError – If the network is already tracked with a different configuration.
- Return type:
- remove_network(alias)
Remove a network from the tracker.
- get_il_network(alias)
Retrieves the Ethercat network for a specific alias.
- class ingeniamotion.pdo.PDONetworkManager(motion_controller)
Bases:
objectManage all the PDO functionalities.
- Parameters:
mc – The MotionController.
- create_pdo_item(register_uid, axis=1, servo='default', value=None)
Create a PDOMapItem by specifying a register UID.
- Parameters:
- Return type:
Union[RPDOMapItem,TPDOMapItem]- Returns:
Mappable PDO item.
- Raises:
ValueError – If there is a type mismatch retrieving the register object.
AttributeError – If an initial value is not provided for an RPDO register.
- static create_pdo_maps(rpdo_map_items, tpdo_map_items)
Create the RPDO and TPDO maps from PDOMapItems.
- static create_empty_rpdo_map()
Create an empty RPDOMap.
- Return type:
RPDOMap- Returns:
The empty RPDOMap.
- static create_empty_tpdo_map()
Create an empty TPDOMap.
- Return type:
TPDOMap- Returns:
The empty TPDOMap.
- set_pdo_maps_to_slave(rpdo_maps, tpdo_maps, servo='default')
Map the PDOMaps to the slave.
- Parameters:
- Raises:
ValueError – If there is a type mismatch retrieving the drive object.
ValueError – If not all elements of the RPDO map list are instances of a RPDO map.
ValueError – If not all elements of the TPDO map list are instances of a TPDO map.
- Return type:
- clear_pdo_mapping(servo='default')
Clear the PDO mapping within the servo.
- Parameters:
servo (
str) – servo alias to reference it.defaultby default.- Raises:
ValueError – If there is a type mismatch retrieving the drive object.
- Return type:
- remove_rpdo_map(servo='default', rpdo_map=None, rpdo_map_index=None)
Remove a RPDOMap from the RPDOMap list.
- The RPDOMap instance or the index of the map in the RPDOMap list
should be provided.
- Parameters:
- Raises:
ValueError – If there is a type mismatch retrieving the drive object.
- Return type:
- remove_tpdo_map(servo='default', tpdo_map=None, tpdo_map_index=None)
Remove a TPDOMap from the TPDOMap list.
The TPDOMap instance or the index of the map in the TPDOMap list should be provided.
- Parameters:
- Raises:
ValueError – If there is a type mismatch retrieving the drive object.
- Return type:
- start_pdos(network_type=None, refresh_rate=None, watchdog_timeout=None, servo='default')
Start the PDO exchange process.
Warning
Note that the PDO exchange will start for all servos connected to the same network.
- Parameters:
network_type (
Optional[CommunicationType]) – Network type (EtherCAT or CANopen) on which to start the PDO exchange.refresh_rate (
Optional[float]) – Determines how often (seconds) the PDO values will be updated.watchdog_timeout (
Optional[float]) – The PDO watchdog time. If not provided it will be set proportional to the refresh rate.servo (
str) – servo alias to reference it.DEFAULT_SERVOby default. If network_type is provided, servo must be connected to that network.
- Raises:
ValueError – If the MotionController is not connected to any Network.
ValueError – If there is a type mismatch retrieving the network object.
- Return type:
- stop_pdos(servo='default')
Stop the PDO exchange process.
Warning
Note that the PDO exchange will stop for all servos connected to the same network.
- is_active(servo='default', net_alias=None)
Check if the PDO thread is active for the network to which the servo is connected.
Alternatively, it can be checked for a specific network. If the network alias is provided, the servo will be ignored.
- Parameters:
- Return type:
- Returns:
True if the PDO thread is active. False otherwise.
- Raises:
ValueError – If neither servo nor net_alias is provided.
- subscribe_to_send_process_data(callback, servo='default')
Subscribe be notified when the RPDO values will be sent.
- subscribe_to_receive_process_data(callback, servo='default')
Subscribe be notified when the TPDO values are received.
- subscribe_to_exceptions(callback, servo='default')
Subscribe be notified when there is an exception in the PDO process data thread.
If a callback is subscribed, the PDO exchange process is paused when an exception is raised. It can be resumed using the resume_pdos method.
- unsubscribe_to_send_process_data(callback, servo='default')
Unsubscribe from the send process data notifications.
- unsubscribe_to_receive_process_data(callback, servo='default')
Unsubscribe from the receive process data notifications.
- create_poller(registers, servo='default', sampling_time=0.125, buffer_size=100, watchdog_timeout=None, start=True)
Create a register Poller using PDOs.
- Parameters:
registers (
list[dict[str,Union[int,str]]]) –list of registers to add to the Poller. Dicts should have the follow format:
[ { # Poller register one "name": "CL_POS_FBK_VALUE", # Register name. "axis": 1 # Register axis. # If it has no axis field, by default axis 1. }, { # Poller register two "name": "CL_VEL_FBK_VALUE", # Register name. "axis": 1 # Register axis. # If it has no axis field, by default axis 1. } ]
servo (
str) – servo alias to reference it.defaultby default.sampling_time (
float) – period of the sampling in seconds. By default0.125seconds.watchdog_timeout (
Optional[float]) – The PDO watchdog time. If not provided it will be set proportional to the refresh rate.buffer_size (
int) – number maximum of sample for each data read.100by default.start (
bool) – ifTrue, function starts poller, ifFalsepoller should be started after.Trueby default.
- Return type:
- Returns:
The poller instance.
- unsubscribe_to_exceptions(callback, servo='default')
Unsubscribe from the exceptions in the process data notifications.