Section 3.0.1 states:
"The only means by which the Node-ID and Baudrate can be changed is to use Layer Setting Services (LSS) and protocols as defined by CANopen standard DS-305."
When you create your I/O configuration with CANopen Manager, automatically the CAA CiA405 library is added. This includes an FB SDO_WRITE4. You can use this to send the LSS messages.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for your reply and sorry for my delayed response. I was not able to test your suggestion until now.
I've created a program using the SDO_WRITE4 function block and I can now write SDOs. For example, I can change the baud rate of a CANOpen device.
However, I don't understand how to use SDO_WRITE4 to write LSS messages. This function block takes in the destination node-id on the DEVICE input. However, LSS messages use special reserved COB-IDs without node-ids. Is there a way to get around this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Ben, you are right, I answered too quickly. You need to send a message with own defined COB ID. Probably the CAN Level2 communication is your best option. There is an example project available which contains a library that encapsulates this communication method to access it in an OOP way.
I've had a look at the example code you pointed me to. Unfortunately, I can't see any examples of a write function that does not use SDO messages. Can you be more specific about which function block might work?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The example project, which is included in the package, shows an example with CFC program (CFC_PRG). This calls the FB MsgProcessor_EchoCFC. This FB calls a method ProcessMessage, which calls the FB CAN.CANSender. This has a reference to the interface of the CANDriver and a reference to the Message you want to send.
So you could use this FB to send any CAN message.
The Message is a struct:
TYPE MESSAGE :STRUCT udiCanID : UDINT; (* CAN-ID (Communication Object Identifier) is the bitId of a CAN-frame *) abyData : ARRAY[0..7] OF BYTE; (* Array for 0 to 7 bytes of data *) usiDataLength : USINT; (* The length of the data array 0 to 8 *) xRTR : BOOL; (* Remote Transmission Request *) xIs29BitMessage : BOOL; (* TRUE: the messages is a 29bit message, FALSE: the message is a 11bit message *)END_STRUCTEND_TYPE
For LSS, you can use as udiCanID - 16#7E5. You always should send 8 bytes for an LSS message.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have an Axiomatic AX021101 CANOpen valve controller that I'd like to configure.
Here's a link to the user manual.
https://products.axiomatic.com/Asset/UMAX021101.pdf
Section 3.0.1 states:
"The only means by which the Node-ID and Baudrate can be changed is to use Layer Setting Services (LSS) and protocols as defined by CANopen standard DS-305."
I've seen a number of posts online that indicate that this can be done by writing a small Codesys program.
Here are two examples:
https://forge.codesys.com/forge/talk/CODESYS-V2/thread/1490774df6/
https://stackoverflow.com/questions/56738715/codesys-and-canopen-multisame-nodeid
Can anyone point me to which libraries and functions are required to send and receive LSS messages?
When you create your I/O configuration with CANopen Manager, automatically the CAA CiA405 library is added. This includes an FB SDO_WRITE4. You can use this to send the LSS messages.
Thank you for your reply and sorry for my delayed response. I was not able to test your suggestion until now.
I've created a program using the SDO_WRITE4 function block and I can now write SDOs. For example, I can change the baud rate of a CANOpen device.
However, I don't understand how to use SDO_WRITE4 to write LSS messages. This function block takes in the destination node-id on the DEVICE input. However, LSS messages use special reserved COB-IDs without node-ids. Is there a way to get around this?
Hi Ben, you are right, I answered too quickly. You need to send a message with own defined COB ID. Probably the CAN Level2 communication is your best option. There is an example project available which contains a library that encapsulates this communication method to access it in an OOP way.
See the store:
https://store.codesys.com/en/canbus-example.html
In the package is a library and an example project. Hopefully this helps.
I've had a look at the example code you pointed me to. Unfortunately, I can't see any examples of a write function that does not use SDO messages. Can you be more specific about which function block might work?
The example project, which is included in the package, shows an example with CFC program (CFC_PRG). This calls the FB MsgProcessor_EchoCFC. This FB calls a method ProcessMessage, which calls the FB CAN.CANSender. This has a reference to the interface of the CANDriver and a reference to the Message you want to send.
So you could use this FB to send any CAN message.
The Message is a struct:
For LSS, you can use as udiCanID - 16#7E5. You always should send 8 bytes for an LSS message.
Oops! I was looking at the wrong example project. It makes sense now. Thanks for your help.