AsCanOpen library, CANopenPDORead8 Function Block

Hi everyone,

Recently I was testing AsCANOpen library to read/write PDO without importing an EDS file into the physical view.

Hardware used as below

  1. 4PPC30.043F-21B
  2. X20BC0043-10 + PS6400 + X20DI9371 + X20DO9322

I have generated the EDS file for X20BC0043-10 + PS6400 + X20DI9371 + X20DO9322 for my reference so that I know which COB-ID I can read/write.

So I have created a program based on the example AsCanOpen library (ac74fb01-e592-4ca0-b2b3-6902a1141127).

Everything works fine from registering the COB-ID and writing value to turn on respective DO channels in X20DO9322, but for reading I am getting an error 64/16#0040. When I checked the AS help, the error number indicates NO_VALID_DATA_AVAILABLE.

I notice that the error only occurs if the previous value and current value is same during the CANopenPDORead8 FB’s execution. For an example when I am reading X20DI9371 channel 1, if the state is FALSE during the first execution, the FB has no error, if on the next execution, the DI channel’s state is still FALSE, the error occurs. otherwise it is fine.

Can anyone point what am I missing or anything that I am doing wrongly here?

Thank you
Best regards

Hi @kumaranj,

from what I can read here B&R Online Help this is the expected behavior, since

After being read with the CANopenPDORead8() function block, messages are deleted from the network layer receive buffer. This prevents a message from being read more than once by the PLC program.

So until the master sends a new message, which it only seems to do in case of a change, it’s expected you get NO_VALID_DATA_AVAILABLE

At least that’s my understanding of this.
Disclaimer: I have not used this library myself before, but I am used to some errors being expected for various libs, e.g. from the AsTCP libraries, where “NO DATA” is also a case you have to handle yourself.

1 Like

@michael_w thank you for the input. Appreciate it.
I found out that from one of my colleague that error 16#0040 will occur when the PDO’s transmission is based on event. If there is no change in the event and the Fb is executed, the Fb will return 16#0040.

Hope this will be helpful if anyone else facing similar situation.

Thank you
Best regards
Jai Kumaran