Hi Gavin,

Thanks for the reply.  After looking at the debug output and looking at the 
driver code to see what was going on, I realized that I had erroneously 
specified the data size in my SDO requests in bits instead of bytes.  After 
correcting that, stuff seems to work much better.

Regards,

Steve

From: Gavin Lambert <gav...@compacsort.com<mailto:gav...@compacsort.com>>
Date: Wednesday, August 13, 2014 6:21 PM
To: Steve Hartmann <shartm...@cnt.canon.com<mailto:shartm...@cnt.canon.com>>, 
Etherlab Users <etherlab-users@etherlab.org<mailto:etherlab-users@etherlab.org>>
Subject: RE: [etherlab-users] Copley CoE issues

Hi,

You should probably start by setting the master to debug level 1, either via 
“ethercat debug 1” on the command line or setting MASTER_ARGS=”debug_level=1” 
in the service configuration file.  This should tell you more of what’s going 
on behind the scenes at the time the failures occur.

There’s been some discussions recently about CoE failures caused by trying to 
do certain things too close together, or while the master is doing certain 
background operations.  There are some patches floating around for some of the 
issues but they haven’t been integrated into mainstream yet, and it’s hard to 
say which of them might help you with this issue without seeing the more 
detailed logs.

Regards,
Gavin Lambert

From: 
etherlab-users-boun...@etherlab.org<mailto:etherlab-users-boun...@etherlab.org> 
[mailto:etherlab-users-boun...@etherlab.org] On Behalf Of Steve Hartmann
Sent: Thursday, 14 August 2014 08:27
To: etherlab-users@etherlab.org<mailto:etherlab-users@etherlab.org>
Subject: [etherlab-users] Copley CoE issues

Hi All,

I am having some issues with CoE on my Copley Accelnet controllers.  CoE reads 
seem to be working fine, but CoE writes work sometimes, but most of the time 
they do not.  So, first the setup.

Linux imcs-ecat-450 3.2.21-xenomai-2.6.2.1 #1 SMP PREEMPT Fri Oct 18 14:13:46 
CDT 2013 x86_64 GNU/Linux
Realtek NIC
Etherlab is latest in 1.5 stable branch
Running in user land
78 ethercat slaves, 24 of which are single axis copley controllers.  The rest 
are Beckhoff I/O.

The operations to the Copley I am testing are get/set acceleration and 
velocity.  The get operations work reliably.  The last message in the dmseg 
dump below is displayed when the write fails, which is most of the time.  
What's weird is once the write operations start working, they keep working.

[14785.862445] EtherCAT: Requesting master 0...
[14785.862453] EtherCAT: Successfully requested master 0.
[14786.023965] EtherCAT 0: Domain0: Logical address 0x00000000, 163 byte, 
expected working counter 24.
[14786.023969] EtherCAT 0:   Datagram domain0-0-main: Logical offset 
0x00000000, 163 byte, type LRW.
[14786.023973] EtherCAT 0: Domain1: Logical address 0x000000a3, 19 byte, 
expected working counter 11.
[14786.023976] EtherCAT 0:   Datagram domain1-163-main: Logical offset 
0x000000a3, 19 byte, type LRW.
[14786.023980] EtherCAT 0: Domain2: Logical address 0x000000b6, 13 byte, 
expected working counter 9.
[14786.023982] EtherCAT 0:   Datagram domain2-182-main: Logical offset 
0x000000b6, 13 byte, type LRW.
[14786.023986] EtherCAT 0: Domain3: Logical address 0x000000c3, 49 byte, 
expected working counter 11.
[14786.023988] EtherCAT 0:   Datagram domain3-195-main: Logical offset 
0x000000c3, 49 byte, type LRW.
[14786.023991] EtherCAT 0: Domain4: Logical address 0x000000f4, 60 byte, 
expected working counter 8.
[14786.023994] EtherCAT 0:   Datagram domain4-244-main: Logical offset 
0x000000f4, 60 byte, type LRW.
[14786.023997] EtherCAT 0: Domain5: Logical address 0x00000130, 84 byte, 
expected working counter 12.
[14786.024000] EtherCAT 0:   Datagram domain5-304-main: Logical offset 
0x00000130, 84 byte, type LWR.
[14786.024003] EtherCAT 0: Domain6: Logical address 0x00000184, 84 byte, 
expected working counter 12.
[14786.024006] EtherCAT 0:   Datagram domain6-388-main: Logical offset 
0x00000184, 84 byte, type LRD.
[14786.024009] EtherCAT 0: Domain7: Logical address 0x000001d8, 84 byte, 
expected working counter 12.
[14786.024012] EtherCAT 0:   Datagram domain7-472-main: Logical offset 
0x000001d8, 84 byte, type LWR.
[14786.024015] EtherCAT 0: Domain8: Logical address 0x0000022c, 84 byte, 
expected working counter 12.
[14786.024018] EtherCAT 0:   Datagram domain8-556-main: Logical offset 
0x0000022c, 84 byte, type LRD.
[14786.024021] EtherCAT 0: Domain9: Logical address 0x00000280, 49 byte, 
expected working counter 7.
[14786.024032] EtherCAT 0:   Datagram domain9-640-main: Logical offset 
0x00000280, 49 byte, type LWR.
[14786.024036] EtherCAT 0: Domain10: Logical address 0x000002b1, 49 byte, 
expected working counter 7.
[14786.024038] EtherCAT 0:   Datagram domain10-689-main: Logical offset 
0x000002b1, 49 byte, type LRD.
[14786.024041] EtherCAT 0: Domain11: Logical address 0x000002e2, 7 byte, 
expected working counter 1.
[14786.024044] EtherCAT 0:   Datagram domain11-738-main: Logical offset 
0x000002e2, 7 byte, type LWR.
[14786.024047] EtherCAT 0: Domain12: Logical address 0x000002e9, 7 byte, 
expected working counter 1.
[14786.024049] EtherCAT 0:   Datagram domain12-745-main: Logical offset 
0x000002e9, 7 byte, type LRD.
[14786.024063] EtherCAT 0: Master thread exited.
[14786.024066] EtherCAT 0: Starting EtherCAT-OP thread.
[14786.025804] EtherCAT WARNING 0: No app_time received up to now, but master 
already active.
[14786.033014] EtherCAT 0: Domain 0: Working counter changed to 1/24.
[14786.388934] EtherCAT 0: Domain 5: Working counter changed to 1/12.
[14786.388938] EtherCAT 0: Domain 6: Working counter changed to 1/12.
[14786.834689] EtherCAT 0: Domain 1: Working counter changed to 1/11.
[14786.960483] EtherCAT 0: Domain 7: Working counter changed to 1/12.
[14786.960982] EtherCAT 0: Domain 8: Working counter changed to 1/12.
[14787.032363] EtherCAT 0: Domain 0: 18 working counter changes - now 24/24.
[14787.387777] EtherCAT 0: Domain 5: 11 working counter changes - now 12/12.
[14787.387781] EtherCAT 0: Domain 6: 11 working counter changes - now 12/12.
[14787.440695] EtherCAT 0: Domain 9: Working counter changed to 1/7.
[14787.440698] EtherCAT 0: Domain 10: Working counter changed to 1/7.
[14787.685284] EtherCAT 0: Domain 2: Working counter changed to 1/9.
[14787.779137] EtherCAT 0: Domain 11: Working counter changed to 1/1.
[14787.779140] EtherCAT 0: Domain 12: Working counter changed to 1/1.
[14787.786119] EtherCAT 0: Domain 3: Working counter changed to 1/11.
[14787.834040] EtherCAT 0: Domain 1: 5 working counter changes - now 11/11.
[14787.880966] EtherCAT 0: Domain 4: Working counter changed to 1/8.
[14787.959831] EtherCAT 0: Domain 7: 11 working counter changes - now 12/12.
[14787.959834] EtherCAT 0: Domain 8: 11 working counter changes - now 12/12.
[14787.970600] EtherCAT 0: Slave states on main device: OP.
[14788.440065] EtherCAT 0: Domain 9: 6 working counter changes - now 7/7.
[14788.440068] EtherCAT 0: Domain 10: 6 working counter changes - now 7/7.
[14788.684660] EtherCAT 0: Domain 2: 6 working counter changes - now 9/9.
[14788.785493] EtherCAT 0: Domain 3: 7 working counter changes - now 11/11.
[14788.880334] EtherCAT 0: Domain 4: 5 working counter changes - now 8/8.
[14816.612788] EtherCAT ERROR 0-25: Timeout after 1000 ms while waiting for SDO 
0x6083:0 download response.

Below is the function which does the CoE processing.

struct SDORecord {
    ec_sdo_request_t* sdo;
    ec_direction_t    direction;
    bool              inProgress;
    bool              ioError;
    bool              persistent;  // Never removed from execution list
    void*             data;
    EtherCATMaster::TECDataType
     dataType;
    RT_SEMcompleteSignal;
    SDORecord*       nextExec;
  };

void CopleyEcatDrive::processCoE()
{
  SDORecord* p = SDOExecutionList;
  SDORecord* next;
  ec_request_state_t reqState;
  while (p != NULL) {
    next = p->nextExec;
    reqState = ecrt_sdo_request_state(p->sdo);
    if (p->inProgress == false && reqState != EC_REQUEST_BUSY) {
      p->inProgress = true;
      if (p->direction == EC_DIR_INPUT) {
        rt_printf("Read SDO received: addr:0x%x\n", p);
        ecrt_sdo_request_read(p->sdo);
      } else if (p->direction == EC_DIR_OUTPUT) {
        rt_printf("Write SDO received: addr:0x%x\n", p);
        switch (p->dataType) {
        case EtherCATMaster::EC_DATATYPE_SHORT:
          EC_WRITE_S8(ecrt_sdo_request_data(p->sdo), 
*reinterpret_cast<int8_t*>(p->data));
          break;
        case EtherCATMaster::EC_DATATYPE_USHORT:
          EC_WRITE_U8(ecrt_sdo_request_data(p->sdo), 
*reinterpret_cast<uint8_t*>(p->data));
          break;
        case EtherCATMaster::EC_DATATYPE_INT:
          EC_WRITE_S16(ecrt_sdo_request_data(p->sdo), 
*reinterpret_cast<int16_t*>(p->data));
          break;
        case EtherCATMaster::EC_DATATYPE_UINT:
          EC_WRITE_U16(ecrt_sdo_request_data(p->sdo), 
*reinterpret_cast<uint16_t*>(p->data));
          break;
        case EtherCATMaster::EC_DATATYPE_LONG:
          EC_WRITE_S32(ecrt_sdo_request_data(p->sdo), 
*reinterpret_cast<int32_t*>(p->data));
          break;
        case EtherCATMaster::EC_DATATYPE_ULONG:
          EC_WRITE_U32(ecrt_sdo_request_data(p->sdo), 
*reinterpret_cast<uint32_t*>(p->data));
          break;
default:
 break;
        }
        ecrt_sdo_request_write(p->sdo);
      } else {
        rt_printf("Invalid SDO direction.\n");
        p->inProgress = false;
        rt_sem_v(&(p->completeSignal));
        removeFromSDOExecutionList(p);
      }
    } else if (p->inProgress == true && reqState == EC_REQUEST_SUCCESS) {
      p->inProgress = false;
      p->ioError = false;
      if (p->direction == EC_DIR_INPUT) {
        rt_printf("Read SDO Completed: addr:0x%x\n", p);
        switch (p->dataType) {
        case EtherCATMaster::EC_DATATYPE_SHORT:
          *reinterpret_cast<int8_t*>(p->data) = 
EC_READ_S8(ecrt_sdo_request_data(p->sdo));
          break;
        case EtherCATMaster::EC_DATATYPE_USHORT:
          *reinterpret_cast<uint8_t*>(p->data) = 
EC_READ_U8(ecrt_sdo_request_data(p->sdo));
          break;
        case EtherCATMaster::EC_DATATYPE_INT:
          *reinterpret_cast<int16_t*>(p->data) = 
EC_READ_S16(ecrt_sdo_request_data(p->sdo));
          break;
        case EtherCATMaster::EC_DATATYPE_UINT:
          *reinterpret_cast<uint16_t*>(p->data) = 
EC_READ_U16(ecrt_sdo_request_data(p->sdo));
          break;
        case EtherCATMaster::EC_DATATYPE_LONG:
          *reinterpret_cast<int32_t*>(p->data) = 
EC_READ_S32(ecrt_sdo_request_data(p->sdo));
          break;
        case EtherCATMaster::EC_DATATYPE_ULONG:
          *reinterpret_cast<uint32_t*>(p->data) = 
EC_READ_U32(ecrt_sdo_request_data(p->sdo));
          break;
default:
 break;
        }
      } else if (p->direction == EC_DIR_OUTPUT) {
        rt_printf("Write SDO Completed: addr:0x%x\n", p);
      }
      rt_sem_v(&(p->completeSignal));
      if (p->persistent == false) {
        removeFromSDOExecutionList(p);
      }
    } else if (p->inProgress == true && reqState == EC_REQUEST_ERROR) {
// **** This is the failure path that I see on CoE writes
      rt_printf("SDO Had error: addr:0x%x, direction: %d\n", p, p->direction);
      p->inProgress = false;
      p->ioError = true;
      rt_sem_v(&(p->completeSignal));
      if (p->persistent == false) {
        removeFromSDOExecutionList(p);
      }
    }
    p = next;
  }
}

_______________________________________________
etherlab-users mailing list
etherlab-users@etherlab.org
http://lists.etherlab.org/mailman/listinfo/etherlab-users

Reply via email to