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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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).
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*)FORsEachNode:=0TOMAX_NODEINDEXDO  IF((pCanOpenNode[sEachNode].ucNodeNr =uold_node_id))THEN    pCanOpenNode[sIndex].ucNodeNr:=unew_node_id;        (* sudo code *)        reset_can_stack:=TRUE;  END_IFEND_FOR
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Steve,
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.
Ed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
E.Schwellinger
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
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.
hello,
there is already an entry in your database
CDS-19465 for this improvement
cu
Edi
I think you might be able to do the following:
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).
If you can write to pCanOpenNode[sIndex].ucNodeNr, it might be read only
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.
Steve,
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.
Ed.
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.
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...
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.
E.Schwellinger