canopen icon indicating copy to clipboard operation
canopen copied to clipboard

Problem with TPDO mapping

Open MaxD33 opened this issue 3 years ago • 1 comments

Hi Christan,

I tried to tpdo mapping to get voltage values from my Roboteq SBL1360A using socketcan bustype. Here's my code :

import canopen

network = canopen.Network()

node = canopen.RemoteNode(1, '/home/pc_stage/Downloads/roboteq_motor_controllers_v60.eds')

network.add_node(node)

network.connect(bustype='socketcan', channel='slcan0')

node.tpdo.read()

node.tpdo[1].clear()

node.tpdo[1].add_variable('Qry_VOLTS', 'V 5Vout') node.tpdo[1].cob_id = node.tpdo[1].predefined_cob_id node.tpdo[1].enabled = True

node.tpdo.save()

The last line isn't working, I get the following error :

Traceback (most recent call last): File "tpdo.py", line 38, in node.tpdo.save() File "/home/pc_stage/.local/lib/python3.6/site-packages/canopen/pdo/base.py", line 60, in save pdo_map.save() File "/home/pc_stage/.local/lib/python3.6/site-packages/canopen/pdo/base.py", line 341, in save self.com_record[1].raw = self.cob_id | PDO_NOT_VALID File "/home/pc_stage/.local/lib/python3.6/site-packages/canopen/variable.py", line 88, in raw self.data = self.od.encode_raw(value) File "/home/pc_stage/.local/lib/python3.6/site-packages/canopen/variable.py", line 40, in data self.set_data(data) File "/home/pc_stage/.local/lib/python3.6/site-packages/canopen/sdo/base.py", line 112, in set_data self.sdo_node.download(self.od.index, self.od.subindex, data, force_segment) File "/home/pc_stage/.local/lib/python3.6/site-packages/canopen/sdo/client.py", line 155, in download fp.close() File "/home/pc_stage/.local/lib/python3.6/site-packages/canopen/sdo/client.py", line 381, in write response = self.sdo_client.request_response(request) File "/home/pc_stage/.local/lib/python3.6/site-packages/canopen/sdo/client.py", line 85, in request_response return self.read_response() File "/home/pc_stage/.local/lib/python3.6/site-packages/canopen/sdo/client.py", line 73, in read_response raise SdoAbortedError(abort_code) canopen.sdo.exceptions.SdoAbortedError: Code 0x06090030, Value range of parameter exceeded

I don't know the range of what value is exceeded, therefore I can't save any configuration of the TPDO...

Thanks

Maxime

MaxD33 avatar Apr 26 '21 14:04 MaxD33

Hey, I'm having a similar problem.

Maybe you have a restriction on the upper bits of your cob_id parameter of the PDO.

In my case bit 31 enables/disables the PDO (standard) and bit 30 signals if RTR is allowed. But my device requires that bit 30 is always set. The way TPDOs are read and saved by the library causes problems with that.

Your stacktrace shows

self.com_record[1].raw = self.cob_id | PDO_NOT_VALID

the assignment resolves to sth. like

self.com_record[1].raw = self.cob_id & 0x1FFFFFFF | (1 << 31)

where you can see that all higher bits (except 31) are set to 0.

You are already using

node.tpdo[1].cob_id = node.tpdo[1].predefined_cob_id

after reading the tpdo. Maybe at that point you can inject the missing bits, if this is really your problem :)

Maybe checking what your "predefined_cob_id" actually is could also help :)

freelancer1845 avatar Jul 14 '21 21:07 freelancer1845