[etherlab-users] Ethercat hello world

Thomas Paoloni thomas at digithom.it
Wed Feb 23 11:49:01 CET 2011


Hi all,

I'm writing my first "hello world" style program, and here are the first 
questions ...
I've started with examples/user/main.c and try to modify it so that it 
can run with my EK1100 + EL2008.
First of all, I don't understand why my "ethercat cstruct" reports this

/* Master 0, Slave 0, "EK1101"
  * Vendor ID:       0x00000002
  * Product code:    0x044d2c52
  * Revision number: 0x00110000
  */

ec_pdo_entry_info_t slave_0_pdo_entries[] = {
     {0x6000, 0x01, 16}, /* ID */
};

ec_pdo_info_t slave_0_pdos[] = {
     {0x1a00, 1, slave_0_pdo_entries + 0}, /* ID */
};

ec_sync_info_t slave_0_syncs[] = {
     {0, EC_DIR_INPUT, 1, slave_0_pdos + 0, EC_WD_DISABLE},
     {0xff}
};

/* Master 0, Slave 1, "EL2008"
  * Vendor ID:       0x00000002
  * Product code:    0x07d83052
  * Revision number: 0x00100000
  */

ec_pdo_entry_info_t slave_1_pdo_entries[] = {
     {0x7000, 0x01, 1}, /* Output */
     {0x7010, 0x01, 1}, /* Output */
     {0x7020, 0x01, 1}, /* Output */
     {0x7030, 0x01, 1}, /* Output */
     {0x7040, 0x01, 1}, /* Output */
     {0x7050, 0x01, 1}, /* Output */
     {0x7060, 0x01, 1}, /* Output */
     {0x7070, 0x01, 1}, /* Output */
};

ec_pdo_info_t slave_1_pdos[] = {
     {0x1600, 1, slave_1_pdo_entries + 0}, /* Channel 1 */
     {0x1601, 1, slave_1_pdo_entries + 1}, /* Channel 2 */
     {0x1602, 1, slave_1_pdo_entries + 2}, /* Channel 3 */
     {0x1603, 1, slave_1_pdo_entries + 3}, /* Channel 4 */
     {0x1604, 1, slave_1_pdo_entries + 4}, /* Channel 5 */
     {0x1605, 1, slave_1_pdo_entries + 5}, /* Channel 6 */
     {0x1606, 1, slave_1_pdo_entries + 6}, /* Channel 7 */
     {0x1607, 1, slave_1_pdo_entries + 7}, /* Channel 8 */
};

ec_sync_info_t slave_1_syncs[] = {
     {0, EC_DIR_OUTPUT, 8, slave_1_pdos + 0, EC_WD_ENABLE},
     {0xff}
};

showing 0x7000, 0x7010, etc. while in the example mentioned, pdo_entry 
reports 0x3001 address.
The el2004 should be the 4 Output versione of the 8 used by me and I 
expect a similar configuration, why this difference ?

static ec_pdo_entry_info_t el2004_channels[] = {
     {0x3001, 1, 1}, // Value 1
     {0x3001, 2, 1}, // Value 2
     {0x3001, 3, 1}, // Value 3
     {0x3001, 4, 1}  // Value 4
};

My program ends with a segfault

thomas-desktop ~ # ./main
Configuring PDOs...
Activating master...
pd: 0
Starting timer...
Started.
2 slave(s).
AL states: 0x02.
Link is up.
Segmentation fault

and here is what is reported inside dmesg logs

[331828.246923] EtherCAT: Requesting master 0...
[331828.246942] EtherCAT: Successfully requested master 0.
[331828.247321] EtherCAT 0: Domain0: Logical address 0x00000000, 1 byte, 
expected working counter 1.
[331828.247338] EtherCAT 0:   Datagram domain0-0: Logical offset 
0x00000000, 1 byte, type LWR.
[331828.247437] EtherCAT 0: Master thread exited.
[331828.247454] EtherCAT 0: Starting EtherCAT-OP thread.
[331838.249073] main[11875]: segfault at 8 ip 0804a1d9 sp bffd0080 error 
4 in main[8048000+88000]
[331838.249287] EtherCAT 0: Releasing master...
[331838.249393] EtherCAT 0: Master thread exited.
[331838.249435] EtherCAT 0: Starting EtherCAT-IDLE thread.
[331838.249824] EtherCAT 0: Released.

What's wrong ?
Where can I study something about this ?


Thanks,

Thomas Paoloni.



More information about the Etherlab-users mailing list