Getting same TPDO variable values on two different nodes
See original GitHub issueHello,
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:
- Created 3 years ago
- Comments:7
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!
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.
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.