<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-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
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="DE" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:12.0pt">Hello everybody!<br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">I‘m using the unofficial patch set from
<a href="https://github.com/ribalda/ethercat">https://github.com/ribalda/ethercat</a> (2017-11-08).<br>
My RTAI communication cycle is synchronized to the DC slave reference clock (average jitter < 1µs). I need to extrapolate the position of servo drives to the beginning of my cycle.<br>
<br>
I’m not sure about the right use of the functions for reading the reference clock.<br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">I want to start my cycle at the time of the “Sync0” interrupt.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">My questions are: When is the time sampled that I get by calling
<br>
ecrt_master_64bit_reference_clock_time(m_poMaster, &ui64RefClockTime)); ?<br>
<br>
How I have to initialize my application time (first call of “ecrt_master_application_time(…)”)?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">My synchronisation seems to work but I’m not sure about the phase shift between the Sync0 event and the start of my communication cycle.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">My code looks something like this:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">In the first real time cycle I call:<br>
ecrt_master_application_time(m_poMaster, m_ui64AppTime_ns); // with m_ui64AppTime_ns=0<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_master_sync_slave_clocks(m_poMaster);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_domain_queue(m_po_domainInput);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_master_send(m_poMaster);<br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">// busy wait 25µs for getting the answer<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_master_receive(m_poMaster);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_domain_process(m_po_domainInput);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">//<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">// …. Later sending the output data<br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">In the next cycles I do this:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_master_receive(m_poMaster);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_domain_process(m_po_domainOutput);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_master_64bit_reference_clock_time_queue(m_poMaster);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_domain_queue(m_po_domainInput);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_master_send(m_poMaster);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">// busy wait 25µs for getting the answer<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_master_receive(m_poMaster);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_domain_process(m_po_domainInput);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">uint64_t ui64RefClockTime;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_master_64bit_reference_clock_time(m_poMaster, &ui64RefClockTime));<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">m_ui64AppTime_ns += static_cast<uint64_t>((m_io__dNominalCycleTime) * 1e9);<br>
ecrt_master_application_time(m_poMaster, m_ui64AppTime_ns);<br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">m_out_iDcSysTimeDifferenceMaster = m_ui64AppTime_ns - ui64RefClockTime; // Time drift value<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt">ecrt_master_sync_slave_clocks(m_poMaster);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt;mso-fareast-language:DE">With kind regards<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-GB" style="font-size:12.0pt;mso-fareast-language:DE"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;mso-fareast-language:DE">Matthias Bartsch<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><b><span lang="EN-GB" style="mso-fareast-language:DE">ARADEX AG</span></b><span lang="EN-GB" style="mso-fareast-language:DE">
<br>
<br>
</span><span lang="EN-US" style="font-family:"Arial","sans-serif";mso-fareast-language:DE"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
</div>
</body>
</html>