<div dir="ltr"><div dir="ltr">Since I only needed to subtract the reference slave's time in each cycle from the previous fine, method 2a worked very well. So in the cycle, I have,</div><div dir="ltr"><br><div><div>#ifdef MEASURE_TIMING</div><div><span style="white-space:pre"> </span>ecrt_master_reference_clock_time(master, &t_cur);</div><div><span style="white-space:pre"> </span>printf("%" PRIu32 "\n", t_cur - t_prev);</div><div><span style="white-space:pre"> </span>t_prev = t_cur;</div><div>#endif</div><div><br></div></div><div><br></div><div>1- How is the time given by <i>ecrt_master_reference_clock_time() </i>affected by the synchronization process? Since I'm syncing the slave's clock in each cycle, I'm afraid that this would render this method biased in a way. </div><div>2- <a href="https://drive.google.com/file/d/1rxn1oh0qfaJJi0S_hXkK6wkpe_kO1LMU/view?usp=sharing">This</a> is the result of analyzing the value of <i>t_cur - t_prev, </i>which shows a jitter of about 20 microseconds. Does this value match your experience? It's certainly much lower than I expected. (I'm using a kernel without PREEMPT_RT and the process has the maximum priority with FIFO scheduler)</div><div>Best,</div><div>Mohsen</div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Oct 7, 2018 at 10:29 PM Mohsen Alizadeh Noghani <<a href="mailto:m.alizad3h@gmail.com">m.alizad3h@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear Graeme,<div>Thanks for the excellent and detailed explanation. Since I'm already using distributed clocks in my program, I think I just have to do capture the packets by Wireshark and analyze the timestamps. I will look into gavinl's patch for long-term analysis.</div><div>Best,</div><div>Mohsen</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Oct 3, 2018 at 2:49 AM Graeme Foot <<a href="mailto:Graeme.Foot@touchcut.com" target="_blank">Graeme.Foot@touchcut.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-NZ" link="#0563C1" vlink="#954F72">
<div class="m_-3920639001336168942m_-4820421522162564556m_-5825857937692589098WordSection1">
<p class="MsoNormal"><span>Two options:<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>1) You can use wireshark on another computer.<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>- Plug in a switch inline somewhere on your EtherCAT network, make sure it forwards without delay<u></u><u></u></span></p>
<p class="MsoNormal"><span>- Also plug your second computer into the switch, make sure you disable all protocols on the network card (but not the card itself)<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>1a)<u></u><u></u></span></p>
<p class="MsoNormal"><span>- In your application cycle call ecrt_master_sync_slave_clocks()<u></u><u></u></span></p>
<p class="MsoNormal"><span>- Run your application and use wireshart to log your data<u></u><u></u></span></p>
<p class="MsoNormal"><span>- Run the command:<u></u><u></u></span></p>
<p class="MsoNormal"><span>"C:\Program Files\Wireshark\tshark.exe" -r data.pcap -T fields -e ecat.reg.dc.systimeL > data.txt<u></u><u></u></span></p>
<p class="MsoNormal"><span>(replacing data.pcap and data.txt with your input and output filenames)<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>1b) If you have gavinl's patchset<u></u><u></u></span></p>
<p class="MsoNormal"><span>- In your application cycle call ecrt_master_64bit_reference_clock_time_queue()<u></u><u></u></span></p>
<p class="MsoNormal"><span>- Run your application and use wireshart to log your data<u></u><u></u></span></p>
<p class="MsoNormal"><span>- Run the command:<u></u><u></u></span></p>
<p class="MsoNormal"><span>"C:\Program Files\Wireshark\tshark.exe" -r data.pcap -T fields -e ecat.reg.dc.systime > data.txt<u></u><u></u></span></p>
<p class="MsoNormal"><span>(replacing data.pcap and data.txt with your input and output filenames)<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>- Filter out the appropriate information from data.txt and analyse. Note: wireshark will see each packet twice, once going out and once coming back in. If the switch is before your reference slave
then the timestamp will only be in the returning packet, if it's after then it will be in both.<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>2) analyse the info within your app<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>2a)<u></u><u></u></span></p>
<p class="MsoNormal"><span>- In your application cycle call ecrt_master_sync_slave_clocks()
<u></u><u></u></span></p>
<p class="MsoNormal"><span>- get the 32bit clock value using ecrt_master_reference_clock_time()<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>2b) If you have gavinl's patch set<u></u><u></u></span></p>
<p class="MsoNormal"><span>- In your application cycle call ecrt_master_64bit_reference_clock_time_queue()<u></u><u></u></span></p>
<p class="MsoNormal"><span>- get the 64bit clock value using ecrt_master_64bit_reference_clock_time()<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>- Analyse the results yourself in the app, or log to file<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>Notes:<u></u><u></u></span></p>
<p class="MsoNormal"><span>- The wireshark message timestamp is not accurate enough by itself, hence using the distributed clock reference slave timestamp<u></u><u></u></span></p>
<p class="MsoNormal"><span>- EtherCAT frames are broadcast messages so you don't need to do anything special on the switch for your wireshark PC to be able to see them<u></u><u></u></span></p>
<p class="MsoNormal"><span>- See: <a href="https://www.wireshark.org/docs/dfref/e/ecat.html" target="_blank">
https://www.wireshark.org/docs/dfref/e/ecat.html</a> for a list of possible tshark ethercat fields<u></u><u></u></span></p>
<p class="MsoNormal"><span>- The EtherCAT master syncs reference slave using the lower 32bits of the dc clock. If your application is running at 1khz then this value rolls over every 4.2 odd seconds, so gets more complicated
to track long running time. Gavinl's patchset adds the ability to read the whole 64bit timestamp using ecrt_master_sync_slave_clocks().<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>Regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span>Graeme Foot.<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> etherlab-users <<a href="mailto:etherlab-users-bounces@etherlab.org" target="_blank">etherlab-users-bounces@etherlab.org</a>>
<b>On Behalf Of </b>Mohsen Alizadeh Noghani<br>
<b>Sent:</b> Tuesday, 2 October 2018 10:50 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] Measuring the frequency of master sending the frames to network<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">In motion control applications, smooth motion and small error often requires an update rate of at least 1 KHz.<u></u><u></u></p>
<div>
<p class="MsoNormal">When defining a task in RTAI, we can set its execution frequency. Therefore, if we set the frequency to 2 KHz, the master is expected to send EtherCAT frames every 0.5 ms + jitter. <u></u><u></u></p>
<div>
<p class="MsoNormal">Other than using a network probe (e.g. Beckhoff ET2000) connected to another PC and analyzing the timestamps, is there a reliable way for measuring this frequency? In other words, I want to stress test the master for a few hours and make
sure that all frames are sent before the real-time deadlines.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Best, <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Mohsen<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote></div>
</blockquote></div>