<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Plain Text Char";
margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.PlainTextChar
{mso-style-name:"Plain Text Char";
mso-style-priority:99;
mso-style-link:"Plain Text";
font-family:Consolas;}
span.EmailStyle22
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">The only difference between ARMW and FRMW is the addressing mode for the slave; there is absolutely no reason this would cause synchronization issues, provided that both select the same slave as reference clock. (The only “advantage” of
ARMW over FRMW is that you can be a bit lazier with the former if declaring that your first slave is always your reference clock – and indeed you do want your reference clock to be earlier in the network than any slaves where you care about their times.)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">There’s fundamentally two different ways to try to sync the master clock and slave reference clocks. The first is to use the ecrt_master_sync_reference_clock or ecrt_master_sync_reference_clock_to calls, which will try to keep the clocks
fully aligned, essentially by trying to make the slave clocks drift approximately the same as the master’s. The second is to instead only call ecrt_master_reference_clock_time or ecrt_master_64bit_reference_clock_time (the latter requires extra steps) to
only read the reference clock’s existing time and then perform your own (usually virtual) adjustment to the master clock as needed. Most of the examples only demonstrate the former; the rtai_rtdm_dc example is the only one that demonstrates the latter. Which
way makes more sense depends on which clock you expect to be “better”, as well as whether you need the slaves to have something close to the “real” wall-clock time (only matters for 64-bit DC slaves) or if a relative close-to-zero clock is sufficient for their
needs (usually true).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Separate to this is the timing loop for your master packets. When using the former method you typically just try to send at a steady timestamp based solely on the master clock. When using the latter, you can still do that if you don’t
mind jitter and drift, but it’s better to try to realign your master cycle based on the reference clock (the rtai_rtdm_dc example demonstrates this as well – be careful you didn’t accidentally eliminate that when converting to userspace calls; system2count
is critical here).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">It’s also critically important to consider which values you’re using in the ecrt_slave_config_dc call – make sure they match your vendor’s recommendations for your intended cycle interval. In particular, selecting a good shift value may
reduce the effect of jitter, where reasonably tight. (Also bear in mind that sync0 and sync1 cycle/shift times are not treated equivalently.)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Bear in mind that you usually want your packets arriving at a different time from the Sync0 trigger on the slave, allowing for capture and processing delays plus jitter. It may be useful to connect a scope to observe the relative timing
of each event.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I vaguely recall there being a userspace variant of the example code posted to the list a few years back, but I didn’t manage to find it in a basic search.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<span style="FONT-FAMILY: Gotham, Calibri, 'sans-serif'; COLOR: #231f20"><strong>Gavin Lambert<br></strong>
<br>
Senior Software Developer TOMRA Fresh Food<br>
<br>
</span><br>
<br><img style="HEIGHT: 45px; WIDTH: 350px" src="cid:TOMRAFresh_final_size_times_two_2_99d242b2-ba06-4c25-ab26-020cca7ee6dd.png" width="350" height="45" border="0">
<br> <A href="https://www.facebook.com/TOMRAFreshFood" target=_blank><IMG
alt="tomra facebook" src="cid:TF-FB-icon_b77c57e4-4990-4f9d-b3a2-8e6ab45df7f2.jpg"
height=30></A> <A href="https://www.linkedin.com/company/tomra-fresh-food/"
target=_blank><IMG alt="tomra linkedin"
src="cid:TF-LinkedIn-icon_d54c4829-dcb9-450c-9187-34b26e85ebaa.jpg"
height=30></A> <A href="https://vimeo.com/tomrafreshfood"
target=_blank><IMG alt="tomra vimeo" src="cid:TOMRA-Vimeo_4673038e-313a-491f-b3a4-0b39ace6df88.jpg"
height=30></A> <A href="https://www.instagram.com/tomrafood/"
target=_blank><IMG alt="tomra instragram"
src="cid:TOMRAinstagram_45b30c55-490a-4f32-8fd3-998c152e3494.jpg"
height=30></A><BR>
<span style="FONT-SIZE: 75%; FONT-FAMILY: Calibri, Candara, Segoe, Optima, Arial, sans-serif; COLOR: #6e8186"> <b>Compac Technologies Ltd</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: #6e8186"> Phone: +64 96 34 00 88 | <a href="https://www.compacsort.com">https://www.compacsort.com</a></span><br>
<span style="FONT-SIZE: 60%; FONT-FAMILY: Gotham, Calibri, 'sans-serif'; COLOR: #6e8186">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: #6e8186">
</span><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Celil Can Anik<br>
<b>Sent:</b> Tuesday, 1 March 2022 03:11<br>
<b>To:</b> etherlab-users@etherlab.org<br>
<b>Subject:</b> Re: [Etherlab-users] Using DC to syncronise to reference slave clock<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi again,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I still work on running Mitsubishi JET servo drives. We managed to run with DC synchronized to slave reference clock. When we check Wireshark data,<span style="color:black"> “System Time Register” 0x910 is transferred with FRMW command.
But e</span>ngineers from Mitsubishi had told us Beckhoff Ethercat master is using
<span lang="TR">ARMW command for “System Time Register” 0x910. </span>Honestly, I don’t have any idea why, but they claim this command difference causes synchronization problem. What do you think about this topic?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Also, I checked the source, but couldn’t found usage of ARMW command. Is there any example for ARMW command?
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Best regards,<o:p></o:p></p>
<p class="MsoNormal">Celil<o:p></o:p></p>
<p class="MsoNormal"><span lang="TR"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="TR"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><span lang="TR"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span lang="TR"><o:p> </o:p></span></p>
<div>
<p class="MsoPlainText"><span lang="TR" style="color:black">Hi, <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black"> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">How should we use DC to synchronize to the slave reference clock? I implemented it by looking at the rtai_rtdm example. But it's not working as desired. <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black"> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">I guess I'm missing something. I would expect to change my sleep times to synchronize to slave clock. I couldn't see something like that. <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black"> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">* How can I stop drifting my send time relative to slave clock? <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black"> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">* Also, how can I measure the time I'm sending relative to cycle start of the slave clock? Can I just modulo the value returned by ecrt_master_reference_clock_time() to the cycle time? <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black"> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">For a little background: <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black"> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">We are using EtherCAT master for several years. We are using PREEMPT_RT patch with ubuntu 16.04, kernel 4.9.178. We had downloaded Gavin Lambert's unofficial patch sets a few years ago. <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black"> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">Normally we are using master PC as the master clock. This option is mentioned as option a in various mails in the mail list. <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black"> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">With this method we successfully integrated many servo motor drives from several vendors. We are generally using 1ms and 2ms cycle times on different machines. <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black"> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">We have recently added Mitsubishi Jet EtherCAT series to our database. Although this drive is working fine under lab conditions, somehow it gave synchronization errors from time to time at the machine.
There are 4 drives and several IOs from Beckhoff on the bus. <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black"> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">Mitsubishi engineers claim that, the problem occurs because we are not synchronized to the slave reference clock. And ask us to change our mechanism to synchronize the master PC to the reference slave.
This method is also described as the option b in mail list. <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black"> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">So I copied the related blocks from rtai_rtdm example in the examples folder. I modified RTAI specific functions to user space functions. At our lab we are testing two Jet drives connected to our master
PC. The drives are changing to OP mode and I can control the position and speed. <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">There is no error in dmesg messages. Also no error on the display of the drives. But I hear knocking sounds in every few minutes while rotating. <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">It seems my send time is drifting relative to slave clock. But I don't see how can I stop drifting. <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black"> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">Best regards, <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black"> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="TR" style="color:black">Celil <o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="TR" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="TR"><o:p> </o:p></span></p>
</div>
</div>
</div>
</body>
</html>