How to get the instance of a CANopen Master in the Device Tree?

yueqiqi
2026-09-02
2026-11-27
  • yueqiqi - 2026-09-02

    I have been wondering of how to get the instance of a Canopen Master in the device tree, please see the picture in the attachment .

    Could anyone help me?

     
    πŸ‘
    1
  • YIN - 2026-11-27

    Hi yueqiqi, the short answer is that you don't create an instance of the master the way you would a function block. In your screenshot CANopen_Master is already the instance name, the part in brackets is just the device type, so that node is the master itself and it is configured in the device tree rather than declared in your code.

    What you actually work with in a program are the things underneath it. In your picture those are the two encoders, with Axis_CO and Axis_CO_1 below them, and those axis instances are the ones to use when you want to read a position or run motion. The master just handles the bus side of things, starting the nodes and exchanging the PDOs you mapped.

    If what you need is to talk to the master at runtime, for example to send an NMT command or read an SDO, don't add a second master in code, that will only fight with the configured one. Use the CANopen library function blocks for NMT and SDO instead, working against the device you already configured, and check the master's own settings first, node ID, port and heartbeat, since a node that never comes up is usually a configuration or wiring problem rather than a code problem.

    It would help to know what you want to do with it, read the encoder values or control the nodes, because that decides which block to reach for. And one thing from experience, before you try any NMT or start command on a real machine, test it in simulation first and keep the safety loop separate from any test program, don't let a test drive real motion.

     

Log in to post a comment.