CANopenNode / CANopenSocket

Obsolete repository, replaced by CANopenDemo and CANopenLinux
Apache License 2.0
208 stars 119 forks source link

Problem while sending SDO request #16

Closed fzoric8 closed 4 years ago

fzoric8 commented 4 years ago

Hi, I've been to set up CAN communication with one master and two motor drivers and I have certain questions. I may misunderstood some things, but I would kindly appreciate some guidance.

I've connected my PC to PEAK-CAN USB on Linux PC which provided me with all necessary drivers for usage. As I mentioned, I'm trying to use PC as master CAN node which will send commands to motor drivers which are slave nodes.

I've set up can0 interface on PC and I'm hearing heartbeat from motor drivers. Therefore, communication channel is established.

In basic CANopenSocket tutorial I've been writing/reading SDO commands provided in tutorial but there are few things I'm not quite sure about. With CLI interface I've been providing -s and -a arguments which are paths to empty OD file. It would be great if there's example of valid OD for certain device cause provided empty ODs are not of much usage. It's also not so clear from the tutorial which node is master node. And how to properly run master or client node and distingusih between them.

I've tried to initiate SDO read with method sdoClientUpload but it always fails in method CO_SDO_initTransfer in CO_OD_find method. Return error code is CO_SDO_AB_NOT_EXIST. It's quite clear that I don't have valid values written in OD for certain index and subindex, but I've thought that CO_SDOclient_setup sets those Object Dictionary Variables. Could you please provide some guidance.

Main questions are:

  1. How to set up master node? What distinguishes master from client node when running CO_init or method.
  2. How to provide valid OD for certain device?
  3. How to initiate valid SDO client which correctly sets up variables in OD?

Just to make sure, even using provided CLI with correct nodeID and sending SDO read command on socket makes my motor driver heartbeat alternate between 7F, 05 and 85 states which is quite weird. I'm sorry if I missed something but help would mean a lot. Thank you. :)

CANopenNode commented 4 years ago

Hi,

First, in CANopen there is no strong distinguish between master and slave node. Basically all nodes have SDO server and own Object Dictionary. Some nodes can also have some master functionalities like SDO client or NMT master.

You don't have to install any drivers for PEAK-CAN USB, because Linux kernel already has support.

In CANopenSocket there is ascii command interace for using SDO client and NMT master, as shown by examples.

"od4_storage" files are used only for storing values from local object dictionary. After you execute command ./canopencomm 4 w 0x1010 1 u32 0x65766173 it should not be empty any more.

Object Dictionary is provided by CO_OD.h and CO_OD.c files. They are automatically generated from _project.xml file. You can edit then with https://github.com/robincornelius/libedssharp tool.

In general, you don't have to do any special to set-up CANopenSocket. SDO client should work out-of-the-box.

If you show some outputs from candump command, it will be easier to help. Please also note emergency messages from your driver. You may also have forgotten to add terminating resistors to CAN bus, etc.

Very efficient way to get familiar with CANopen is also reading a book, for example https://can-newsletter.org/engineering/engineering-miscellaneous/nr_e_cia_can_books_3-2008_emb_can_pfeiffer_120529

fzoric8 commented 4 years ago

Thank you for your fast reply. Some things are far clearer now :+1: