<div dir="ltr">Dear Gavin,<br><br><div>thank you for the help. The Sync1 specification was completely obscure to me. If it is something "general" (not slave specific) I think it should be better described in the documentation.</div><div><br></div>Regarding my example, with EL3702 I think I'm starting to approach a working solution: the slave is OP and oversampled data appears every cycle.<br>What I still don't completely understand is why if I run in the terminal the command "ethercat master -v" I see that the DC reference time does not increment.<br><div>To better understand this, I've tried to check the return values in my code after calling "ecrt_master_sync_reference_clock_to()" or "ecrt_master_sync_reference_clock()" (used exclusively one or the other) and they both are 0.</div><div><br></div><div>Then, I tried to read the reference clock using the provided function "ecrt_master_reference_clock_time()" and, in this case, I get the return -5 (-EIO) and the print message "Failed to get reference clock time: Input/output error"</div><div>In another console, if I check the DC residual error by continuously watch "ethercat reg_read -p1 -tsm32 0x92c", I see that the number starts big and gradually reduces to ~<100.</div><div><br></div><div>This information seems to contradict each other: on the one end the application seems to work, and the time error is minimal, on the other it seems that the reference clock is not properly set...</div><div>I don't know who to trust :-)</div><div><br></div><div>Have you any idea why
ecrt_master_reference_clock_time() could fail? Is it an error in the slave configuration or in the master?</div><div><br></div><div>Thanks again, and best regards</div><div><br></div><div></div><div> Davide</div><div><br></div><div><br></div><div><br></div><div><br></div>On Sun, Feb 16, 2025 at 11:36 PM Gavin Lambert <<a href="mailto:gavin.lambert@tomra.com">gavin.lambert@tomra.com</a>> wrote:<br>><br>> The EK1100 is DC-capable (it has a DC clock and can be assigned as reference clock) but does not actually use DC-application functionality, so you don’t call ecrt_slave_config_dc on it (thus it doesn’t need an AssignActivate word).<br>><br>> <br>><br>> Note that if you have Sync0 = 1000000 and Sync1 = 1000000 then you are not 1x sampling, you are 2x sampling (Sync0 pulses at 1000000ns and Sync1 pulses at 2000000ns, so your application cycle interval should be 2000000ns). Sync1 is an offset; it works differently than Sync0. Blame Beckhoff.<br>><br>> <br>><br>> If you actually want 1x sampling at an application cycle rate of 1000000ns then you need to specify Sync0 = 1000000 and Sync1 = 0. For 4x sampling at 1000000ns then Sync0 = 250000 and Sync1 = 750000. You may also need a non-zero Sync0 shift value; for that you’ll need to check the documentation of your slave.<br>><br>> <br>><br>> Gavin Lambert<br>> <br>> Software Engineer<br>><br>><br>> <br>> <br>> <br>> TOMRA Food (ANZ) Limited | 4 Henderson Place | PO Box 13 516 | Onehunga 1061 | New Zealand<br>><br>> Phone: +64 96 34 00 88 | <a href="https://www.tomra.com/food">https://www.tomra.com/food</a><br>> The information contained in this communication and any attachment is confidential and may be legally privileged. It should only be read by the person(s) to whom it is addressed. If you have received this communication in error, please notify the sender and delete the communication.<br>><br>> From: <a href="mailto:dabbede@gmail.com">dabbede@gmail.com</a> <<a href="mailto:dabbede@gmail.com">dabbede@gmail.com</a>><br>> Sent: Saturday, 15 February 2025 12:29 am<br>> To: Gavin Lambert <<a href="mailto:gavin.lambert@tomra.com">gavin.lambert@tomra.com</a>><br>> Cc: <a href="mailto:etherlab-users@etherlab.org">etherlab-users@etherlab.org</a><br>> Subject: Re: [Etherlab-users] DC and oversampling with EL2262<br>><br>> <br>><br>> Dear Gavin,<br>><br>> thank you for your insight and sorry if I didn't reply earlier... your message has been classified as spam and I missed it...<br>><br>> <br>><br>> Yes, I know that usually the reference clock is assigned to the first DC-capable slave: in my simple setupthis slave is the bus coupler EK1100, but other EtherCAT masters refuse to assign the reference to a coupler, and generally use the first "normal" slave. This is the case for TwinCAT and Koenig Pa., for example. Moreover, I don't have an "AssignActivate" word for EK1100... Anyway, I've tried both with and without the specification of "ecrt_master_select_reference_clock" and the result does not change: the reference clock is always Slave 0, and the DC reference time does not advance.<br>><br>> <br>><br>> Since I was having issues on sending EL2262 to "OP", later I've tried to use a different slave with similar characteristics (DC capable and oversampling), which is EL3702. With that, I could go "OP" without problem, but all the other issues related to the reference clock staying assigned to Slave 0 (despite ecrt_master_select_reference_clock ) and DC reference time which does not advance remained the same.<br>><br>> <br>><br>> Of course I strictly followed the example dc_user (that was my starting point), and in fact my cyclic task has this form:<br>> clock_gettime(CLOCK_TO_USE, &time);<br>> ecrt_master_sync_reference_clock_to(master, TIMESPEC2NS(time));<br>> ecrt_master_sync_slave_clocks(master);<br>><br>> <br>><br>> I don't know if I'm allowed to attach files to this mailing list. I'm going to try with a minimal example and, if it does not work, I'll copy in the next message the content of the file.<br>><br>> I don't know if anyone of you owns a EL3702 to try replicate the error, but this is what I can see with the attached minimal example:<br>><br>> - the file compiles properly, and does run "as expected" without printing any "if-exception"<br>><br>> - the output is <br>><br>> Activating master...<br>> Using priority 97.<br>> Starting cyclic function.<br>> 2 slave(s).<br>> AL states: 0x02.<br>> Link is up.<br>> AL states: 0x08.<br>> Domain1: WC 1.<br>> Domain1: State 2.<br>><br>> <br>><br>> <br>><br>> - the command ethercat config -v gives<br>><br>> Alias: 0<br>> Position: 0<br>> Vendor Id: 0x00000002<br>> Product code: 0x044c2c52<br>> Attached slave: 0 (OP)<br>> Watchdog divider: (Default)<br>> Watchdog intervals: (Default)<br>> SDO configuration:<br>> None.<br>> IDN configuration:<br>> None.<br>> Feature flags:<br>> None.<br>><br>> Alias: 0<br>> Position: 1<br>> Vendor Id: 0x00000002<br>> Product code: 0x0e763052<br>> Attached slave: 1 (OP)<br>> Watchdog divider: (Default)<br>> Watchdog intervals: (Default)<br>> SM0, Dir: Input, Watchdog: Default<br>> PDO 0x1b00<br>> PDO entry 0x6800:01, 16 bit<br>> PDO 0x1a00<br>> PDO entry 0x6000:01, 16 bit<br>> SM1, Dir: Input, Watchdog: Default<br>> PDO 0x1b01<br>> PDO entry 0x6800:02, 16 bit<br>> PDO 0x1a80<br>> PDO entry 0x6000:02, 16 bit<br>> SM2, Dir: Input, Watchdog: Default<br>> PDO 0x1b10<br>> PDO entry 0x1d09:98, 32 bit<br>> SDO configuration:<br>> None.<br>> IDN configuration:<br>> None.<br>> Feature flags:<br>> None.<br>> DC configuration:<br>> AssignActivate: 0x0730<br>> Cycle [ns] Shift [ns]<br>> SYNC0 1000000 0<br>> SYNC1 1000000 0<br>><br>> <br>><br>> <br>><br>> - the command ethercat master -v gives<br>><br>> Master0<br>> Phase: Operation<br>> Active: yes<br>> Slaves: 2<br>> Ethernet devices:<br>> Main: 00:12:cd:07:a3:4a (attached)<br>> Link: UP<br>> Tx frames: 2102849<br>> Tx bytes: 139702270<br>> Rx frames: 2102848<br>> Rx bytes: 139702206<br>> Tx errors: 0<br>> Tx frame rate [1/s]: 1000 1000 995<br>> Tx rate [KByte/s]: 64.2 64.2 63.9<br>> Rx frame rate [1/s]: 1000 1000 995<br>> Rx rate [KByte/s]: 64.2 64.2 63.9<br>> Common:<br>> Tx frames: 2102849<br>> Tx bytes: 139702270<br>> Rx frames: 2102848<br>> Rx bytes: 139702206<br>> Lost frames: 0<br>> Tx frame rate [1/s]: 1000 1000 995<br>> Tx rate [KByte/s]: 64.2 64.2 63.9<br>> Rx frame rate [1/s]: 1000 1000 995<br>> Rx rate [KByte/s]: 64.2 64.2 63.9<br>> Loss rate [1/s]: 0 0 0<br>> Frame loss [%]: 0.0 0.0 0.0<br>> Distributed clocks:<br>> Reference clock: Slave 0<br>> DC reference time: 6591555116393<br>> Application time: 6842454116393<br>> 2000-01-01 01:54:02.454116393<br>><br>> <br>><br>> Notice that DC reference time and application time are different and that, while the latter updates at each call, the first does not.<br>><br>> <br>><br>> The original code was more complicated, to account for the oversampling also in the PDOs, but even this minimal one with oversampling = 1 still does not work, so I don't understand if I'm missing something or if these types of slaves are not supported...<br>><br>> <br>><br>> Thank you all for your patience and for any guidance.<br>><br>> <br>><br>> Regards,<br>><br>> <br>><br>> Davide<br>><br>> <br>><br>> <br>><br>> On Tue, Feb 11, 2025 at 4:15 AM Gavin Lambert <<a href="mailto:gavin.lambert@tomra.com">gavin.lambert@tomra.com</a>> wrote:<br>><br>> Typically, the reference clock should be the first DC-capable device on the network (often an infrastructure device like a coupler, if present – as in your case), because the DC time only flows downstream from that. It’s unusual for it to be your DC-consuming device directly unless you don’t have any others. Thus, it’s not usually necessary to call ecrt_master_select_reference_clock unless you have special requirements (such as DC synching across multiple networks).<br>><br>> <br>><br>> Since you’re using ecrt_master_sync_reference_clock_to and you’re saying that the DC time doesn’t appear to be advancing, ensure that your code actually does advance the time in your realtime loop – that’s your responsibility when you use that method rather than the alternatives.<br>><br>> <br>><br>> There can be many reasons why a device refuses to transition to SAFEOP (or does but then faults back to PREOP). You’ll need to review the syslog to see what error codes it’s reporting, if any. (But it could just be due to the DC time not advancing.)<br>><br>> <br>><br>> Try comparing your code against the existing examples such as dc_user, and pay close attention to your slave’s documented requirements for ecrt_slave_config_dc – in particular note that the SYNC1 time is specified in an unusual way.<br>><br>> <br>><br>> Gavin Lambert<br>> <br>> Software Engineer<br>><br>><br>> <br>> <br>> <br>> TOMRA Food (ANZ) Limited | 4 Henderson Place | PO Box 13 516 | Onehunga 1061 | New Zealand<br>><br>> Phone: +64 96 34 00 88 | <a href="https://www.tomra.com/food">https://www.tomra.com/food</a><br>> The information contained in this communication and any attachment is confidential and may be legally privileged. It should only be read by the person(s) to whom it is addressed. If you have received this communication in error, please notify the sender and delete the communication.<br>><br>> From: Etherlab-users <<a href="mailto:etherlab-users-bounces@etherlab.org">etherlab-users-bounces@etherlab.org</a>> On Behalf Of <a href="mailto:dabbede@gmail.com">dabbede@gmail.com</a><br>> Sent: Monday, 10 February 2025 9:54 pm<br>> To: <a href="mailto:etherlab-users@etherlab.org">etherlab-users@etherlab.org</a><br>> Subject: [Etherlab-users] DC and oversampling with EL2262<br>><br>> <br>><br>> Dear Etherlab community,<br>><br>> I have been using the EtherCAT master for a few days. I think I understand more or less how to configure the PDOs and domains for one or more slaves, but I'm having trouble with the distributed clock (DC).<br>> In particular, my setup is currently as follows:<br>> - master<br>> - Beckhoff EK1100<br>> - Beckhoff EL2262<br>><br>> The latter is a digital output with oversampling capabilities. It can output a sample every Sync0, which in turn can be set to trigger faster than the application cycle. I used this slave successfully with other EtherCAT masters, so I know it is working properly.<br>><br>> In my code I've set the PDOs using "ecrt_slave_config_pdos" and assigned them to the domain1 using "ecrt_slave_config_reg_pdo_entry".<br>><br>> Then I've set this slave to be the reference clock using<br>> ecrt_master_select_reference_clock (master, sc); // Set this slave to be reference clock<br>> and finally I've set the DC settings (and Sync0/1) using "ecrt_slave_config_dc" (by the way, the AssignActivate data is 0x0730 for this slave).<br>><br>> Then, for every application cycle I call, in order:<br>> - ecrt_master_application_time<br>> - ecrt_master_receive<br>> - ecrt_domain_process<br>> - check_domain1_state<br>> - ecrt_master_sync_reference_clock_to<br>> - ecrt_master_sync_slave_clocks<br>> - ecrt_domain_queue<br>> - ecrt_master_send<br>><br>> The problems I see are:<br>> - the outputs are constantly OFF, even if I've set an alternating pattern of ON and OFF,<br>> - the slave stops at PREOP,<br>> - if I inspect the master from the cli using "ethercat master -v", I see that the reference clock is set to Slave 0, instead of Slave 1. Moreover, the DC reference time is set correctly every time I restart the application, but it does not update during execution. Conversely, the application time increase as expected<br>> - during " check_domain1_state", I see that the wc_state==EC_WC_ZERO (no process data exchanged)<br>><br>> <br>><br>> I am willing to share my code if it is required.<br>> Thank you for your help and, especially, thank you for providing such powerful software as open source.<br>><br>> Best regards,<br>><br>> <br>><br>> Davide<br>><br>> --<br>> Etherlab-users mailing list<br>> <a href="mailto:Etherlab-users@etherlab.org">Etherlab-users@etherlab.org</a><br>> <a href="https://lists.etherlab.org/mailman/listinfo/etherlab-users">https://lists.etherlab.org/mailman/listinfo/etherlab-users</a></div>