PDO¶
-
class
ingeniamotion.pdo.
PDOPoller
(mc, servo, refresh_time, watchdog_timeout, buffer_size)¶ Poll register values using PDOs
-
property
data
¶ 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.
- Parameters
callback (
Callable
[[IMException
],None
]) – Function to be called when an exception occurs.- Return type
-
property
-
class
ingeniamotion.pdo.
PDONetworkManager
(motion_controller)¶ Manage all the PDO functionalities.
- Parameters
mc – The MotionController.
-
class
ProcessDataThread
(net, refresh_rate, watchdog_timeout, notify_send_process_data=None, notify_receive_process_data=None, notify_exceptions=None)¶ Manage the PDO exchange.
- Parameters
net (
EthercatNetwork
) – The EthercatNetwork instance where the PDOs will be active.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.notify_send_process_data (
Optional
[Callable
[[],None
]]) – Callback to notify when process data is about to be sent.notify_receive_process_data (
Optional
[Callable
[[],None
]]) – Callback to notify when process data is received.notify_exceptions (
Optional
[Callable
[[IMException
],None
]]) – Callback to notify when an exception is raised.
- Raises
ValueError – If the provided refresh rate is unfeasible.
-
create_pdo_item
(register_uid, axis=1, servo='default', value=None)¶ Create a PDOMapItem by specifying a register UID.
- Parameters
- Return type
- 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.
-
create_pdo_maps
(rpdo_map_items, tpdo_map_items)¶ Create the RPDO and TPDO maps from PDOMapItems.
- Parameters
rpdo_map_items (
Union
[RPDOMapItem
,List
[RPDOMapItem
]]) – The RPDOMapItems to be added to a RPDOMap.tpdo_map_items (
Union
[TPDOMapItem
,List
[TPDOMapItem
]]) – The TDOMapItems to be added to a TPDOMap.
- Return type
- Returns
RPDO and TPDO maps.
-
static
add_pdo_item_to_map
(pdo_map_item, pdo_map)¶ Add a PDOMapItem to a PDOMap.
- Parameters
pdo_map_item (
Union
[RPDOMapItem
,TPDOMapItem
]) – The PDOMapItem.pdo_map (
Union
[RPDOMap
,TPDOMap
]) – The PDOMap to add the PDOMapItem.
- Raises
ValueError – If an RPDOItem is tried to be added to a TPDOMap.
ValueError – If an TPDOItem is tried to be added to a RPDOMap.
- Return type
-
static
create_empty_rpdo_map
()¶ Create an empty RPDOMap.
- Return type
- Returns
The empty RPDOMap.
-
static
create_empty_tpdo_map
()¶ Create an empty TPDOMap.
- Return type
- 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.default
by 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 the RPDOMap instance is not in the RPDOMap list.
IndexError – If the index is out of range.
- 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 the TPDOMap instance is not in the TPDOMap list.
IndexError – If the index is out of range.
- Return type
-
start_pdos
(network_type=None, refresh_rate=None, watchdog_timeout=None)¶ Start the PDO exchange process.
- Parameters
network_type (
Optional
[COMMUNICATION_TYPE
]) – 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.
- Raises
ValueError – If the refresh rate is too high.
ValueError – If the MotionController is connected to more than one Network.
ValueError – If network_type argument is invalid.
IMException – If the MotionController is connected to more than one Network.
ValueError – If there is a type mismatch retrieving the network object.
IMException – If the PDOs are already active.
- Return type
-
stop_pdos
()¶ Stop the PDO exchange process.
- Raises
IMException – If the PDOs are not active yet.
- Return type
-
subscribe_to_send_process_data
(callback)¶ Subscribe be notified when the RPDO values will be sent.
-
subscribe_to_receive_process_data
(callback)¶ Subscribe be notified when the TPDO values are received.
-
subscribe_to_exceptions
(callback)¶ 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.
- Parameters
callback (
Callable
[[IMException
],None
]) – Callback function.- Return type
-
unsubscribe_to_send_process_data
(callback)¶ Unsubscribe from the send process data notifications.
-
unsubscribe_to_receive_process_data
(callback)¶ 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
[str
,int
]]]) –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.default
by default.sampling_time (
float
) – period of the sampling in seconds. By default0.125
seconds.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.100
by default.start (
bool
) – ifTrue
, function starts poller, ifFalse
poller should be started after.True
by default.
- Return type
- Returns
The poller instance.
-
unsubscribe_to_exceptions
(callback)¶ Unsubscribe from the exceptions in the process data notifications.
- Parameters
callback (
Callable
[[IMException
],None
]) – Subscribed callback function.- Return type