question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting same TPDO variable values on two different nodes

See original GitHub issue

Hello,

I have problems when using PDOs with two nodes and a master. First of all, I configure each PDO of each node with the variables that I want to assign them, in the code you will see that I only configure, for each of the nodes, the first 3 TPDOs (currently, there are only 3 for the driver I am using) and then I leave the RPDOs disabled. In the first TPDO I have the variables ‘actual_position’ and ‘position_demand’ configured.

After the configuration I print the ‘actual_position’ and ‘demand_position’ values ​​received by PDO, but in both nodes it prints the same value, and it is always the last one. That is, if I move motor1 , I get the ‘actual_position’ value from the motor1 on both TPDO1 (from node_1 and node_2) , and if I move the motor2, I get the ‘actual_position’ value from the motor2 on both TPDO1 (from node_1 and node_2). The same happens to me with the other variables.

Is it possible to receive the value of each variable in the TPDO of the corresponding node?

I’m using canopen v.1.0.0.

Any help is appreciated.

Thank you

`

    self.node_1.tpdo.read()
    self.node_1.rpdo.read()
    self.node_2.tpdo.read()
    self.node_2.rpdo.read()

    # TPDO1

    self.node_1.tpdo[1].clear()
    self.node_1.tpdo[1].add_variable(PDO_Registers['actual_position'])
    self.node_1.tpdo[1].add_variable(PDO_Registers['demand_position'])
    self.node_1.tpdo[1].trans_type = 0  # Send upon sync
    self.node_1.tpdo[1].enabled = True

    self.node_2.tpdo[1].clear()
    self.node_2.tpdo[1].add_variable(PDO_Registers['actual_position'])
    self.node_2.tpdo[1].add_variable(PDO_Registers['demand_position'])
    self.node_2.tpdo[1].trans_type = 0  # Send upon sync
    self.node_2.tpdo[1].enabled = True

    # TPDO2
    self.node_1.tpdo[2].clear()
    self.node_1.tpdo[2].add_variable(PDO_Registers['current_q_actual'])
    self.node_1.tpdo[2].trans_type = 0  # Send upon sync
    self.node_1.tpdo[2].enabled = True

    self.node_2.tpdo[2].clear()
    self.node_2.tpdo[2].add_variable(PDO_Registers['current_q_actual'])
    self.node_2.tpdo[2].trans_type = 0  # Send upon sync
    self.node_2.tpdo[2].enabled = True

    # TPDO3
    self.node_1.tpdo[3].clear()
    self.node_1.tpdo[3].add_variable(PDO_Registers['sw'])
    self.node_1.tpdo[3].add_variable(PDO_Registers['last_error'])
    self.node_1.tpdo[3].trans_type = 0  # Send upon sync
    self.node_1.tpdo[3].enabled = True

    self.node_2.tpdo[3].clear()
    self.node_2.tpdo[3].add_variable(PDO_Registers['sw'])
    self.node_2.tpdo[3].add_variable(PDO_Registers['last_error'])
    self.node_2.tpdo[3].trans_type = 0  # Send upon sync
    self.node_2.tpdo[3].enabled = True

    # Unused RPDOs
    self.node_1.rpdo[1].clear()
    self.node_1.rpdo[1].enabled = False
    self.node_1.rpdo[2].clear()
    self.node_1.rpdo[2].enabled = False
    self.node_1.rpdo[3].clear()
    self.node_1.rpdo[3].enabled = False

    self.node_2.rpdo[1].clear()
    self.node_2.rpdo[1].enabled = False
    self.node_2.rpdo[2].clear()
    self.node_2.rpdo[2].enabled = False
    self.node_2.rpdo[3].clear()
    self.node_2.rpdo[3].enabled = False

    self.node_1.nmt.state = 'PRE-OPERATIONAL'
    self.node_2.nmt.state = 'PRE-OPERATIONAL'
    self.node_1.tpdo.save()
    self.node_1.rpdo.save()
    self.node_2.tpdo.save()
    self.node_2.rpdo.save()

    self.node_1.nmt.state = 'OPERATIONAL'
    self.node_2.nmt.state = 'OPERATIONAL'

    while True:
        self.__net.sync.transmit()
        actual_position_1 = self.node_1.tpdo[PDO_Registers['actual_position']].raw
        demand_position_1 = self.node_1.tpdo[PDO_Registers['demand_position']].raw
        print("actual_position_1 = " + str(actual_position_1))
        print("demand_position_1 = " + str(demand_position_1))


        actual_position_2 = self.node_2.tpdo[PDO_Registers['actual_position']].raw
        demand_position_2 = self.node_2.tpdo[PDO_Registers['demand_position']].raw
        print("actual_position_2 = " + str(actual_position_2))
        print("demand_position_2 = " + str(demand_position_2))`

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
millerespcommented, May 5, 2020

Hi @af-silva,

Sorry to reply so late again.

First of all, thank you very much for your answer, we have finally managed to change the COB-ID manually using SDOs following the instructions on the Ingenia page, and now it works 😃. Thank you very much for your help, this problem has finally been solved.

On the other hand, I wanted to know if it is possible to use PDOs without using an EDS file, but directly, using just the registers. I have tried it setting the EDS path to None but the clear() function stops working.

Thank you very much again!

0reactions
af-silvacommented, May 5, 2020

Hi @MillerEsp

If you set the EDS to null there is nothing loaded into the Maps and so nothing to Clear.

This what the clear function does, just set the map to an empty array.

    def clear(self):
        """Clear all variables from this map."""
        self.map = []
        self.length = 0

Try to read the PDO’s configuration loaded in the drives using the import_from_node function by providing the node_id and network objects. The function uses SDO’s calls to the remote note do get the PDO’s configuration and stores it in the the object dictionary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Receiving and Transmitting different node PDOs concurrently
My confusion comes from wanting to have multiple node. When i add a secondary node, i go through the same motions of mapping...
Read more >
how to take same variable to two different nodes in cpp
hello , i want to take global variable one node to another without using publisher and subcriber ! can anyone give me idea...
Read more >
Sharing & modifying a variable between multiple files node.js
I'd like to have both @add and @remove manipulate the same variable ( count ), and for @total to return the total of...
Read more >
BPEL, Assign loop from multiple nodes, how to do
(<=> iterate through incoming xml nodes, assign values from one xml node to another variable, and calling another partnerlink...). What I did :...
Read more >
Process Data Object (PDO) - CANopen for Python
With RPDOs you can, for example, start two devices simultaneously. You only need to map the same RPDO into two or more different...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found