General question
See original GitHub issuehello, I have had everything working for over a year without issue, but i have been forced to update my image with the beaglebone black, and a lot has changed. i can see my servo drive hearbeat with Candump but i am thinking i have some sort of a disconnect with my python version ? i have “python 2.7.13” as the version the beaglebone uses if i use ‘python -V’… but i can only get the scripts to run by typing python3,
these are examples of the types of errors i am getting any ideas for what i need to investigate would be fantastic, as i fear i am simply starting to mess around without understanding the problem.
`debian@beaglebone:~/my_python$ python3 HelloCan.py Traceback (most recent call last): File “HelloCan.py”, line 37, in <module> node.pdo.rx[3][‘Controlword’, ‘Target position’].phys = 1000 File “/home/debian/.local/lib/python3.5/site-packages/canopen/pdo/base.py”, line 212, in getitem var = self.__getitem_by_index(int(key, 16)) TypeError: int() can’t convert non-string with explicit base
debian@beaglebone:~/my_python$ python3 HelloCan.py
Traceback (most recent call last):
File “HelloCan.py”, line 33, in <module>
node.pdo.export(‘database.dbc’)
File “/home/debian/.local/lib/python3.5/site-packages/canopen/pdo/base.py”, line 68, in export
from canmatrix import canmatrix
ImportError: No module named ‘canmatrix’
`debian@beaglebone:~/my_python$ python3.5 MoveCan.py Traceback (most recent call last): File “MoveCan.py”, line 3, in <module> from canopen.profiles.p402 import Node402 ImportError: cannot import name ‘Node402’
debian@beaglebone:~/my_python$ python3.5 MoveCan.py Traceback (most recent call last): File “MoveCan.py”, line 4, in <module> node = canopen.Node402(32, ‘object_dictionary.eds’) AttributeError: module ‘canopen’ has no attribute ‘Node402’
debian@beaglebone:~/my_python$ python3.5 MoveCan.py Traceback (most recent call last): File “MoveCan.py”, line 6, in <module> network.add_node(node) NameError: name ‘node’ is not defined
debian@beaglebone:~/my_python$ python3.5 MoveCan.py
Traceback (most recent call last):
File “MoveCan.py”, line 9, in <module>
node.setup_402_state_machine()
NameError: name ‘node’ is not defined
Issue Analytics
- State:
- Created 4 years ago
- Comments:9
Top GitHub Comments
Hi @Wez50,
If you are satisfied and don’t need more help, please close the ticket so this thread can be clean, since this is not a software issue, thanks 😉
Hi, that is strange… You don’t need to export, the export is to export da configurations to a ´.dbc´ file. What you need is to first configure the nodes you are trying to control like
If all the configuration nodes are present in the eds file you don’t need to do the configuration by hand like in the code example (e.g.,
node.sdo[0x6040].raw = 0x0F
), make sure to call thenode.load_configuration()
, to make sure the configuration for each node has been loaded correctly you can call thenode.rpdo.read()
andnode.tpdo.read()
.One important thing, the Controlword and Statusword must be well configure. The code used in the example ds402 was used by me to test the correct control of my motor. In my configuration I have to configured the heartbeat (the NMT state Guard) the ensures the nodes are running, if the master can’t reach the nodes, they will shutdown.
EDS example, some of the values
The object 6040 is the ControlWord and the object 6041 is the StatusWord. They are mapped to the RDPO1 and TPDO1 like you can see in the configuration above. My RPDO1 maps the Controlword and the Target velocity, and my TPDO1 maps the Statusworkd and the Velocity Actual Value. This objects are used to issue commands to the drive, also the drive is configured to take action, this is, try to achieve the target velocity at each heart beat sent from the master node (0x80). Also, you need to send using the Controlword the instruction for the drive to move right away, like
In the example above I post some of my code to set the target position of the drive using the State402 class and BaseNode402 class … I can’t however post more code … sorry.
Also make sure your BUS configuration is OK like:
{'bustype': 'socketcan', 'channel': 'slcan0', 'bitrate': 1000000 }
To test, please read using the candump the messages that are being sent in the network bus. The candump is a tool provided by the SocketCAN utils here.
Sorry if I don’t explained my self well, I don’'t have much time now, but please try to see if you are reaching the nodes through the candump and check your configuration. Also don’t look only at the example, it was meant to only show how to start working with the code and access the controllers. The State402 class has a lot of code that helps in the communication with the controllers but you need to read it and understand how they work.