CANOpen Layer Setting Services (LSS)

Ben Lewis
2023-06-08
2023-07-14
  • TimvH

    TimvH - 2023-06-09

    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.

     
  • Ben Lewis - 2023-07-11

    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?

     
  • TimvH

    TimvH - 2023-07-12

    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.

     
  • Ben Lewis - 2023-07-13

    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?

     
  • TimvH

    TimvH - 2023-07-13

    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_STRUCT
    END_TYPE
    

    For LSS, you can use as udiCanID - 16#7E5. You always should send 8 bytes for an LSS message.

     
  • Ben Lewis - 2023-07-14

    Oops! I was looking at the wrong example project. It makes sense now. Thanks for your help.

     

Log in to post a comment.