CANOpen; Change node id runtime (from PLC side)

  • chab

    chab - 2011-10-13


    I wonder if I can change the node id of a local CANOpen device, in runtime.
    The goal is to change the node id of a local CANOpen device that is in the PLC's device tree.
    In the device tree I can set the node id before compiling and downloading. But I want to change the node id when the PLC is running!
    The CANOpen devices I use are from 3S: CAN Local Device and CANOpen Manager.

    The topic "Changin of Node ID" ( l viewtopic.php?f=1&t=1224 l ) did not give an answer.
    It is focused on the CANBus side. I'm looking for the CoDeSys side. Espesially ST code.

    Thank you.

  • eschwellinger

    eschwellinger - 2011-10-14

    there is already an entry in your database
    CDS-19465 for this improvement

  • spfeif

    spfeif - 2011-10-14

    I think you might be able to do the following:

    1. Look at pCanOpenNode[sIndex].ucNodeNr . This is the global array that is built from the CANopenmanger windows that you configure the nodes with before build in CoDeSys. Note every time you add a new eds file you will have more Indexs of the pCanOpenNode array, so the indexs can change if you move eds files around. You can find this variable in the CanOpen implicit Variables Global POU when you are online with the PLC when running (To see the data).

    2. If you can write to pCanOpenNode[sIndex].ucNodeNr, it might be read only

    (* Scan the nodes and look for the node ID you want to change MAX_NODEINDEX is a global constant generated by CoDeSys*)
    FOR sEachNode := 0 TO MAX_NODEINDEX DO
       IF ((pCanOpenNode[sEachNode].ucNodeNr  = uold_node_id ))THEN
          pCanOpenNode[sIndex].ucNodeNr := unew_node_id;
                    (* sudo code *)
                    reset_can_stack := TRUE;

    then you would have to perform a reset of the can stack in order for the changes to take effect. If you reset the whole PLC the changes will be gone.

    I'm not sure how to reset the CAN stack.

    You would have to put this in some initialization code.

  • chab

    chab - 2011-10-18

    Thank you.
    Are the array structure pCanOpenNode or the constant MAX_NODEINDEX available in CoDeSys V3?
    At compile time, I get errors.
    I use the CANOpen devices from 3S: CAN Local Device and CANOpen Manager. With CoDeSys V3.4 SP4 Patch 1.

  • spfeif

    spfeif - 2011-10-18

    I'm sorry I really have to pay attention to the forum where this was post which was V3. No this is only available in V23.

  • chab

    chab - 2011-10-18

    With CoDeSys V3:

    I detected that a lot of internal variables of the CANOpen_Manager instance are available for read access.

    For example:
    fpCOM := ADR(CANOpen_Manager_COM);
    COM_m_eBusState := fpCOM^.m_eBusState;
    COM_m_bBusAlarm := fpCOM^.m_bBusAlarm;
    COM_m_bBusError := fpCOM^.m_bBusError;

    Maybe here the node id is available for read / write also. I have to check...

  • eschwellinger

    eschwellinger - 2011-10-21

    Hello Edwin,
    i would not recommend to write directly from the application
    into these structures/fbs. What happens if 3S changes this fb/structures (for example with a new version). ->Your application will not work.
    Recommend to wait till this jira (tracker database) is fixed.


Log in to post a comment.