How does the CANopen communication between X20IF1072 and a CANopen slave work?

Hi, I’m a newbie with AS and also with CAN protocols and I would like some help understanding how the communication with CANopen works.

I have a X20 CPU with a X20IF1072 interface connected to a CANopen slave device I’ve imported via an EDS file. I’ve setup the CANopen configuration both on the interface and slave sides and now I can see the PDOs of the slave in the I/O mapping and build the code with no problems.

My question are:

  1. Now how do I use the data coming from my slave?
  2. Do I just need to map the PDOs data into global/local variables of my invention in the I/O mapping of the slave?
  3. Do I necessarily need to use the AsCANopen library to obtain the data?
  4. If the “Start all slaves on the CAN network” parameter is set to “on”, what does it mean they are started, does it mean they are asked to enter Operational mode?

Hi Edoardo,

Welcome to the Community, and the B&R world!

  1. You can map Process Variables (PVs) to the datapoints in the I/O mapping. If you right-click on the slave device and open the I/O Mapping, you’ll see all of the available datapoints. You can then use the Process Variable column to map to an existing Global or Local variable. This variable will need to have the same datatype as the datapoint. First, double-click on the datapoint’s row in the Process Variable column. Then use the three dots that appear on the right to browse available variables.
  2. Yes exactly!
  3. You probably do not need the AsCANopen library. This library allows you to implement a CANopen master over a simple CAN interface (as CANopen is just an application layer on top of the physical CAN bus). It is also helpful if you don’t have an EDS file. The X20IF1072 already does what you need via the provided EDS file.
  4. CANopen devices have different states they can be in. On startup, they are by default in Pre-Operational mode and will remain that way until told to start (NMT command 1). The “Start all slaves” setting if ON will send a broadcast NMT Start command to anything connected to the network. If this is OFF, only the devices configured in the Automation Studio project will be started. If you only have one device, and it is configured in your project, this setting won’t affect you.

Hi Marcus, thanks for your reply, it was very clear!

I would like to understand more about the AsCANopen library.

I get that the setup is already done thanks to the X20IF1072, however as far as I’ve understood at this moment my slave will enter Operational mode after startup (if configured to do so as you said) and that’s it. I would like to implement some conditional logics in an ST program so to control the mode of my slave, and also modify its configuration via SDOs to send parameters chosen from an HMI. I guess to do so the AsCANopen library is invitable to use right?

You’re welcome!

Yes, in that case you’d want to use the AsCANopen library. Specifically, to Start nodes on command, you can use the CANopenNMT function block.

There are also some examples provided by the library. You can add these to your project’s Logical view via the Toolbox (select Library Samples, then in the popup window expand Library and AsCANopen). These should help get you started.

One thing to note is that there are cases where the library cannot be used along with the EDS file. You should be able to read data cyclically using the EDS file and start the nodes via a function block. However, I think that if you wanted to read and write data via the library, you couldn’t also add the slave via EDS file since the EDS file tells the master to configure the slave device a certain way.