canopen icon indicating copy to clipboard operation
canopen copied to clipboard

FAULT state and Timeout when trying to change state

Open Cdfghglz opened this issue 3 years ago • 3 comments

Hi

Being pretty new to CANopen I am struggling to control multiple nodes. With the following code a single node works, but when connecting more, the nodes randomly go to FAULT state and canopen throws RuntimeError('Timeout when trying to change state',).

NOTE: The code below is extracted from classes so it may be a little inconsistent.

network = canopen.Network()
network.connect(channel='can0', bustype='socketcan', bitrate=500000)
network.sync.start(0.15)

...

for motor in motors:
    Motor('*.dcf', node_id)

...

for motor in motors:
    motor.initialize(op_mode)
...

class Motor
    def __init__(self, dcf, network, node_id=1):
        ...
        # connect the node
        self.__node = BaseNode402(node_id, dcf)
        network.add_node(self.__node)

        self.__node.setup_402_state_machine()
        self.__node.nmt.start_node_guarding(0.01)
        ...

    def initialize(self, op_mode="PROFILED POSITION"):
        ...
        self.__node.op_mode = op_mode
        self.__command_index = self.__command_index_dict[op_mode]

        # set up the communication PDOs?
        self.__node.nmt.state = "PRE-OPERATIONAL"
        time.sleep(1)

        # TODO: is this section needed at all?
        self.__node.tpdo.read()
        self.__node.rpdo.read()
        time.sleep(0.4)

        # init the receive PDO variables
        self.__node.rpdo[self.__pdo_channel].clear()
        self.__node.rpdo[self.__pdo_channel].add_variable(0x6040)
        self.__node.rpdo[self.__pdo_channel].add_variable(self.__command_index)
        self.__node.rpdo[self.__pdo_channel].enabled = True
        self.__node.rpdo.save()
        self.__node.tpdo.save()

        time.sleep(0.4)
        self.__node.nmt.state = "OPERATIONAL"
        time.sleep(1)

        time.sleep(1)
        self.__node.state = "OPERATION ENABLED"

Usually the issues happen before the last line in the block above.

Could you please identify any trivial mistake I'm making? Is there any valuable resource that addresses the topic?

Thanks a lot!

Cdfghglz avatar Sep 17 '21 10:09 Cdfghglz

Hi @Cdfghglz,

What is the Fault code ?? Is the node guard configuration on the drives well configured?

best regards.

af-silva avatar Sep 21 '21 10:09 af-silva

Thanks @af-silva for your response.

It seems not to be quite deterministic, we've seen 8120 and 8110 motor errors.

After some debugging we seem to also be running into https://github.com/christiansandberg/canopen/issues/234. I will come back with more details as soon as we look into the 234.

Cdfghglz avatar Sep 22 '21 13:09 Cdfghglz

A quick search:

  • 8110h: CAN overrun (data frame lost)
  • 8120h: CAN protocol controller in error passive mode (node cannot indicate bus errors, when it is a receiver)

So, this is 81xxh that means is a Communication problem, check if the drivers and the CAN adapter you are using are ok...

af-silva avatar Sep 23 '21 08:09 af-silva