CANopen Slave Documentation
Version 6.16.04
|
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 cos_mobj_rpdo.inc
contains a list with possible mapping entries for RPDOs, the file cos_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 CosPdoMapping_s::pvdData before the optional handler (CosPdoMapping_s::pfnHandler) is called. On transmission of a TPDO the data will be collected from all mapped values defined by CosPdoMapping_s::pvdData after the optional handler (CosPdoMapping_s::pfnHandler) has been called.
When using optional add-on modules (device profiles), the mapping tables are already part of the device profile.
Default configuration of a RPDO or TPDO mapping is done inside the CosPdoComSetup() function.
The function CosPdoRcvMapAdd() 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 cos_mobj_rpdo.inc
:
In the application, the RPDO is configured in the following manner:
The function CosPdoTrmMapAdd() 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 cos_mobj_tpdo.inc
:
In the application, the TPDO is configured in the following manner: