<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/TR/REC-html40" 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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Message</title>
<meta name="GENERATOR" content="MSHTML 8.00.6001.18812">
<!--[if !mso]>
<STYLE>v\:* {
BEHAVIOR: url(#default#VML)
}
o\:* {
BEHAVIOR: url(#default#VML)
}
w\:* {
BEHAVIOR: url(#default#VML)
}
.shape {
BEHAVIOR: url(#default#VML)
}
</STYLE>
<![endif]--><style>@font-face {
font-family: Cambria Math;
}
@font-face {
font-family: Calibri;
}
@font-face {
font-family: Tahoma;
}
@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.0in 1.0in 1.0in; }
P.MsoNormal {
MARGIN: 0in 0in 0pt; FONT-FAMILY: "Calibri","sans-serif"; FONT-SIZE: 11pt
}
LI.MsoNormal {
MARGIN: 0in 0in 0pt; FONT-FAMILY: "Calibri","sans-serif"; FONT-SIZE: 11pt
}
DIV.MsoNormal {
MARGIN: 0in 0in 0pt; FONT-FAMILY: "Calibri","sans-serif"; FONT-SIZE: 11pt
}
A:link {
COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlink {
COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
A:visited {
COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlinkFollowed {
COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.EmailStyle17 {
FONT-FAMILY: "Calibri","sans-serif"; COLOR: windowtext; mso-style-type: personal
}
SPAN.EmailStyle18 {
FONT-FAMILY: "Calibri","sans-serif"; COLOR: #1f497d; mso-style-type: personal-reply
}
.MsoChpDefault {
FONT-SIZE: 10pt; mso-style-type: export-only
}
DIV.Section1 {
page: Section1
}
</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="purple">
<div><font color="#ff0000" size="2" face="Arial"><span class="153374112-26112009">inline response in red,</span></font></div>
<div><font color="#ff0000" size="2" face="Arial"><span class="153374112-26112009"></span></font> </div>
<div><font color="#ff0000" size="2" face="Arial"><span class="153374112-26112009">best regards,</span></font></div>
<div><font color="#ff0000" size="2" face="Arial"><span class="153374112-26112009">Paolo</span></font></div>
<blockquote style="MARGIN-RIGHT: 0px" dir="ltr">
<div></div>
<div dir="ltr" lang="en-us" class="OutlookMessageHeader" align="left"><font size="2" face="Tahoma">-----Original Message-----<br>
<b>From:</b> Peter van Knippenbergh [mailto:peter.van.knippenbergh@sioux.eu] <br>
<b>Sent:</b> giovedì, 26. novembre 2009 13:32<br>
<b>To:</b> Inselmini Paolo<br>
<b>Cc:</b> peter.van.knippenbergh@sioux.nl<br>
<b>Subject:</b> RE: [etherlab-users] Timing measurements<br>
<br>
</font></div>
<div class="Section1">
<p class="MsoNormal"><span style="COLOR: #1f497d">Hi<o:p></o:p></span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d">Thank you for your quick reply, but not is everything is clear yet, see inline (below)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d"><o:p> </o:p></span></p>
<div>
<div style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<p class="MsoNormal"><b><span style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt">From:</span></b><span style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt"> Inselmini Paolo [mailto:Paolo.Inselmini@ch.gfac.com]
<br>
<b>Sent:</b> Thursday, November 26, 2009 10:22 AM<br>
<b>To:</b> Peter van Knippenbergh<br>
<b>Subject:</b> RE: [etherlab-users] Timing measurements<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt">Hi</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt">EL5101 support distributed clock so if you want to measure the cycle time you can do it by evaluating the response of the slave synchronization datagram.<br>
I do that to synchronize the master with the slave reference clock. I implemented the ecrt_get_slave_sync_time function in the etherCAT master.c file to read the cycle time.<br>
This function should be called every cycle, you can then read the cycle time within the exported EtherCAT_timeSync structure.</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt">It's what you need?</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">struct {<br>
u64 ecat_time_ns; //absolute sync thelegram time</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> u32 delta_ecat_time_ns; //sync thelegram cycle time<br>
u32 ecat_time_1;<br>
bool isSync;<br>
struct semaphore lock;<br>
} EtherCAT_timeSync;</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">void ecrt_get_slave_sync_time(ec_master_t *master)<br>
{</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> u32 ecat_time;<br>
//s32 delta_ecat_time;</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> if((master->has_start_time == 1) && (EtherCAT_timeSync.isSync ==0))<br>
{<br>
down(&EtherCAT_timeSync.lock);<br>
EtherCAT_timeSync.isSync =1;<br>
EtherCAT_timeSync.ecat_time_ns = master->app_start_time;<br>
EtherCAT_timeSync.ecat_time_1 = (u32)(EtherCAT_timeSync.ecat_time_ns & 0xFFFFFFFF);<br>
up(&EtherCAT_timeSync.lock);<br>
}</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> if(master->sync_datagram.state == EC_DATAGRAM_RECEIVED)<br>
{<br>
down(&EtherCAT_timeSync.lock);<br>
ecat_time = (u32) le32_to_cpup((void *)master->sync_datagram.data);</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"><br>
EtherCAT_timeSync.delta_ecat_time_ns = (s32)ecat_time - (s32)EtherCAT_timeSync.ecat_time_1;<br>
if(EtherCAT_timeSync.delta_ecat_time_ns < 0)<br>
EtherCAT_timeSync.delta_ecat_time_ns = (u32)(0x100000000LL + (s64)decat_time);<span style="COLOR: #1f497d"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d">The decat_time time is not defined, so in my opinion the line must be :<o:p></o:p></span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d"> EtherCAT_timeSync.delta_ecat_time_ns = (u32)((0x100000000LL) + (s64)(EtherCAT_timeSync.delta_ecat_time_ns));<o:p></o:p></span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; COLOR: #1f497d; FONT-SIZE: 10pt">Is that correct ??<o:p></o:p></span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"><span class="153374112-26112009"><font color="#0000ff" face="Arial"> <span style="FONT-FAMILY: 'Times New Roman','serif'; COLOR: #1f497d; FONT-SIZE: 12pt"><span class="153374112-26112009"><font face="Arial"><font color="#ff0000" size="2">R:
</font></font></span></span><font color="#ff0000">Yes, it is!! the delta_ecat_time was added for you, I only use</font>
<font color="#ff0000">the absolute time... I made a mistake.</font></font></span><br>
</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> EtherCAT_timeSync.ecat_time_ns &= ~0xFFFFFFFFLL; // remove low 32 bits of the time<br>
EtherCAT_timeSync.ecat_time_ns |= (u64)ecat_time; // add low 32 bits of readed ethercat absolute time</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> if(ecat_time < EtherCAT_timeSync.ecat_time_1)<br>
{ //overflow, increment the owerflowed value<br>
EtherCAT_timeSync.ecat_time_ns += 0x100000000LL;<br>
}</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> EtherCAT_timeSync.ecat_time_1 = ecat_time;<br>
up(&EtherCAT_timeSync.lock);<br>
}<br>
}</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">EXPORT_SYMBOL(ecrt_get_slave_sync_time);<span style="COLOR: #1f497d">
</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d">I assume I must export this function to user space, the same way as for example ecrt_master_send<span class="153374112-26112009"><font color="#0000ff" size="2"> </font></span></span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d"><span class="153374112-26112009"><font color="#ff0000" size="2"><span style="FONT-FAMILY: 'Times New Roman','serif'; COLOR: #1f497d; FONT-SIZE: 12pt"><span class="153374112-26112009"><font face="Arial"><font color="#ff0000" size="2">R:
</font></font></span></span>Yes, you should. I use this function only in kernel space so I did not exported to user space.</font></span></span></p>
<p class="MsoNormal"><span style="COLOR: #1f497d"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">EXPORT_SYMBOL(EtherCAT_timeSync);</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; COLOR: #1f497d; FONT-SIZE: 12pt">I assume I must create a function to export this struct to userspace, where the parameter is a pointer to a EtherCAT_timeSync stuct.<span class="153374112-26112009"><font color="#0000ff" size="2" face="Arial"> </font></span></span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; COLOR: #1f497d; FONT-SIZE: 12pt"><span class="153374112-26112009"><font color="#ff0000" size="2" face="Arial">R: In kernel space I access directly to the structure to read the delta_ecat_time_ns
value, you can create a simple function without parameters that return the value you need (ecat_time_ns or delta_ecat_time_ns) and export this function to the user space like you will do with the ecrt_get_slave_sync_time function.</font></span></span></p>
</div>
<div>
<p style="MARGIN-BOTTOM: 12pt" class="MsoNormal"><span style="COLOR: #1f497d"><o:p> </o:p></span></p>
<p style="MARGIN-BOTTOM: 12pt" class="MsoNormal"><span style="COLOR: #1f497d">Kind regards<o:p></o:p></span></p>
<p style="MARGIN-BOTTOM: 12pt" class="MsoNormal"><span style="COLOR: #1f497d"><o:p> </o:p></span></p>
<p style="MARGIN-BOTTOM: 12pt" class="MsoNormal"><span style="COLOR: #1f497d">Peter van Knippenbergh<o:p></o:p></span></p>
<p style="MARGIN-BOTTOM: 12pt" class="MsoNormal"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><br>
</span><span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt" lang="IT">Paolo Inselmini</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><br>
</span><span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt" lang="IT">Development Engineer</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
</div>
<div style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt">
<hr align="center" size="2" width="100%">
</span></div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 8pt" lang="IT">AGIE SA<br>
via dei Pioppi 2, 6616 Losone, Svizzera<br>
phone +41 (0) 91 806 95 73, Fax +41 (0) 91 806 92 42<br>
<a href="mailto:paolo.inselmini@ch.gfac.com">paolo.inselmini@ch.gfac.com</a>, <a href="http://www.gfac.com/">
www.gfac.com</a> </span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
<div style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt">
<hr align="center" size="2" width="100%">
</span></div>
<p class="MsoNormal"><span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 8pt" lang="IT">GFAgieCharmilles – Achieve more</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt" lang="IT">
</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
<p style="MARGIN-BOTTOM: 12pt" class="MsoNormal"><span style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt">-----Original Message-----<br>
<b>From:</b> etherlab-users-bounces@etherlab.org [mailto:etherlab-users-bounces@etherlab.org]
<b>On Behalf Of </b>Peter van Knippenbergh<br>
<b>Sent:</b> mercoledì, 25. novembre 2009 15:05<br>
<b>To:</b> etherlab-users@etherlab.org<br>
<b>Subject:</b> [etherlab-users] Timing measurements</span><span style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt"><o:p></o:p></span></p>
<p class="MsoNormal">Hi<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I want to measure the latency of sending and receiving cyclic data, one of the slaves is a Beckhoff EL5101. I want to read a timing register every cycle.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I want to map a register (not an object) to the process data, and therefore I tried to use the 3<sup>rd</sup> fmmu, but when going to OP, the ethercat master zero’s the 3<sup>rd</sup> fmmu.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Is there a easy way to get a timestamp in a user-space program for every cycle. It is ok for me if the communicated timestamp is an older tempstamp, because I want to use it for latency measurements. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Kind regards<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Peter van Knippenbergh<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</blockquote>
</body>
</html>