[etherlab-users] Beckhoff encoder interface EL5101-0010 mapping issue

BUSSIERES Vincent vincent.bussieres at hemeria-group.com
Thu May 14 16:17:56 CEST 2020


Dear Etherlab users,

I have got problems with Beckhoff encoder interface EL5101-0010 PDO mapping.
I try to map only TxPDO 0x1a01 (SM3), I haven't got any errors in init, everything seems to be fine.
I read encoder value in a loop with 1ms period, return value is always 0.

In dmesg, slave doesn't reach OP state,  and stay in PREOP state.
In Ethercat xml description file, some entries have got 0x0 as index value, and subindex are not completed (strange). I don't know if I need to take them into account.

<Entry>
<Index>#x0</Index>
               <BitLen>2</BitLen>
               <Name>Status__</Name>
</Entry>

You can see below dmesg :

[ 7033.920685] EtherCAT: Requesting master 0...
[ 7033.920686] EtherCAT DEBUG 0: IDLE -> OPERATION.
[ 7033.920687] EtherCAT: Successfully requested master 0.
[ 7034.872900] EtherCAT DEBUG 0: ecrt_master_create_domain(master = 0xffff895554eb6000)
[ 7034.872901] EtherCAT DEBUG 0: Created domain 0.
[ 7035.835219] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7035.835220] EtherCAT DEBUG 0: Creating slave configuration for 0:5, 0x00000002/0x13ED3052.
[ 7035.835222] EtherCAT DEBUG 0 0:5: Attached slave main-5.
[ 7036.592742] EtherCAT DEBUG 0 0:5: ecrt_slave_config_sync_manager(sc = 0xffff895552309000, sync_index = 3, dir = 2, watchdog_mode = 1)
[ 7036.592745] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_assign_clear(sc = 0xffff895552309000, sync_index = 3)
[ 7036.592749] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_assign_add(sc = 0xffff895552309000, sync_index = 3, pdo_index = 0x1A01)
[ 7036.592750] EtherCAT DEBUG 0 0:5: Loading default mapping for PDO 0x1A01.
[ 7036.592753] EtherCAT DEBUG 0 0:5: Entry 0x6000:01.
[ 7036.592754] EtherCAT DEBUG 0 0:5: Entry 0x6000:02.
[ 7036.592754] EtherCAT DEBUG 0 0:5: Entry 0x6000:03.
[ 7036.592755] EtherCAT DEBUG 0 0:5: Entry 0x6000:06.
[ 7036.592756] EtherCAT DEBUG 0 0:5: Entry 0x6000:07.
[ 7036.592756] EtherCAT DEBUG 0 0:5: Entry 0x6000:09.
[ 7036.592757] EtherCAT DEBUG 0 0:5: Entry 0x6000:0A.
[ 7036.592758] EtherCAT DEBUG 0 0:5: Entry 0x6000:0B.
[ 7036.592758] EtherCAT DEBUG 0 0:5: Entry 0x6000:0C.
[ 7036.592759] EtherCAT DEBUG 0 0:5: Entry 0x6000:0D.
[ 7036.592759] EtherCAT DEBUG 0 0:5: Entry 0x6000:0E.
[ 7036.592760] EtherCAT DEBUG 0 0:5: Entry 0x6000:0F.
[ 7036.592761] EtherCAT DEBUG 0 0:5: Entry 0x6000:10.
[ 7036.592761] EtherCAT DEBUG 0 0:5: Entry 0x6000:11.
[ 7036.592762] EtherCAT DEBUG 0 0:5: Entry 0x6000:12.
[ 7036.592764] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_clear(sc = 0xffff895552309000, pdo_index = 0x1A01)
[ 7036.592767] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x01, entry_bit_length = 1)
[ 7036.592769] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x02, entry_bit_length = 1)
[ 7036.592770] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x03, entry_bit_length = 1)
[ 7036.592772] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x06, entry_bit_length = 1)
[ 7036.592773] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x07, entry_bit_length = 1)
[ 7036.592775] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x09, entry_bit_length = 1)
[ 7036.592776] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x0A, entry_bit_length = 1)
[ 7036.592778] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x0B, entry_bit_length = 1)
[ 7036.592779] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x0C, entry_bit_length = 1)
[ 7036.592781] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x0D, entry_bit_length = 1)
[ 7036.592783] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x0E, entry_bit_length = 1)
[ 7036.592784] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x0F, entry_bit_length = 1)
[ 7036.592786] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x10, entry_bit_length = 1)
[ 7036.592788] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x11, entry_bit_length = 2)
[ 7036.592789] EtherCAT DEBUG 0 0:5: ecrt_slave_config_pdo_mapping_add(sc = 0xffff895552309000, pdo_index = 0x1A01, entry_index = 0x6000, entry_subindex = 0x12, entry_bit_length = 2)
[ 7037.153188] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153191] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x01, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153193] EtherCAT DEBUG 0: Domain 0: Added 3 bytes at 0.
[ 7037.153194] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153195] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x02, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153196] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153198] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x03, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153199] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153200] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x06, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153201] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153202] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x07, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153203] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153205] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x09, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153206] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153207] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x0A, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153208] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153209] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x0B, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153211] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153212] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x0C, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153213] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153214] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x0D, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153215] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153216] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x0E, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153218] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153219] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x0F, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153220] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153221] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x10, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153222] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153223] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x11, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.153224] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0xffff895554eb6000, alias = 0, position = 5, vendor_id = 0x00000002, product_code = 0x13ed3052)
[ 7037.153225] EtherCAT DEBUG 0 0:5: ecrt_slave_config_reg_pdo_entry(sc = 0xffff895552309000, index = 0x6000, subindex = 0x12, domain = 0xffff89555461e3c0, bit_position = 0xffffa33a0525bd64)
[ 7037.720938] EtherCAT DEBUG 0: ecrt_domain_external_memory(domain = 0xffff89555461e3c0, mem = 0xffffa33a01b69000)
[ 7037.720940] EtherCAT DEBUG 0: ecrt_master_callbacks(master = 0xffff895554eb6000, send_cb = 0xffffffffc09feff0, receive_cb = 0xffffffffc09ffc60, cb_data = 0xffff895554eb6000)
[ 7037.720940] EtherCAT DEBUG 0: ecrt_master_activate(master = 0xffff895554eb6000)
[ 7037.720941] EtherCAT DEBUG 0: Adding datagram pair with expected WC 1.
[ 7037.720942] EtherCAT 0: Domain0: Logical address 0x00000000, 3 byte, expected working counter 1.
[ 7037.720943] EtherCAT 0:   Datagram domain0-0-main: Logical offset 0x00000000, 3 byte, type LRD at ffff89555461ef18.
[ 7037.720943] EtherCAT DEBUG 0: Stopping master thread.
[ 7037.720974] EtherCAT DEBUG 0: Master IDLE thread exiting...
[ 7037.720978] EtherCAT 0: Master thread exited.
[ 7037.720978] EtherCAT 0: Stopping EoE thread.
[ 7037.721017] EtherCAT DEBUG 0: EoE thread exiting...
[ 7037.721021] EtherCAT 0: EoE thread exited.
[ 7037.721042] EtherCAT DEBUG 0: FSM datagram is ffff895554eb6350.
[ 7037.721043] EtherCAT 0: Starting EoE thread.
[ 7037.721152] EtherCAT 0: Starting EtherCAT-OP thread.
[ 7037.721174] EtherCAT DEBUG 0: EoE thread running.
[ 7037.721300] EtherCAT DEBUG 0: Operation thread running with fsm interval = 4000 us, max data size=45000
[ 7037.721305] EtherCAT DEBUG 0: mmap()
[ 7037.721308] EtherCAT DEBUG 0: Vma fault, virtual_address = 00007fffec02a000, offset = 0, page = fffffd0e908af680
[ 7083.264568] EtherCAT DEBUG 0: Configuration changed (aborting state check).
[ 7083.264570] EtherCAT DEBUG 0-main-0: Checking system time offset.
[ 7118.368544] EtherCAT WARNING 0: No app_time received up to now, abort DC time offset calculation.
[ 7118.368545] EtherCAT DEBUG 0: Requesting OP...
[ 7118.368549] EtherCAT DEBUG 0-main-5: Changing state from PREOP to OP.
[ 7118.368550] EtherCAT DEBUG 0-main-5: Configuring...
[ 7118.384514] EtherCAT DEBUG 0-main-5: Now in INIT.
[ 7118.384515] EtherCAT DEBUG 0-main-5: Clearing FMMU configurations...
[ 7118.384515] EtherCAT DEBUG 0-main-5: Clearing mailbox check flag...
[ 7118.392604] EtherCAT DEBUG 0-main-5: Clearing sync manager configurations...
[ 7118.400551] EtherCAT DEBUG 0-main-5: Clearing DC assignment...
[ 7118.408559] EtherCAT DEBUG 0-main-5: Configuring mailbox sync managers...
[ 7118.408562] EtherCAT DEBUG 0-main-5: SM0: Addr 0x1000, Size 128, Ctrl 0x26, En 1
[ 7118.408564] EtherCAT DEBUG 0-main-5: SM1: Addr 0x1080, Size 128, Ctrl 0x22, En 1
[ 7118.416573] EtherCAT DEBUG 0-main-5: Assigning SII access to PDI.
[ 7118.432522] EtherCAT 0: Slave states on main device: INIT, PREOP.
[ 7118.444566] EtherCAT DEBUG 0-main-5: Now in PREOP.
[ 7118.444567] EtherCAT DEBUG 0-main-5: Assigning SII access back to EtherCAT.
[ 7118.456607] EtherCAT DEBUG 0-main-5: Setting PDO assignment of SM2:
[ 7118.456608] EtherCAT DEBUG 0-main-5: Currently assigned PDOs: 0x1600. PDOs to assign: 0x1600
[ 7118.456610] EtherCAT DEBUG 0-main-5: Setting number of assigned PDOs to zero.
[ 7118.456611] EtherCAT DEBUG 0-main-5: Downloading SDO 0x1C12:00.
[ 7118.456611] EtherCAT DEBUG: 00
[ 7118.456612] EtherCAT DEBUG 0-main-5: Expedited download request:
[ 7118.456612] EtherCAT DEBUG: 00 20 2F 12 1C 00 00 00 00 00
[ 7118.480613] EtherCAT DEBUG 0-main-5: Download response:
[ 7118.480613] EtherCAT DEBUG: 00 30 60 12 1C 00 00 00 00 00
[ 7118.480619] EtherCAT DEBUG 0-main-5: Assigning PDO 0x1600 at position 1.
[ 7118.480620] EtherCAT DEBUG 0-main-5: Downloading SDO 0x1C12:01.
[ 7118.480621] EtherCAT DEBUG: 00 16
[ 7118.480623] EtherCAT DEBUG 0-main-5: Expedited download request:
[ 7118.480623] EtherCAT DEBUG: 00 20 2B 12 1C 01 00 16 00 00
[ 7118.496551] EtherCAT 0: Slave states on main device: PREOP.
[ 7118.504563] EtherCAT DEBUG 0-main-5: Download response:
[ 7118.504564] EtherCAT DEBUG: 00 30 60 12 1C 01 00 16 00 00
[ 7118.504572] EtherCAT DEBUG 0-main-5: Setting number of assigned PDOs to 1.
[ 7118.504574] EtherCAT DEBUG 0-main-5: Downloading SDO 0x1C12:00.
[ 7118.504574] EtherCAT DEBUG: 01
[ 7118.504577] EtherCAT DEBUG 0-main-5: Expedited download request:
[ 7118.504577] EtherCAT DEBUG: 00 20 2F 12 1C 00 01 00 00 00
[ 7118.528572] EtherCAT DEBUG 0-main-5: Download response:
[ 7118.528573] EtherCAT DEBUG: 00 30 60 12 1C 00 01 00 00 00
[ 7118.528586] EtherCAT DEBUG 0-main-5: Successfully configured PDO assignment of SM2.
[ 7118.528596] EtherCAT DEBUG 0-main-5: Setting PDO assignment of SM3:
[ 7118.528597] EtherCAT DEBUG 0-main-5: Currently assigned PDOs: 0x1A01. PDOs to assign: 0x1A01
[ 7118.528602] EtherCAT DEBUG 0-main-5: Setting number of assigned PDOs to zero.
[ 7118.528604] EtherCAT DEBUG 0-main-5: Downloading SDO 0x1C13:00.
[ 7118.528605] EtherCAT DEBUG: 00
[ 7118.528608] EtherCAT DEBUG 0-main-5: Expedited download request:
[ 7118.528608] EtherCAT DEBUG: 00 20 2F 13 1C 00 00 00 00 00
[ 7118.552556] EtherCAT DEBUG 0-main-5: Download response:
[ 7118.552557] EtherCAT DEBUG: 00 30 60 13 1C 00 00 00 00 00
[ 7118.552569] EtherCAT DEBUG 0-main-5: Assigning PDO 0x1A01 at position 1.
[ 7118.552571] EtherCAT DEBUG 0-main-5: Downloading SDO 0x1C13:01.
[ 7118.552571] EtherCAT DEBUG: 01 1A
[ 7118.552575] EtherCAT DEBUG 0-main-5: Expedited download request:
[ 7118.552575] EtherCAT DEBUG: 00 20 2B 13 1C 01 01 1A 00 00
[ 7118.580562] EtherCAT DEBUG 0-main-5: Download response:
[ 7118.580563] EtherCAT DEBUG: 00 30 60 13 1C 01 01 1A 00 00
[ 7118.580573] EtherCAT DEBUG 0-main-5: Setting number of assigned PDOs to 1.
[ 7118.580575] EtherCAT DEBUG 0-main-5: Downloading SDO 0x1C13:00.
[ 7118.580575] EtherCAT DEBUG: 01
[ 7118.580578] EtherCAT DEBUG 0-main-5: Expedited download request:
[ 7118.580579] EtherCAT DEBUG: 00 20 2F 13 1C 00 01 00 00 00
[ 7118.604557] EtherCAT DEBUG 0-main-5: Download response:
[ 7118.604558] EtherCAT DEBUG: 00 30 60 13 1C 00 01 00 00 00
[ 7118.604571] EtherCAT DEBUG 0-main-5: Successfully configured PDO assignment of SM3.
[ 7118.604578] EtherCAT DEBUG 0-main-5: SM2: Addr 0x1100, Size   6, Ctrl 0x24, En 1
[ 7118.604581] EtherCAT DEBUG 0-main-5: SM3: Addr 0x1180, Size   3, Ctrl 0x60, En 1
[ 7118.612565] EtherCAT DEBUG 0 0:5: FMMU: LogOff 0x00000000, Size   3, PhysAddr 0x1180, SM3, Dir in
[ 7118.636572] EtherCAT ERROR 0-main-5: Failed to set SAFEOP state, slave refused state change (PREOP + ERROR).
[ 7118.644558] EtherCAT ERROR 0-main-5: AL status message 0x0024: "Invalid Input Mapping".
[ 7118.664569] EtherCAT DEBUG 0-main-5: PREOP + ERROR -> PREOP.
[ 7118.664573] EtherCAT 0-main-5: Acknowledged state PREOP.

You can see below, an extract of my source code which work correctly with other ethercat slaves
static unsigned int offOutput[15];
static unsigned int offBit[15];

static ec_domain_state_t domain1_state = {};
static ec_master_state_t master_state = {};

static ec_pdo_entry_info_t slave_0_pdo_entries[] = {
    /* TxPdo 0x1a01 */
    {0x6000, 0x01, 1},      /* Status Latch C valid */
    {0x6000, 0x02, 1},      /* Status Latch extern valid */
    {0x6000, 0x03, 1},      /* Status set counter done */
    {0x6000, 0x06, 1},      /* Status of input status */
    {0x6000, 0x07, 1},      /* Status open circuit */
    {0x6000, 0x09, 1},      /* Status of input A */
    {0x6000, 0x0a, 1},      /* Status of input B */
    {0x6000, 0x0b, 1},      /* Status of input C */
    {0x6000, 0x0c, 1},      /* Status of input gate */
    {0x6000, 0x0d, 1},      /* Status of extern latch */
    {0x6000, 0x0e, 1},      /* Status sync error */
    {0x6000, 0x0f, 1},      /* Status TxPDO state */
    {0x6000, 0x10, 1},      /* Status TxPDO toogle */
    {0x6000, 0x11, 2},      /* counter value */
    {0x6000, 0x12, 2}       /* latch value */
};

static ec_pdo_info_t slave_0_pdos[] = {
    {0x1a01, 15, &slave_0_pdo_entries[0]}
};

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

const static ec_pdo_entry_reg_t domain1_regs[] = {
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x01, &offOutput[0], &offBit[0]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x02, &offOutput[1], &offBit[1]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x03, &offOutput[2], &offBit[2]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x06, &offOutput[3], &offBit[3]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x07, &offOutput[4], &offBit[4]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x09, &offOutput[5], &offBit[5]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x0a, &offOutput[6], &offBit[6]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x0b, &offOutput[7], &offBit[7]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x0c, &offOutput[8], &offBit[8]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x0d, &offOutput[9], &offBit[9]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x0e, &offOutput[10], &offBit[10]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x0f, &offOutput[11], &offBit[11]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x10, &offOutput[12], &offBit[12]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x11, &offOutput[13], &offBit[13]},
    {0, 5, 0x00000002, 0x13ed3052, 0x6000, 0x12, &offOutput[14], &offBit[14]},
    {}
};

static ec_master_t *master = nullptr;
static ec_domain_t *domain1 = nullptr;
static uint8_t *domain1_pd = nullptr;
static ec_slave_config_t *sc_el5101 = nullptr;
static ec_slave_config_state_t sc_el2809_state = {};
static ec_slave_info_t slaveInfo;

bool Worker::init()
{
    master = ecrt_request_master(0);
    if ( !master )
        return false;

    domain1 = ecrt_master_create_domain(master);
    if ( !domain1 )
        return false;

    if ( !(sc_el5101 = ecrt_master_slave_config(master, 0, 5, 0x00000002, 0x13ed3052)) )
    {
        fprintf(stderr, "Failed to get slave configuration for AKD.\n");
        return false;
    }

    if (ecrt_slave_config_pdos(sc_el5101, EC_END, slave_0_syncs))
        return false;

    if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs))
        return false;

    if ( ecrt_master_activate( master ) )
        return false;

    if (!(domain1_pd = ecrt_domain_data(domain1)))
        return false;


    return true;
}

void Worker::loop()
{
    mMustStop = false;

    while(!mMustStop)
    {
        QThread::usleep(1000);

        if(!mIsCycleStopped)
        {
            // receive process data
            ecrt_master_receive(master);
            ecrt_domain_process(domain1);

            uint16_t lCounterValue = EC_READ_U16(domain1_pd + offOutput[13]);
            qDebug() << "counter value :" << lCounterValue;

            ecrt_domain_queue(domain1);
            ecrt_master_send(master);
        }
    }

    ecrt_release_master(master);
    master = nullptr;

    emit finished();
}


Take care of yourself

Vincent BUSSIERES
Responsable Technique Logiciel

[1572337113342]
ZE Ma Campagne
36, Impasse Félix Nadar
16000 ANGOULEME
Tel: 33 (0)9.72.40.35.08
www.hemeria-group.com<https://webmail.nexeya.fr/owa/redir.aspx?C=GK_BqKCZef7LtPZnqnd_LGYr1NG9sz4Smy3iKIwO-pXqtJC7VgzXCA..&URL=http%3a%2f%2fwww.hemeria-group.com%2f>
P Afin de contribuer au respect de l'environnement, merci de n'imprimer ce courriel qu'en cas de nécessité.
Ce message et les fichiers pouvant être attachés sont confidentiels, réservés à l'usage unique des destinataires et n'engagent HEMERIA sous aucune forme que ce soit.
This email and any files transmitted with it are confidential, intented solely for the unique use of the recipients and don't commit HEMERIA.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200514/7f132778/attachment-0002.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 5034 bytes
Desc: image001.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200514/7f132778/attachment-0003.png>


More information about the Etherlab-users mailing list