Andreas, Here is the output from:
1. $ ethercat slaves -v === Master 0, Slave 0 === State: PREOP Flag: + Identity: Vendor Id: 0x00000002 Product code: 0x044c2c52 Revision number: 0x00110000 Serial number: 0x00000000 DL information: FMMU bit operation: no Distributed clocks: yes, 64 bit DC system time transmission delay: 0 ns Port Type Link Loop Signal NextSlave RxTime [ns] Diff [ns] NextDc [ns] 0 MII up open yes - 2549051802 0 0 1 EBUS up open yes 1 2549052242 440 220 2 MII down closed no - - - - 3 N/A down closed no - - - - General: Group: SystemBk Image name: Order number: EK1100 Device name: EK1100 EtherCAT-Koppler (2A E-Bus) Flags: Enable SafeOp: no Enable notLRW: no Current consumption: -2000 mA === Master 0, Slave 1 === State: PREOP Flag: + Identity: Vendor Id: 0x00000002 Product code: 0x07d43052 Revision number: 0x00100000 Serial number: 0x00000000 DL information: FMMU bit operation: no Distributed clocks: yes, 64 bit DC system time transmission delay: 220 ns Port Type Link Loop Signal NextSlave RxTime [ns] Diff [ns] NextDc [ns] 0 EBUS up open yes 0 2549892332 0 220 1 EBUS up open yes - 2549892482 150 0 2 N/A down closed no - - - - 3 N/C down closed no - - - - General: Group: DigOut Image name: TERM_DO Order number: EL2004 Device name: EL2004 4K. Dig. Ausgang 24V, 0.5A Flags: Enable SafeOp: no Enable notLRW: no Current consumption: 100 mA 2. $ ethercat master -v Master0 Phase: Idle Active: no Slaves: 2 Ethernet devices: Main: 00:04:5f:b0:8e:49 (attached) Link: UP Tx frames: 126992 Rx frames: 126991 Lost frames: 0 Tx bytes: 7619664 Tx errors: 0 Tx frame rate [1/s]: 525 542 534 Tx rate [KByte/s]: 30.8 31.8 31.3 Loss rate [1/s]: 0 0 0 Frame loss [%]: 0.0 0.0 0.0 Backup: None. Distributed clocks: Reference clock: Slave 0 Application time: 0 2000-01-01 00:00:00.000000000 3. And here is my code (I just modified the user example main.c a bit): /***************************************************************************** * * $Id$ * * Copyright (C) 2007-2009 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * * The IgH EtherCAT Master is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2, as * published by the Free Software Foundation. * * The IgH EtherCAT Master is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details. * * You should have received a copy of the GNU General Public License along * with the IgH EtherCAT Master; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * The license mentioned above concerns the source code only. Using the * EtherCAT technology and brand is only permitted in compliance with the * industrial property and similar rights of Beckhoff Automation GmbH. * ****************************************************************************/ #include <errno.h> #include <signal.h> #include <stdio.h> #include <string.h> #include <sys/resource.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> /****************************************************************************/ #include "ecrt.h" /****************************************************************************/ // Application parameters #define FREQUENCY 100 #define PRIORITY 1 // Optional features #define CONFIGURE_PDOS 1 #define SDO_ACCESS 0 /****************************************************************************/ // EtherCAT static ec_master_t *master = NULL; static ec_master_state_t master_state = {}; static ec_domain_t *domain1 = NULL; static ec_domain_state_t domain1_state = {}; static ec_slave_config_t *sc_ana_in = NULL; static ec_slave_config_state_t sc_ana_in_state = {}; // Timer static unsigned int sig_alarms = 0; static unsigned int user_alarms = 0; /****************************************************************************/ // process data static uint8_t *domain1_pd = NULL; // nj -- this was found from command: $ ethercat slaves #define BusCouplerPos 0, 0 #define DigOutSlavePos 0, 1 #define DigInSlavePos 0, 2 #define AnaOutSlavePos 0, 3 #define AnaInSlavePos 0, 4 // nj -- this was found from the command: $ ethercat slaves -v // or it can be found when using ethercat cstruct option #define Beckhoff_EK1100 0x00000002, 0x044c2c52 // bus coupler #define Beckhoff_EL2004 0x00000002, 0x07d43052 // digital output #define Beckhoff_EL1004 0x00000002, 0x03ec3052 // digital input #define Beckhoff_EL4132 0x00000002, 0x10243052 // analog output #define Beckhoff_EL3102 0x00000002, 0x0c1e3052 // analog input // offsets for PDO entries static unsigned int off_ana_in_status; static unsigned int off_ana_in_value; static unsigned int off_ana_out; static unsigned int off_dig_out; static unsigned int off_dig_in; // nj -- added const static ec_pdo_entry_reg_t domain1_regs[] = { {DigOutSlavePos, Beckhoff_EL2004, 0x7000, 1, &off_dig_out}, {DigInSlavePos, Beckhoff_EL1004, 0x6000, 1, &off_dig_in}, {AnaOutSlavePos, Beckhoff_EL4132, 0x3001, 1, &off_ana_out}, {AnaInSlavePos, Beckhoff_EL3102, 0x3101, 1, &off_ana_in_status}, {AnaInSlavePos, Beckhoff_EL3102, 0x3101, 2, &off_ana_in_value}, {} }; static unsigned int counter = 0; static unsigned int blink = 0; /*****************************************************************************/ #if CONFIGURE_PDOS // DIGITAL OUTPUT /* Master 0, Slave 1, "EL2004" * Vendor ID: 0x00000002 * Product code: 0x07d43052 * Revision number: 0x00100000 */ ec_pdo_entry_info_t el2004_pdo_entries[] = { {0x7000, 0x01, 1}, /* Output */ {0x7010, 0x01, 1}, /* Output */ {0x7020, 0x01, 1}, /* Output */ {0x7030, 0x01, 1}, /* Output */ }; ec_pdo_info_t el2004_pdos[] = { {0x1600, 1, el2004_pdo_entries + 0}, /* Channel 1 */ {0x1601, 1, el2004_pdo_entries + 1}, /* Channel 2 */ {0x1602, 1, el2004_pdo_entries + 2}, /* Channel 3 */ {0x1603, 1, el2004_pdo_entries + 3}, /* Channel 4 */ }; ec_sync_info_t el2004_syncs[] = { {0, EC_DIR_OUTPUT, 4, el2004_pdos + 0, EC_WD_ENABLE}, {0xff} }; // DIGITAL INPUT /* Master 0, Slave 2, "EL1004" * Vendor ID: 0x00000002 * Product code: 0x03ec3052 * Revision number: 0x00100000 */ ec_pdo_entry_info_t el1004_pdo_entries[] = { {0x6000, 0x01, 1}, /* Input */ {0x6010, 0x01, 1}, /* Input */ {0x6020, 0x01, 1}, /* Input */ {0x6030, 0x01, 1}, /* Input */ }; ec_pdo_info_t el1004_pdos[] = { {0x1a00, 1, el1004_pdo_entries + 0}, /* Channel 1 */ {0x1a01, 1, el1004_pdo_entries + 1}, /* Channel 2 */ {0x1a02, 1, el1004_pdo_entries + 2}, /* Channel 3 */ {0x1a03, 1, el1004_pdo_entries + 3}, /* Channel 4 */ }; ec_sync_info_t el1004_syncs[] = { {0, EC_DIR_INPUT, 4, el1004_pdos + 0, EC_WD_DISABLE}, {0xff} }; // ANALOG OUTPUT /* Master 0, Slave 3, "EL4132" * Vendor ID: 0x00000002 * Product code: 0x10243052 * Revision number: 0x00000000 */ ec_pdo_entry_info_t el4132_pdo_entries[] = { {0x3001, 0x01, 16}, /* Value */ {0x3002, 0x01, 16}, /* Value */ }; ec_pdo_info_t el4132_pdos[] = { {0x1600, 1, el4132_pdo_entries + 0}, /* RxPDO 001 mapping */ {0x1601, 1, el4132_pdo_entries + 1}, /* RxPDO 002 mapping */ }; ec_sync_info_t el4132_syncs[] = { {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE}, {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, {2, EC_DIR_OUTPUT, 2, el4132_pdos + 0, EC_WD_DISABLE}, {3, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, {0xff} }; // ANALOG INPUT /* Master 0, Slave 4, "EL3102" * Vendor ID: 0x00000002 * Product code: 0x0c1e3052 * Revision number: 0x00000000 */ ec_pdo_entry_info_t el3102_pdo_entries[] = { {0x3101, 0x01, 8}, {0x3101, 0x02, 16}, {0x3102, 0x01, 8}, {0x3102, 0x02, 16}, }; ec_pdo_info_t el3102_pdos[] = { {0x1a00, 2, el3102_pdo_entries + 0}, /* TxPDO 001 mapping */ {0x1a01, 2, el3102_pdo_entries + 2}, /* TxPDO 002 mapping */ }; ec_sync_info_t el3102_syncs[] = { {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE}, {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE}, {2, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE}, {3, EC_DIR_INPUT, 2, el3102_pdos + 0, EC_WD_DISABLE}, {0xff} }; #endif /*****************************************************************************/ #if SDO_ACCESS static ec_sdo_request_t *sdo; #endif /*****************************************************************************/ void check_domain1_state(void) { ec_domain_state_t ds; ecrt_domain_state(domain1, &ds); if (ds.working_counter != domain1_state.working_counter) //printf("Domain1: WC %u.\n", ds.working_counter); if (ds.wc_state != domain1_state.wc_state) //printf("Domain1: State %u.\n", ds.wc_state); domain1_state = ds; } /*****************************************************************************/ void check_master_state(void) { ec_master_state_t ms; ecrt_master_state(master, &ms); if (ms.slaves_responding != master_state.slaves_responding) //printf("%u slave(s).\n", ms.slaves_responding); if (ms.al_states != master_state.al_states) //printf("AL states: 0x%02X.\n", ms.al_states); if (ms.link_up != master_state.link_up) //printf("Link is %s.\n", ms.link_up ? "up" : "down"); master_state = ms; } /*****************************************************************************/ void check_slave_config_states(void) { ec_slave_config_state_t s; ecrt_slave_config_state(sc_ana_in, &s); if (s.al_state != sc_ana_in_state.al_state) //printf("AnaIn: State 0x%02X.\n", s.al_state); if (s.online != sc_ana_in_state.online) //printf("AnaIn: %s.\n", s.online ? "online" : "offline"); if (s.operational != sc_ana_in_state.operational) //printf("AnaIn: %soperational.\n", //s.operational ? "" : "Not "); sc_ana_in_state = s; } /*****************************************************************************/ #if SDO_ACCESS void read_sdo(void) { switch (ecrt_sdo_request_state(sdo)) { case EC_REQUEST_UNUSED: // request was not used yet ecrt_sdo_request_read(sdo); // trigger first read break; case EC_REQUEST_BUSY: fprintf(stderr, "Still busy...\n"); break; case EC_REQUEST_SUCCESS: fprintf(stderr, "SDO value: 0x%04X\n", EC_READ_U16(ecrt_sdo_request_data(sdo))); ecrt_sdo_request_read(sdo); // trigger next read break; case EC_REQUEST_ERROR: fprintf(stderr, "Failed to read SDO!\n"); ecrt_sdo_request_read(sdo); // retry reading break; } } #endif /****************************************************************************/ void cyclic_task() { int i; // receive process data ecrt_master_receive(master); ecrt_domain_process(domain1); // check process data state (optional) check_domain1_state(); /* if (counter) { */ /* counter--; */ /* } else { // do this at 1 Hz */ // counter = FREQUENCY; // calculate new process data blink = !blink; // check for master state (optional) //check_master_state(); // check for islave configuration state(s) (optional) //check_slave_config_states(); #if SDO_ACCESS // read process data SDO read_sdo(); #endif // } #if 0 // read process data printf("AnaIn: state %u value %u\n", EC_READ_U8(domain1_pd + off_ana_in_status), EC_READ_U16(domain1_pd + off_ana_in_value)); #endif #if 1 // write process data EC_WRITE_U8(domain1_pd + off_dig_out, blink ? 0x01 : 0x00); #endif // send process data ecrt_domain_queue(domain1); ecrt_master_send(master); } /****************************************************************************/ void signal_handler(int signum) { switch (signum) { case SIGALRM: sig_alarms++; break; } } /****************************************************************************/ int main(int argc, char **argv) { ec_slave_config_t *sc; struct sigaction sa; struct itimerval tv; master = ecrt_request_master(0); if (!master) return -1; domain1 = ecrt_master_create_domain(master); if (!domain1) return -1; if (!(sc_ana_in = ecrt_master_slave_config( master, AnaInSlavePos, Beckhoff_EL3102))) { fprintf(stderr, "Failed to get slave configuration.\n"); return -1; } #if SDO_ACCESS fprintf(stderr, "Creating SDO requests...\n"); if (!(sdo = ecrt_slave_config_create_sdo_request(sc_ana_in, 0x3102, 2, 2))) { fprintf(stderr, "Failed to create SDO request.\n"); return -1; } ecrt_sdo_request_timeout(sdo, 500); // ms #endif #if CONFIGURE_PDOS printf("Configuring PDOs...\n"); if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3102_syncs)) { fprintf(stderr, "Failed to configure PDOs (3102).\n"); return -1; } if (!(sc = ecrt_master_slave_config( master, AnaOutSlavePos, Beckhoff_EL4132))) { fprintf(stderr, "Failed to get slave configuration.\n"); return -1; } if (ecrt_slave_config_pdos(sc, EC_END, el4132_syncs)) { fprintf(stderr, "Failed to configure PDOs (4132).\n"); return -1; } if (!(sc = ecrt_master_slave_config( master, DigOutSlavePos, Beckhoff_EL2004))) { fprintf(stderr, "Failed to get slave configuration.\n"); return -1; } if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) { fprintf(stderr, "Failed to configure PDOs (2004).\n"); return -1; } if (!(sc = ecrt_master_slave_config( master, DigInSlavePos, Beckhoff_EL1004))) { fprintf(stderr, "Failed to get slave configuration.\n"); return -1; } if (ecrt_slave_config_pdos(sc, EC_END, el1004_syncs)) { fprintf(stderr, "Failed to configure PDOs (1004).\n"); return -1; } #endif // Create configuration for bus coupler sc = ecrt_master_slave_config(master, BusCouplerPos, Beckhoff_EK1100); if (!sc) return -1; if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { fprintf(stderr, "PDO entry registration failed (EK1100)!\n"); return -1; } //printf("Activating master...\n"); if (ecrt_master_activate(master)) return -1; if (!(domain1_pd = ecrt_domain_data(domain1))) { return -1; } #if PRIORITY pid_t pid = getpid(); if (setpriority(PRIO_PROCESS, pid, -19)) fprintf(stderr, "Warning: Failed to set priority: %s\n", strerror(errno)); #endif sa.sa_handler = signal_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; if (sigaction(SIGALRM, &sa, 0)) { fprintf(stderr, "Failed to install signal handler!\n"); return -1; } //printf("Starting timer...\n"); tv.it_interval.tv_sec = 0; tv.it_interval.tv_usec = 250;//1000000 / FREQUENCY; tv.it_value.tv_sec = 0; tv.it_value.tv_usec = 1000; if (setitimer(ITIMER_REAL, &tv, NULL)) { fprintf(stderr, "Failed to start timer: %s\n", strerror(errno)); return 1; } while (1) { pause(); #if 0 struct timeval t; gettimeofday(&t, NULL); printf("%u.%06u\n", t.tv_sec, t.tv_usec); #endif while (sig_alarms != user_alarms) { cyclic_task(); user_alarms++; } } return 0; } /****************************************************************************/ On Mon, Nov 22, 2010 at 11:43 PM, Andreas Stewering-Bone <a...@igh-essen.com>wrote: > Hello Newell, > > There seems to be a communication problem. > > can you reduce the slaves only using the EK1100 and the EL2004 > > and post > > ethercat slaves -v > > and > > ethercat master -v > > and maybe your code > > Greatings > > > Andreas > > > > Newell Jensen schrieb: > >> Hello All, >> >> I am in the middle of trying to test a simple cyclic loop that toggles the >> digital output of the EL2004 which is attached to the EK1100. We have an >> oscilloscope attached to this digital output so that we can verify the >> square waveform that is created from the toggling of this digital output to >> see how fast the system can respond. However, we are getting some bleeps in >> this waveform and I believe they are coming from the following errors: >> >> [ 24.920744] EtherCAT: Accepting device 00:04:5F:B0:8E:49 for master 0. >> [ 24.920924] ec_generic: Binding socket to interface 3 (eth1). >> [ 24.930057] EtherCAT 0: Starting EtherCAT-IDLE thread. >> [ 25.532553] e1000e: eth1 NIC Link is Up 100 Mbps Full Duplex, Flow >> Control: None >> [ 25.532724] 0000:02:00.0: eth1: 10/100 speed: disabling TSO >> [ 25.533311] EtherCAT 0: Link state changed to UP. >> [ 25.533401] ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready >> [ 25.535026] EtherCAT 0: 5 slave(s) responding. >> [ 25.535160] EtherCAT 0: Slave states: PREOP. >> [ 25.537370] EtherCAT 0: Scanning bus. >> [ 27.158003] e1000e: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow >> Control: RX/TX >> [ 27.384322] EtherCAT WARNING 0: 1 datagram TIMED OUT! >> [ 27.596617] EtherCAT ERROR 0-4: Reception of CoE upload request for SDO >> 0x1c12:0 failed with timeout after 1000 ms: No response. >> [ 27.596636] EtherCAT ERROR 0-4: Failed to read number of assigned PDOs >> for SM2. >> [ 28.596325] EtherCAT ERROR 0-4: Reception of CoE upload request for SDO >> 0x1c13:0 failed with timeout after 1000 ms: No response. >> [ 28.596344] EtherCAT ERROR 0-4: Failed to read number of assigned PDOs >> for SM3. >> [ 28.596355] EtherCAT 0: Bus scanning completed in 3061 ms. >> [ 28.596364] EtherCAT ERROR 0: Failed to calculate bus topology. >> [ 215.389287] EtherCAT WARNING 0: 1 datagram TIMED OUT! >> [ 215.389324] EtherCAT WARNING 0: 1 datagram UNMATCHED! >> [ 341.602318] EtherCAT WARNING 0: 1 datagram TIMED OUT! >> [ 341.602339] EtherCAT WARNING 0: 1 datagram UNMATCHED! >> [ 403.613306] EtherCAT WARNING 0: 1 datagram TIMED OUT! >> [ 403.613369] EtherCAT WARNING 0: 1 datagram UNMATCHED! >> [ 469.944365] EtherCAT WARNING 0: 1 datagram TIMED OUT! >> [ 469.944387] EtherCAT WARNING 0: 1 datagram UNMATCHED! >> [ 500.001363] EtherCAT WARNING 0: 1 datagram TIMED OUT! >> [ 500.001384] EtherCAT WARNING 0: 1 datagram UNMATCHED! >> [ 523.217296] EtherCAT WARNING 0: 2 datagrams TIMED OUT! >> [ 523.217332] EtherCAT WARNING 0: 2 datagrams UNMATCHED! >> [ 683.901311] EtherCAT WARNING 0: 1 datagram TIMED OUT! >> [ 683.901395] EtherCAT WARNING 0: 1 datagram UNMATCHED! >> [ 757.067347] EtherCAT WARNING 0: 1 datagram TIMED OUT! >> [ 757.067368] EtherCAT WARNING 0: 1 datagram UNMATCHED! >> [ 759.003291] EtherCAT WARNING 0: 1 datagram TIMED OUT! >> [ 759.003331] EtherCAT WARNING 0: 1 datagram UNMATCHED! >> [ 1060.422312] EtherCAT WARNING 0: 1 datagram TIMED OUT! >> [ 1060.422370] EtherCAT WARNING 0: 1 datagram UNMATCHED! >> [ 1492.539299] EtherCAT WARNING 0: 1 datagram TIMED OUT! >> [ 1492.539339] EtherCAT WARNING 0: 1 datagram UNMATCHED! >> [ 2260.018306] EtherCAT WARNING 0: 1 datagram TIMED OUT! >> [ 2260.018364] EtherCAT WARNING 0: 1 datagram UNMATCHED! >> [ 2435.205290] EtherCAT WARNING 0: 1 datagram TIMED OUT! >> [ 2435.205325] EtherCAT WARNING 0: 1 datagram UNMATCHED! >> >> >> Any one have any ideas how I can get rid of all these different errors? >> >> Plus, we are shooting for having a system that polls (cyclic task) at 0.5 >> ms (2 kHz) with a jitter of about 10 us and from everything that I have read >> in the ethercat master documentation pdf...it seems like this should not be >> a problem at all. >> >> My setup: >> Linux ubuntu-ioc 2.6.31-11-rt #154-Ubuntu SMP PREEMPT RT Wed Jun 9 >> 12:28:53 UTC 2010 i686 GNU/Linux >> generic driver >> IgH EtherCAT master devel e9f722488fcd >> >> Thanks! >> >> -- >> >> Newell >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> etherlab-users mailing list >> etherlab-users@etherlab.org >> http://lists.etherlab.org/mailman/listinfo/etherlab-users >> >> > > > -- > > ------------------------------------------------------------------------ > > Dipl.-Ing. Andreas Stewering-Bone Amtsgericht Essen HRB 11500 > Ingenieurgemeinschaft IgH USt-Id.-Nr.: DE 174 626 722 > Gesellschaft für Ingenieurleistungen mbH Geschäftsführung: > Heinz-Bäcker-Str. 34 Dr.-Ing. S. Rotthäuser > D-45356 Essen Dr.-Ing. T. Finke > Tel.: +49 201 / 360-14-15 Dr.-Ing. W. Hagemeister > Fax.: +49 201 / 360-14-14 Tel.: +49 201 / 360-14-0 > andreas.stewering-b...@igh-essen.com http://www.igh-essen.com > ------------------------------------------------------------------------ > > -- Newell
_______________________________________________ etherlab-users mailing list etherlab-users@etherlab.org http://lists.etherlab.org/mailman/listinfo/etherlab-users