Support multiple motors in CiA 402 CANopen device profile
See original GitHub issueHello,
Currently the ds402 implementation only supports one motor. We would like to extend this to multiple motors as specified by ds402.
We working with a multi-axis board each using CiA 402. We want to be able to control all motors independently of each other.
The CiA 402 standard specifies how to implement multiple motors: Each motor has its own state machine and all the relevant parameters (e.g. Controlword, Statusword). For each subsequent motor the indices are offset by 0x0800. For example, the Controlword of the first motor is 0x6040, the Controlword of the second motor is 0x6840.
Currently the canopen library implements the ds402 state transitions like this:
BaseNode402.state = "OPERATIONAL"
In order for multiple axes to be supported, this could be changed to the following:
BaseNode402.state[0] = "OPERATIONAL"
However, (afaik) there is no good way to implement the latter without breaking the backwards compatibility to the former.
As an alternative, we could have the BaseNode402.state
property for supporting a single axis (the first one) and have a different property for supporting multi-axes implementations:
# Set axes 0 and 1 to operational using the new property
BaseNode402.states[0] = "OPERATIONAL
BaseNode402.states[1] = "OPERATIONAL
# Read the state axis 0 using the old backwards compatible property
print(BaseNode402.state) # Should print "OPERATIONAL"
Would you be interested in an implementation of this for this library?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
The “multiple logical device” is described in CiA301, Object 0x1000 “Device Type”. In case of a multiple device, the upper 16 bits are 0xFFFF. The lower 16 bits (device profile number) is the device profile of the first logical device, in this case 402. For more details see CiA301. With this one CANopen node can contain multiple devices which can be of different types e.g. a drive (device profile 402) combined with Digital IO (device profile 401).
Hi @trinamic-jm,
Ok now is clear to me, sorry for not understanding at first, i’m not aware of the full ds402 specification, I have implemented only the parts that I needed for my requirements and didn’t extended further and also since I don’t have direct access to the ds402 full specification. That being said, I think, in my opinion, that providing a full ds402 implementations through this library would be neat, so I will help as much as I can. If you already have some functional code you can contribute we can create a new branch for this functionality and test it.
So, in resume each node has it’s own NMT state machine, provided by the
class LocalNode(BaseNode)
andclass RemoteNode(BaseNode):
. On the other hand, the classclass BaseNode402(RemoteNode):
has the RemoteNode as base class and implements the ds402 state machine.So, to support multiple ds402 state machines, this must be done inside this class and stored in an array, being the default behavior to access the first position. The existence of more than one device per-node is configured where ??? In the manufacturer reserved area of the Object Dictionary ?? How can we know if more than one device is configured (aka available) for each node ? The library should be manufacture agnostic, and so we need to provided the base same functionality to all device manufacturers and implement ways to resolve this.
Like I said, if you have already something done regarding this and you are willing to contribute to thsi project please share that and I can create a new branch for us to test it.
Thanks 😉