<div dir="ltr"><div dir="ltr"><div>Dear Gavin,</div><div>thank you for your insight and sorry if I didn't reply earlier... your message has been classified as spam and I missed it...</div><div><br></div><div>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.</div><div><br></div><div>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></div><div><br></div><div>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);</div><div><br></div><div>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.</div><div>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:</div><div>- the file compiles properly, and does run "as expected" without printing any "if-exception"</div><div>- the output is </div><div style="margin-left:40px">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.</div><br></div><div dir="ltr"><br></div><div dir="ltr">- the command ethercat config -v gives</div><div style="margin-left:40px">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</div><div><br></div><div><br></div><div>- the command ethercat master -v gives</div><div>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</div><div><br></div><div>Notice that DC reference time and application time are different and that, while the latter updates at each call, the first does not.</div><div><br></div><div>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...</div><div><br></div><div>Thank you all for your patience and for any guidance.</div><div><br></div><div>Regards,</div><div><br></div><div> Davide</div><div><br></div><div><br></div><div><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">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></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg4645804162069424574">
<div lang="EN-NZ" style="overflow-wrap: break-word;">
<div class="m_4645804162069424574WordSection1">
<p class="MsoNormal"><span>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
</span>ecrt_master_select_reference_clock unless you have special requirements (such as DC synching across multiple networks).<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">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.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">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.)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">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.<span><u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<span style="font-family:Gotham,Calibri,"sans-serif";color:rgb(35,31,32)"><b>Gavin Lambert<br></b>
<br>
Software Engineer<br>
<br>
</span><br>
<br><img style="height: 45px; width: 192px;" src="cid:ii_195041de6349fb34c071" width="192" height="45" border="0">
<br>
<a href="https://www.facebook.com/TOMRA.Food/" target="_blank"><img alt="tomra facebook" src="cid:ii_195041de6354244f7ca2" height="30"></a> <a href="https://www.linkedin.com/company/tomra-food/" target="_blank"><img alt="tomra linkedin" src="cid:ii_195041de6364c933db13" height="30"></a> <a href="https://twitter.com/TOMRAFood" target="_blank"><img alt="tomra twitter" src="cid:ii_195041de636dee978ed4" height="30"></a> <a href="https://www.youtube.com/playlist?list=PLDD3B1A7BAE919EC6" target="_blank"><img alt="tomra youtube" src="cid:ii_195041de636c2ca7d1d5" height="30"></a> <a href="https://www.instagram.com/tomrafood/" target="_blank"><img alt="tomra instragram" src="cid:ii_195041de63667135026" height="30"></a><br>
<span style="font-size:75%;font-family:Calibri,Candara,Segoe,Optima,Arial,sans-serif;color:rgb(110,129,134)"> <b>TOMRA Food (ANZ) Limited</b>
| 4 Henderson Place | PO Box 13 516 | Onehunga 1061 | New Zealand </span><br>
<p style="font-size:10pt;margin-bottom:5pt;font-family:Arial;margin-top:0px"></p>
<span style="font-size:75%;font-family:Calibri,Candara,Segoe,Optima,Arial,sans-serif;color:rgb(110,129,134)"> Phone: +64 96 34 00 88 | <a href="https://www.tomra.com/food" target="_blank">https://www.tomra.com/food</a></span><br>
<span style="font-size:60%;font-family:Gotham,Calibri,"sans-serif";color:rgb(110,129,134)">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. </span><br>
<span style="font-size:60%;font-family:Gotham,Calibri,"sans-serif";width:75%;color:rgb(110,129,134)">
</span><div style="border-width:medium medium medium 1.5pt;border-style:none none none solid;border-color:currentcolor currentcolor currentcolor blue;padding:0cm 0cm 0cm 4pt">
<div>
<div style="border-width:1pt medium medium;border-style:solid none none;border-color:rgb(225,225,225) currentcolor currentcolor;padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11pt;font-family:"Calibri",sans-serif"> Etherlab-users <<a href="mailto:etherlab-users-bounces@etherlab.org" target="_blank">etherlab-users-bounces@etherlab.org</a>>
<b>On Behalf Of </b><a href="mailto:dabbede@gmail.com" target="_blank">dabbede@gmail.com</a><br>
<b>Sent:</b> Monday, 10 February 2025 9:54 pm<br>
<b>To:</b> <a href="mailto:etherlab-users@etherlab.org" target="_blank">etherlab-users@etherlab.org</a><br>
<b>Subject:</b> [Etherlab-users] DC and oversampling with EL2262<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">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)<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">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.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Best regards,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"> Davide<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
-- <br>
Etherlab-users mailing list<br>
<a href="mailto:Etherlab-users@etherlab.org" target="_blank">Etherlab-users@etherlab.org</a><br>
<a href="https://lists.etherlab.org/mailman/listinfo/etherlab-users" rel="noreferrer" target="_blank">https://lists.etherlab.org/mailman/listinfo/etherlab-users</a><br>
</div></blockquote></div></div></div>