<!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">
<style>@font-face {
font-family: Cambria Math;
}
@font-face {
font-family: Calibri;
}
@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-compose
}
.MsoChpDefault {
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 size="2" face="Arial">
<div><font face="Arial"><span class="176075108-26112009">Hi</span></font></div>
<div><span class="176075108-26112009"></span> </div>
<div><span class="176075108-26112009"><font face="Arial">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.</font></span></div>
<div><font face="Arial"></font> </div>
<div><span class="176075108-26112009"><font face="Arial">It's what you need?</font></span></div>
<div><font face="Arial"></font> </div>
<div><font face="Arial"></font> </div>
<div><font face="Courier New">struct {<br>
<span class="176075108-26112009"> </span>u64 ecat_time_ns;<span class="176075108-26112009"> //absolute sync thelegram time</span></font></div>
<div><font face="Courier New"><span class="176075108-26112009"> u32 delta_ecat_time_ns;<span class="176075108-26112009"> //sync thelegram cycle time</span></span><br>
u32 ecat_time_1;<br>
bool isSync;<br>
struct semaphore lock;<br>
} EtherCAT_timeSync;</font></div>
<div><font face="Courier New"></font> </div>
<div><font face="Courier New">void ecrt_get_slave_sync_time(ec_master_t *master)<br>
{</font></div>
<div><font face="Courier New"></font> </div>
<div><font face="Courier New"> u32 ecat_time;<br>
//s32 delta_ecat_time;</font></div>
<div><font face="Courier New"></font> </div>
<div><font face="Courier New"> 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>
}</font></div>
<div><font face="Courier New"></font> </div>
<div><font face="Courier New"> 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);</font></div>
<div><font face="Courier New"><br>
EtherCAT_timeSync.delta_ecat_time_ns = (s32)ecat_time - (s32)EtherCAT_timeSync.ecat_time_1;<br>
</font><font face="Courier New"><span class="176075108-26112009"> if(EtherCAT_timeSync.delta_ecat_time_ns < 0)<br>
EtherCAT_timeSync.delta_ecat_time_ns = (u32)(0x100000000LL + (s64)decat_time);</span><br>
</font></div>
<div><font face="Courier New"><span class="176075108-26112009"> </span>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</font></div>
<div><font face="Courier New"></font> </div>
<div><font face="Courier New"> if(ecat_time < EtherCAT_timeSync.ecat_time_1)<br>
{ //overflow, increment the owerflowed value<br>
EtherCAT_timeSync.ecat_time_ns += 0x100000000LL;<br>
}</font></div>
<div><font face="Courier New"></font> </div>
<div><font face="Courier New"> EtherCAT_timeSync.ecat_time_1 = ecat_time;<br>
up(&EtherCAT_timeSync.lock);<br>
}<br>
}</font></div>
<div><font face="Courier New"></font> </div>
<div><font face="Courier New">EXPORT_SYMBOL(ecrt_get_slave_sync_time);</font></div>
<div><font face="Courier New">EXPORT_SYMBOL(EtherCAT_timeSync);</font></div>
<div> </div>
<span style="FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: IT" lang="IT"></span>
<div><br>
</div>
<span style="FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-ansi-language: IT" lang="IT"><span class="357332110-26112009"></span></span>
<div></div>
<div><font face="Tahoma">P<span class="357332110-26112009">aolo</span></font></div>
<div><font face="Tahoma"><span class="357332110-26112009"></span></font> </div>
<div><font face="Tahoma"><span class="357332110-26112009"></span>-----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<br>
<br>
</div>
</font>
<blockquote style="MARGIN-RIGHT: 0px" dir="ltr">
<div class="Section1">
<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>
</font></div>
</body>
</html>