2

I'm searching for information about PDO and the protocol CiA 301 V4.2.0 at topic 7.2.2.5.1 does not exactly show how PDO's work. Every PDO contains 8 bytes of data.

I know that there are 4 different PDO's.

PDO TX 1 - COB ID = 0x180 + Node ID
PDO RX 1 - COB ID = 0x200 + Node ID
PDO TX 2 - COB ID = 0x280 + Node ID
PDO RX 2 - COB ID = 0x300 + Node ID
PDO TX 3 - COB ID = 0x380 + Node ID
PDO RX 3 - COB ID = 0x400 + Node ID
PDO TX 4 - COB ID = 0x480 + Node ID
PDO RX 4 - COB ID = 0x500 + Node ID

I know that there are 4 different methods to call for the PDO service. The frist method is executed when for example a variable changes. The second method is when remote frame is transmitted from the consumer to the producer. Please, let me know what remote frame is. The third method is when the producer got a SYNC request from the consumer. The fourth method is when the producer it self send to the consumers on a fixed time event.

enter image description here

This is what I know about the PDO's. So here is my questions:

Question 1:

The PDO communiation parameters for both transmit and receive can be stored inside the Object Dictionary. For changing those, I need to use SDO - Service Data Objects.

enter image description here

I know what sub idex 02h means. It select which type of method the node is going to use to produce or receive the PDO message.

But what does sub inde 01h mean? I'm looking at the documention and it only says this. Does this mean I can checkmark if the PDO of that specific node should be active or not? Which node ID should I place there?

enter image description here

Question 2:

If I want to send data from a producer to a consumer with the PDO1 channel. I first need to select wich type of transmission type. Assume that I select this transmision type. For every 240 SYNC message from the consumer to the producer, send a PDO message to the consumers?

enter image description here

Question 3:

Each PDO contains 8 bytes of data. When I got a PDO message with the COB ID = 0x200 + 0x2 from the node 0x2, should I save the 8 bytes of data into the Object Dictionary? If yes, where?

Question 4:

What should I use PDO RX and PDO TX for, if there is only one way communication? I mean, the consumers sends a request to the producer e.g via SYNC message. SYNC service is not PDO. Then when the producer have got e.g X SYNC's, then the producer sends out a PDO message to the consumers. Why use RX and TX here? Why not only use TX?

Summation:

  1. What does COB ID mean in sub index 01h for the communication objects? What should I write there for both TX and RX communication objects of PDO?
  2. SYNC is a method for the consumers to count until the producer is going to send 8 bytes of data to the consumers?
  3. When a consumer got the PDO message of 8 bytes, then it going to store that into the Object Dictionary? If yes, which index and sub index?
  4. Why use RX when the producer only using TX when it sends PDO's to the consumers?
euraad
  • 1,025
  • 11
  • 30

3 Answers3

2

Every PDO contains 8 bytes of data.

In general, they can contain up to 8 bytes of data, but they don't have to. PDOs are the only messages in CANopen that can have a smaller DLC than 8.

I know that there are 4 different PDO's.

Depends on Device Profile. If you are using something like for example CiA 401 generic I/O module, then it has a certain amount of standardized PDOs. But a manufacturer can add more - they just won't be enabled from start.

Please, let me know what remote frame is

A remote request frame (RTR). This is a concept of the underlaying CAN data link layer, which you need to know before you can work with CANopen.

But what does sub index 01h mean?

The "valid" bit can be used to enable/disable a supported PDO. You have to set this one when the node is in pre-operational mode, you can't set it in operational mode.

The RTR bit is what it says, enable/disable RTR requests for this PDO by an external node.

In case of the standardized PDOs like those you listed, they are enabled by default and accept RTR by default. Manufacturer-specific PDOs like I mentioned above are not enabled by default.

Assume that I select this transmision type. For every 240 SYNC message from the consumer to the producer, send a PDO message to the consumers?

Yes.

Each PDO contains 8 bytes of data. When I got a PDO message with the COB ID = 0x200 + 0x2 from the node 0x2, should I save the 8 bytes of data into the Object Dictionary? If yes, where?

Each PDO is just a "box" where you map data stored elsewhere. In case dynamic PDO mapping is supported, you can even change which data that is stored where on the fly. For the standardized PDOs they have mapping parameters stored at default locations such as 0x1A00 for TPDOs. In case of static PDO mapping (which is in my experience the most common), then the mapping parameter are read-only.

These mapping parameters in turn point at the actual data store, which is also standardized at addresses such 0x6000, 0x6200 etc. I'd advise to look at CiA 401 generic I/O module for examples. Basically you can have something like a digital on/off stored at 0x6000:01, which is mapped into TPDO1 (0x180+node id) through the mapping parameter 0x1A00.

This also means that you can actually access the "raw" data at address 0x6000 with SDO access as well.

What should I use PDO RX and PDO TX for

One node's TPDO is another node's RPDO. So if you have a TPDO 0x181 which is sent out after receiving SYNC, the node which is interested in that data has to change one of the RPDO COBID to 0x181. The COBID listed by CANopen are just the default settings. You have to pair nodes together manually, by changing COBID (and optionally mapping parameters etc).

Lundin
  • 17,577
  • 1
  • 24
  • 67
0

EDIT: I'd like to point the audience to Lundin's response - clearly more precise, better informed and delivered with authority :-) Glad to have learned some interesting details. I'm leaving the rest of my message "as is", in spite of some b.s.

Standard low-level CAN works like this:

  • at the bus level, there are no apriori masters vs slaves
  • anyone can transmit anything he wants
  • anyone who has received the message should give an ACK
  • feel free to use the bus in a producer-consumer fashion if you will
  • the CAN ID indicates "the sort of data" being provided - need not necessarily mean / encode a node address, more like a "multicast group" or a TCP/UDP well-known port number, but possibly "to the world at large".

CANopen, on top of CAN, adds further rules:

  • there is a single bus master to rule the slaves (i.e., there is a distinction between a master and a slave) and there are node addresses, but, the transfers are not "request-response" fashion (Modbus style). Rather, the slaves can also talk to each other. Or rather, each slave speaks or listens as configured (as configured by the master).
  • to implement routine process data transfers, CANopen has the PDO's. I understand that TPDO's are "a node's TX", RPDO's are "a node's RX" (i.e. not from the bus master's perspective, somebody correct me if I'm wrong.)
  • multiple nodes can probably listen (RPDO) to a single slave transmitting (TPDO).
  • the slaves come equipped with an object dictionary. Via the object dictionary, the PDO's get configured.
  • to access the slaves' object dictionaries, CANopen has SDO's. This is a master/slave request/response protocol - originally intended to configure the PDO's in a particular slave, but some vendors (ab)use them for payload transfers too...
  • RTR is a mechanism for the master to solicit the transmission (TPDO) from a particular slave node (as we have node addresses). So this is closest to a "request-response" traffic pattern, in terms of the PDO's.
  • SYNC is a message optionally transferred by the master, which essentially means "whatever it is that you guys are configured to do, now's the time". If a slave is configured to transmit something, that's what he should do. The original meaning of the message apparently is "tick tock, I'm the clock on this bus" = it's intended for time sync, and it is supposed to be transmitted periodically.

To answer your questions:

  1. the COB ID inside an object dictionary entry (sub-index 01) likely means the "local offset of this PDO" within a node (i.e. not including the node ID). It allows you to customize the local offset of a particular data object.

  2. SYNC is one way of triggering PDO transfers. Originally it is just a periodic time sync message. I can imagine scenarios where slave nodes transmit every N-th sync, or use the SYNC to align their timebase but actually trigger their transmissions shifted in time (as a way of avoiding the transmission priority arbitration) etc.

  3. I believe that within a node, the local storage for PDO payload data is left up to the implementor of the node firmware. It may certainly be internally interlinked/referenced with the "object dictionary" data metastructures, or it can be some fixed allocation, or it can belong to the application-specific (proprietary) data processing engine in the node's firmware = whatever it is that the CANopen node does for a living :-) Remember: PDO's are for the bread and butter. SDO's and the Object Dictionary are there to configure the PDO's (addressing offsets and other properties, as you have noticed). Local PDO payload data storage isn't a standard part of the Data Dictionary.

  4. the sense and purpose of distinguishing RPDOs vs. TPDOs: clearly these refer to the "direction" of the data flow. Apparently, withing CANopen, from the perspective of a particular bus node, a particular PDO can either serve for TX to the bus, or for RX from the bus. Not both at the same time (unlike other technologies, where you can "write" a particular datapoint and then read the value back). The bus master can use the slaves' object dictionaries (by means of SDO) to "splice" their TPDO's and RPDO's to interconnect data flows between the nodes.

I've seen partial implementations of CANopen-like CAN nodes that e.g. use PDO-style addressing, but do not have an Object Dictionary. I've also seen nodes where payload traffic is implemented by SDO's. I've seen nodes that do not support SYNC or RTR. Note that a node can transmit a TPDO based on custom criteria, principally "at its own discretion" - as required by the application, ot as programmed "out of band". I've seen a CANopen master interface for a PLC, where the PDO transfers flow "seamlessly" into the PLC's process data memory space (table of datapoints = there's your payload storage), and SDO transfers can be triggered explicitly by the PLC's program (via function blocks)...

You have my thumbs up for asking all the right questions :-) It never hurts to become fluent in the native principal concepts of a particuar bus technology... if only there weren't so many different fieldbus technologies out there :-)

frr
  • 2,573
  • 12
  • 14
  • Thanks! About question 1. What should I write between bit 0 and bit 10? – euraad Nov 07 '21 at 16:13
  • @MrYui frankly I have no clue :-) If you don't get a better answer from someone else, try inserting the node ID for the slave node you're talking to. Alternatively, I'd try leaving those bits at log.0. – frr Nov 07 '21 at 17:35
  • According to HYDAC "Determines the identifier for the PDO. The highest value bit (Bit31) of the **entry no longer belongs** to the ID and has the meaning "disable PDO". If this bit is set, then transmission of the PDO is disabled." for product `Protocol description HAT 1000 CANopen HAT 3000 CANopen ` – euraad Nov 07 '21 at 20:50
  • So in that case...I could ignore that CAN ID field? – euraad Nov 07 '21 at 20:51
  • Do you have knowledge in CANopen? I know the protocol well? – euraad Nov 07 '21 at 20:51
  • @MrYui I do not want to claim to know CANopen well. I have limited practical hands-on with about two particular implementations (hardware). And I have ancient programming experience with CAN transceivers, with some features towards CANopen. And occasionally I service CANopen transceivers by replacing blown line driver chips. – frr Nov 07 '21 at 21:11
  • Nice! If you want, you can help me build on a CANopen library that are suitable for embedded systems. It's all on my GitHub. I have constructed a very nice structure and it's easy to follow. All in C code. But I'm stuck at PDO. I think PDO communcation parameters is ONLY for the producer and PDO mapping parameter is ONLY for the consumer. Is that correct? – euraad Nov 07 '21 at 22:13
  • @MrYui There's hardly anything I can do. By now you're pretty well versed in the CANopen standards document. I am not. And the past "hands-on" were as part of some HW service jobs or even just telephone techsupport tickets. I don't have a lab bench ready with a CANopen master and some slaves. Nowhere near that. BTW the wikipedia entry mentions a few open-source CANopen stacks. Perhaps you could look for inspiration there? https://en.wikipedia.org/wiki/CANopen#External_links – frr Nov 07 '21 at 22:24
  • Thanks. I have seen these open source CANopen libraries, but they are still to heavy for low powered CAN bus system. If you like CAN bus, you might want to try out Open SAE J1939. I wrote it. https://github.com/DanielMartensson/Open-SAE-J1939 – euraad Nov 07 '21 at 22:33
  • @MrYui wow, that's quite a complex piece of code! Comprehensive. Thumbs up for making it available as open source. Ages ago, I've written a Modbus library that I wasn't allowed to publish. http://support.fccps.cz/download/adv/frr/modbus/index.htm That's the past, but I still work as a support techie with a national distributor of the HMS/IXXAT = I have some motivation not to contribute to open-source projects that would compete with them :-/ Just kidding, I'm out of time anyway. I suggest that we continue our debate in private e-mail. – frr Nov 07 '21 at 22:44
  • The code is not complex because it follows the same pattern. Have a look at https://github.com/DanielMartensson/Easy-CANopen/tree/main/src/CANopen Same here. Follows the same pattern. I was first into Modbus, but it seems like an old standard and more modern standard is starting to replace Modbus RTU. – euraad Nov 07 '21 at 22:50
  • This answer is conceptually wrong. There is no master in CANopen apart from the NMT master. Which doesn't have anything to do with PDO or SDO access. – Lundin Nov 08 '21 at 07:54
  • @MrYui There is already a somewhat well-known open source CANopen stack https://canfestival.org/ which has lots of work put into it. Rather than re-inventing the wheel, why don't you use that stack and/or join that project? – Lundin Nov 08 '21 at 08:49
  • @Lundin I need to have a special solution. – euraad Nov 08 '21 at 17:22
  • @Lundin thanks for all your corrections. As for the distinction between master/slave, clearly I've been living under the influence of a particular implementation (a product family from a particular vendor) where a CANopen master/manager stack is clearly distinguished from a CANopen slave stack. Now I understand that this distinction is a proprietary constraint / arrangement of the "node personalities / behaviors". – frr Nov 08 '21 at 20:03
  • 1
    @frr Yes there's quite a bit of difference from a stack's perspective - if you buy commercial stacks like the one from IXXAT for example, they come in two different flavours, NMT Master or NMT Slave. But their master stack includes a lot of other peripheral advanced features too, like "flying master" (some other node becoming secondary master on the fly for redundancy purposes), LSS master and so on. Basically they bunch up a lot of advanced features in some premium version called "master stack". On the actual CANopen network though, speaking of a master only makes sense for NMT. – Lundin Nov 09 '21 at 07:25
  • 1
    That being said, a lot of control systems like those for heavy machinery are almost always built around a single ECU/PLC which acts as the "smart node", essentially a master in the traditional sense. There may be a number of subsystem nodes that are reasonably smart too, but mostly a lot of "dumb" nodes like I/O modules, valves etc that might even have a lot of CANopen functionality stripped off. – Lundin Nov 09 '21 at 07:27
  • @Lundin Why are RPDO communication used when RPDO ONLY receive data? – euraad Nov 10 '21 at 20:38
  • @MrYui What do you mean? – Lundin Nov 11 '21 at 07:18
  • @Lundin I open a new question about that, instead of asking a new one here. – euraad Nov 11 '21 at 07:49
  • @MrYui on the bus, it's just PDO. The distinction between RPDO and TPDO makes sense from the perspective of an individual node. Locally, speaking of bus communications, TPDO is a data source (from the node to the bus), RPDO is a data sink (from the bus to the node). Note that some fieldbus technologies tend to speak about input and output "datapoints", with the direction referring to the bus master's perspective, or "distributed discrete I/O" perspective. The distinction of RPDO/TPDO and their "splicing" on the bus reminds me of LonWorks... – frr Nov 11 '21 at 08:15
  • @frr Isn't RPDO and TPDO the same, just different channels? – euraad Nov 11 '21 at 17:58
  • @MrYui I haven't read the CiA spec, so I don't know if this is somehow standardized, but conceptually why not, and your impementation-specific details are your implementation-specific details ;-) I've taken a look at your code a week ago and again today, and I can see progress. One letter has caught my eye: in PDO_Internal/CANopen_Consumer_PDO_Receive.c , the name CANopen_Consumer_PDO_Receive_TPDO() - does the *T*PDO make sense here? I'd say *R*PDO here :-) But I haven't read your code thoroughly and I don't understand it enough. This note is very superficial. – frr Nov 12 '21 at 08:36
0

Disclaimer: I have tried and partially succeeded developing & implementing a CANopen stack on a STM32, but apart from some initial test, I've never properly test it on field or on a real product. It has been some years, so my memories may be inaccurate.

What does COB ID mean in sub index 01h for the communication objects? What should I write there for both TX and RX communication objects of PDO?

COB-ID represents the hard CAN identifier on the wire. For transmitters, well, this is the ID they use when emitting PDOs on the bus, where each PDO has its own distinct COB-ID. For receivers, these are the CAN IDs they look for on the bus. CAN controllers can filter out the messages they are not interested in. So, a typical implementation configures its hardware filters according to RPDO COB-IDs (and of course SDO & other messages), then process RPDOs according to their COB-IDs.

SYNC is a method for the consumers to count until the producer is going to send 8 bytes of data to the consumers?

For producers (TPDO), SYNC serves as a "sample inputs" command. As the SYNC is broadcast to all nodes, all producers can sample their inputs at the same time. Then they all try to send their TPDOs. The produced data will have some delays before they arrive their destination, but they all belong to the same time instant. Some producers may need to sample & send their TPDOs less often, so they do so on every nth SYNC.

For consumers (RPDO), SYNC serves as a "update outputs" command. RPDOs may arrive on different times, but all the outputs on the system/bus will be updated when the SYNC arrives (after the RPDOs). If I remember correctly, SYNC counter isn't used for RPDOs, but I may be wrong.

When a consumer got the PDO message of 8 bytes, then it going to store that into the Object Dictionary? If yes, which index and sub index?

There are some PDO Mapping Parameters on object dictionary (OD). It's some kind of table where it lists RPDO COB-IDs and index-subindex pairs associated with 8 bytes that RPDO contains. On some simpler devices, these are hard-coded. On others, these can be configured using SDO transfers.

Why use RX when the producer only using TX when it sends PDO's to the consumers?

The PDO - COB-ID table you mentioned is just a default one to prevent collisions on a bus with maximum number of nodes and each using 4 TPDO & 4 RPDO. But, there can be less nodes in the bus, some nodes may need more or less PDOs. The unused COB-IDs can be assigned for different purposes, for example as a PDO TX 5. Actually, you are not required to follow that numbering scheme and may assign COB-IDs as you see fit. Just remember that there can be only one transmitter on the bus for a given COB-ID.

Tagli
  • 1,222
  • 1
  • 6
  • 16
  • Using CAN controller filters is not very meaningful in most CANopen applications, since there are so many different identifiers and you need to be able to change your own node id. – Lundin Nov 08 '21 at 07:51
  • 1
    @Lundin With the exception of very special and not rarely supported failsafe and LSS messages, the rest of COB-IDs have node ID in the low 7 bits. This makes it _very_ suitable for masked filtering in hardware. Yes, large industrial setups can have multiple nodes talking to each other, but many CANopen applications still using good old master/slaves setup, where filtering is easy on all slave nodes. And even in complex setups it is rare that a node talks to more than a dozen other nodes, while simple controllers like STM32 bxcan easily support 14 filters. – Maple Nov 21 '21 at 17:35