CANopen Master Documentation
Version 6.06.04
|
The CANopen Master protocol stack provides two solutions for PDO handling: PDO Mapping and PDO Queue. The solutions are depicted in the figure PDO handling
. Both solutions can be used independent from each other.
Configuration of a RPDO or TPDO is done via the ComPdoConfig() function. Please note that the function disables the transmission of TPDOs and reception of RPDOs as default. A PDO has to be enabled by calling ComPdoEnable() by the application program. The following code snipped provides an example for an enabled RPDO1:
PDO mapping allows automatic distribution of values received by a RPDO to the corresponding entries of the object dictionary. In the same way values stored in the object dictionary can be copied into a TPDO, as shown in the next figure.
If PDO mapping is used, the possible mapping entries (i.e. data elements of the object dictionary which can be mapped into a PDO) are defined in different *.inc
files. The file com_mobj_rpdo.inc
contains a list with possible mapping entries for RPDOs, the file com_mobj_tpdo.inc
contains a list with possible mapping entries for TPDOs. In addition to the mapping entries, optional callback handlers can be added as an option. For a RPDO the handler is called after PDO reception, for a TPDO the handler is called before PDO transmission.
On reception of a RPDO data will be distributed to all mapped values defined by structure ComPdoMapping_s::pvdData before the optional handler (ComPdoMapping_s::pfnHandler) is called. On transmission of a TPDO the data will be collected from all mapped values defined by ComPdoMapping_s::pvdData after the optional handler (omPdoMapping_s::pfnHandlerpfnHandler) has been called.
The function ComPdoRcvMapAdd() is used to map entries to the desired position inside the RPDO. The RPDO mapping example from the figure above would require the following file contents of com_mobj_rpdo.inc
:
In the application, the RPDO is configured in the following manner:
The function ComPdoTrmMapAdd() is used to map entries to the desired position inside the TPDO. The TPDO mapping example from the figure above would require the following file contents of com_mobj_tpdo.inc
:
In the application, the TPDO is configured in the following manner:
On reception of configured RPDOs the complete CAN message can optionally be stored into a receive queue. The RPDO queue is disabled by default.
In the same way it is possible to send configured TPDOs via the command ComPdoTrmPacket().