Application note 0564-06: PDO configuration
This document explains the procedure to configure a PDO. The communication profile CiA-301 specifies the following steps:
step | PDO communication parameter * | PDO mapping parameters ** | category | description |
sub-index 1: set bit 31 of the cob-ID |
| mandatory | Disable the PDO. | |
|
sub-index 2-6: change the value |
|
optional | change the PDO communication parameters: The sub-index can be configured if: · the sub-index exists in the PDO object · the sub-index is writeable · the new value is allowed for this PDO |
|
|
sub-index 0: set number of PDO mapping entries to 0 |
conditional | change the PDO mapping: Disable PDO mapping. The PDO mapping can be changed if: · dynamic PDO mapping is allowed for this PDO · the sub-indices of the PDO mapping object are writeable |
| sub-index 1-64: set the PDO mapping | optional | Specify the PDO mapping. The mapped objects must be mappable into a PDO. | |
| sub-index 0: set the correct number of PDO mapping entries | conditional | The number of the specified PDO mapping entries in step 4 must be set. | |
sub-index 1: set the desired cob-ID, bit 31 must be set to 0 |
| mandatory | Change the cob-ID and enable the PDO. |
*...objects 1400h-15FFh and 1800h-19ffh, **... objects 1600h-17FFh and 1A00h-1BFFh
Step 3 and 5 are mandatory if the PDO mapping shall be changed and the conditions are fulfilled.
It is allowed to configure a PDO in the state NMT/OPERATIONAL because the PDO is disabled in step 1, i.e. the PDO is not used.
Sub-index 2 and 5 if the PDO communication parameters can also be configured when the PDO is enabled.
The configuration steps are also valid for the configuration of a PDO via the CAN bus.
Initialization of the PDO cob-ID in an application created with the CANopen Library of port:
The CANopen Library initializes the PDO cob-ID as indicated in Figure 1.
Figure 1: initialization of PDO cob-IDs
Notes to Figure 1:
The initialization of the PDO cob-ID depends on the access right of the PDO communication parameter / cob-ID object, see Design Tool PDO communication parameter object / sub-index cob-ID / Tab Structure / Access.
The option “non-standard extension” of the Design Tool is described in the application note 0640-03.
The CANopen Library initializes the PDO cob-IDs according to the pre-defined connection set. This initialization can be overwritten by the PDO cob-IDs designed in the Design Tool. Call the function overwritePreDefConnSet(), located in the generated C module co_init.c, in your application after calling of init_Library().
The CANopen Library initializes the PDO cob-IDs according to the pre-defined connection set. Application-specific PDO cob-ID have to be set by CANopen Library functions, see the following chapter.
The CANopen Library initializes the PDO cob-IDs with the values designed in the Design Tool.
Change PDO cob-IDs with CANopen Library functions:
The function init_Library() initializes the cob-IDs according to pre-defined connection set, defined in CiA-301. When you like to use other cob-IDs you have to change the values of the PDO cob-IDs in your application after the execution of the function init_Library(). There are the following possibilities to configure the PDO cob-IDs, shown for TPDO1:
option:
coRetVal = setCobId(0x1800, 1, (PDO_NO_VALID_BIT | cobId) );
coRetVal = setCobId(0x1800, 1, cobId);
option:
cobId = PDO_NO_VALID_BIT | cobId;
coRetVal = putObj(0x1800, 1, (UNSIGNED8*)&cobId, size, CO_TRUE);
coRetVal = setCommPar(0x1800, 1);
cobId = (~PDO_NO_VALID_BIT) & cobId;
coRetVal = putObj(0x1800, 1, (UNSIGNED8*)&cobId, size, CO_TRUE);
coRetVal = setCommPar(0x1800, 1);
option:
p301_n1_tpdo_para.cobId |= PDO_NO_VALID_BIT;
coRetVal = setCommPar(0x1800, 1);
p301_n1_tpdo_para.cobId &= (~PDO_NO_VALID_BIT);
coRetVal = setCommPar(0x1800, 1);
The compiler define PDO_NO_VALID_BIT is already defined in the CANopen Library in the file co_pdo.h:
#define PDO_NO_VALID_BIT 0x80000000
Change another PDO parameter in an application created with the CANopen Library of port:
Option 2 and 3 can also be used to change the other PDO parameters, i.e.:
Set the value of the PDO parameter in the object dictionary with the function putObj() or directly about the C name of the object.
Activate the setting for the CANopen Library by calling the function setCommPar().