[etherlab-users] Control loop at higher frequencies

Gavin Lambert gavin.lambert at tomra.com
Thu Oct 31 00:07:13 CET 2019


When you use the master debug interface (or the newly added “ethercat pcap” command, although you won’t have that in your version yet), the receive timestamps are the time that they are received by the master, which is the time that you called ecrt_master_receive.

You can get a better understanding of the “real” wire transfer time by connecting a separate monitoring device between the master and first slave – a proper network monitor is ideal, but you can made do with a standard Ethernet hub/switch with three ports connected (master, first slave, monitoring laptop running Wireshark), although for best results (especially if it’s a Windows laptop) you should disable all the network protocols on the laptop adapter other than the minimum it needs to do the Wireshark monitoring, so that it doesn’t inadvertently transmit packets of its own.  (These won’t hurt the network itself, since both the master and slave will drop non-EtherCAT packets, but it may worsen the latency.)  This will still be somewhat inaccurate since it’s still timestamping when the packet was processed rather than when it was actually received in hardware, but it’s likely to be more accurate than doing it on the master since it’s not waiting for the cycle delay.

As Graeme said, you can also put the monitoring device elsewhere in the network (all packets will always pass every point in the network – except the end), although then it becomes harder to meaningfully use the timestamps.


Gavin Lambert
Senior Software Developer

[cid:logo_compac_5dcf97ef-52f5-498c-8b9b-728410ddffaf.png]
[cid:compacicon_82e8a8c7-154a-4a32-9720-a5badb6258e0.png]<http://www.compacsort.com> [cid:facebook_fa85b924-53b9-45cc-8162-0564f64ec3a3.png] <https://www.facebook.com/Compacsort>  [cid:linkedin_4ec016ad-84fa-443c-85a3-b9615a4ccef8.png] <https://www.linkedin.com/company/compac-sorting-equipment/>  [cid:youtube_32142163-fc27-4aed-b14d-e8a377f98a6d.png] <https://vimeo.com/compacsort>  [cid:twitter_d89338d8-98c8-4b65-9a9e-7b1333160b0d.png] <https://twitter.com/compacsort>  [cid:insta2_1cd85de9-b3a2-4971-9904-52b2481a7c82.png] <https://www.instagram.com/compacsort/>

COMPAC SORTING EQUIPMENT LTD | 4 Henderson Pl | Onehunga | Auckland 1061 | New Zealand
Switchboard: +64 96 34 00 88 | tomra.com<http://www.tomra.com>

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.

From: Graeme Foot
Sent: Thursday, 31 October 2019 11:49
To: Jordan Palacios <jordan.palacios at pal-robotics.com>
Cc: etherlab-users at etherlab.org
Subject: Re: [etherlab-users] Control loop at higher frequencies

Hi,

It is sounding like the data time on the wire is taking too long (> 250us).

Besides doubling the "DC system time transmission delay" of the last slave, you can also check the "Diff [ns]" value of your first slave.  This may give you a more accurate idea if you have a star topology, as the return trip of the frame from the last slave bypasses the fingers of the stars.  e.g.:

ethercat slaves -v -p0

=== Master 0, Slave 0 ===
Alias: 10001
Device: Main
State: OP
Flag: +
Identity:
  Vendor Id:       0x00000002
  Product code:    0x04562c52
  Revision number: 0x00110000
  Serial number:   0x00000000
DL information:
  FMMU bit operation: no
  Distributed clocks: yes, 64 bit
  DC system time transmission delay: 0 ns
Port  Type  Link  Loop    Signal  NextSlave  RxTime [ns]  Diff [ns]   NextDc [ns]
   0* EBUS  up    open    yes             -   3638440690           0           0
   1  MII   up    open    yes             1   3638442410        1720         560
   2  N/A   down  closed  no              -            -           -           -
   3  N/C   down  closed  no              -            -           -           -

You will also need to add on 2 * "master to first slave transmission delay" which you will probably need to guess.  If you use a Beckhoff CX2020 (or similar) where the CX2100 is directly connected to the EBus this will likely be around 150us.  If your master has an ethernet port and the first slave is an amp or a coupler this may be around 550us or more (depending on cable length).  You could also calc the frame transmission time.  Your frame length is 782 bytes.  So that should take ~ 6 - 7us.  Plus whatever other overheads the ethernet card / driver has.

Reducing the number of configured slaves (even with them still physically plugged in) will reduce the ec_master_domain_queue() and ec_master_send() overhead time, getting the frame to the wire quicker.  It will also reduce the frame length and the related frame transmission time (especially if you remove slaves with bigger datagram overhead).  It looks like this is enough to result in the total frame roundtrip time being reduce enough for it to return and be ready by the time that ec_master_receive() is called.


Just FYI, I have a machine downstairs at the moment with 42 slaves (14 of which are amps), linear topology.  The last slaves transmission delay is 19560ns.  The first slaves Diff is 39390ns.  The EtherCAT frame size is 886 bytes.  The ec_master_receive() to ec_master_send() time is approx 23us.  So your values sound in line with what I have, except that the wireshark output is showing a large cycle time.

In general it's looking like the time on the wire is taking longer than it should.  How are you capturing the EtherCAT frame data?  e.g.: a switch between your master and first slave?  If so, try moving it further down the chain, doing an "ethercat rescan" and check the transmission delays.  See if the switch is causing a large delay between those slaves.

What is your network card and driver used by the master?  What is your realtime system?  If you are using tshark on the master PC there might be delays being introduced in the network card driver.


Regards,
Graeme.


From: etherlab-users <etherlab-users-bounces at etherlab.org<mailto:etherlab-users-bounces at etherlab.org>> On Behalf Of Jordan Palacios
Sent: Thursday, 31 October 2019 4:36 AM
To: etherlab-users at etherlab.org<mailto:etherlab-users at etherlab.org>
Subject: [etherlab-users] Control loop at higher frequencies

Hi.

We've been working with the etherlab master for some time now. On our current setup we have around 40 slaves and our control loop runs at 1Khz without any issues. We use the stable version of etherlab with the 20180622 patchset.

Recently we've tried increasing the loop frequency to achieve a better control. The target frequency is 4Khz. After some troubles we managed a stable control at 2Khz. Then we went for the 4Khz and this is where we have hit a roadblock.

A warning like this is generated each second:

[11547.183302] EtherCAT WARNING 0: 4000 datagrams UNMATCHED!
[11547.619399] EtherCAT WARNING: Datagram ffff88040b6bf318 (domain0-0-main) was SKIPPED 4004 times.

As per what Florian explained here<https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.etherlab.org%2Fpipermail%2Fetherlab-users%2F2009%2F000386.html&data=02%7C01%7Cgavin.lambert%40tomra.com%7C04fb9669a65e4a8628df08d75d8b6027%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637080725509845944&sdata=zK%2BbQlmlBTBLOP65qEs7UIA6f%2BKC9XH%2FjyFpB7P2vwA%3D&reserved=0> this means that the answer to the last datagram sent has not been received yet. I don't think this is related to the rate at which we execute the control loop. We have instrumented it and is steady at 250us with a jitter below 10us (see attachment). Furthermore, we have also enabled the ethercat master debug interface. Here is a sample of the traffic output using tshark:

 7807 0.975750173 MS-NLB-PhysServer-19_95:2e:e1:b0 → Broadcast    ECAT 810 'LRW': Len: 782, Adp 0x0, Ado 0x0, Wc 69
 7808 0.975757725 Congatec_2e:e1:b0 → Broadcast    ECAT 810 'LRW': Len: 782, Adp 0x0, Ado 0x0, Wc 0
 7809 0.976000284 MS-NLB-PhysServer-19_95:2e:e1:b0 → Broadcast    ECAT 810 'LRW': Len: 782, Adp 0x0, Ado 0x0, Wc 69
 7810 0.976007872 Congatec_2e:e1:b0 → Broadcast    ECAT 810 'LRW': Len: 782, Adp 0x0, Ado 0x0, Wc 0
 7811 0.976252515 MS-NLB-PhysServer-19_95:2e:e1:b0 → Broadcast    ECAT 810 'LRW': Len: 782, Adp 0x0, Ado 0x0, Wc 69
 7812 0.976260050 Congatec_2e:e1:b0 → Broadcast    ECAT 810 'LRW': Len: 782, Adp 0x0, Ado 0x0, Wc 0

The master received is done right at the beginning of the loop, and is followed by the domain process, domain queue and master send. The calculations are done after. We instrumented the received/send calls and we know together take around 20us.

We originally made our calculations before the domain queue and master send. After reading what Graeme explains here<https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.etherlab.org%2Fpipermail%2Fetherlab-users%2F2018%2F003351.html&data=02%7C01%7Cgavin.lambert%40tomra.com%7C04fb9669a65e4a8628df08d75d8b6027%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637080725509855946&sdata=LeK76aJegbLDAZvk04IaKzVrtfbjqY9%2FZ%2B9uetwrSTE%3D&reserved=0> we changed the order to allow for more time for the data in the wire. This change helped achieving the 2Khz.

All of this means that the time at which the frames are received is another good indicator of the correct control loop periodicity. Note also how the next frame is sent right after.

Thing is, even though the WC is the expected (69 in this case), we think that these frames are always late. The datagram received is the one of the previous cycle. Hence the constant warning of 4000 datagrams skipped. The statistics reported by the "ethercat master" command show 4000 frames transmitted/received per second and no frames are lost.

Checking the "DC system time transmission delay" of the last slave we get a value of 38995 ns, which would translate to something like 80us for the frame to be in the wire. Keeping in mind we are allowing for 230us for the datagram to return (250us cycle minus 20us for receive/send) it should be more than enough. Yet something doesn't add up.

The only thing that seems to help is reducing the amount of slaves. If we switch to something like a 25 slave configuration then we manage to control at 4KHz without issues. We don't physically disconnect them though so the DC system time transmission delay remains the same. Obviously frame size is smaller.

We are not performing any calls related to distributed clocks in the master. If I understand correctly DC are used for synchronizing the data processing of the slaves. It should not affect the frame delay, right?

Any ideas are appreciated.

Kind regards.

Jordán.

--

Jordán Palacios

Software Engineer


[https://lh6.googleusercontent.com/mgsVJlQ9p5jN1eI-8SP0YOxUhv0BEXrjZFnqqzYgaopfqhinUDbC7abJqhSV9RmgauHBXoff-GMTrJpOL2B9iYbSUgQN3cY8gIFI1XzcMdqZ6nG_Qera_i9qg2VQk35dG0uR01Ut]

C/ Pujades 77-79, 4-4

08005 Barcelona, Spain


Skype jordanpalacios.pal-robotics

Tel +34 93 414 53 47<tel:%2B34%2093%20414%2053%2047>

jordan.palacios at pal-robotics.com<mailto:jordan.palacios at pal-robotics.com>


www.pal-robotics.com<https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.pal-robotics.com%2F&data=02%7C01%7Cgavin.lambert%40tomra.com%7C04fb9669a65e4a8628df08d75d8b6027%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637080725509865938&sdata=ud6L6AE%2BxMtBBfXHGyILhz9G0T9QFaMpscTQgSIk4pg%3D&reserved=0>
Facebook<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.facebook.com%2Fpalrobotics%2F&data=02%7C01%7Cgavin.lambert%40tomra.com%7C04fb9669a65e4a8628df08d75d8b6027%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637080725509865938&sdata=sPlDvHQ7mGc3ID8ZWzaaCQPKgYbRTuzEo02bBDDOb1A%3D&reserved=0> | Twitter<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftwitter.com%2FPALRobotics&data=02%7C01%7Cgavin.lambert%40tomra.com%7C04fb9669a65e4a8628df08d75d8b6027%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637080725509875939&sdata=7OB76GKDkYcMFepI3cXw%2FLmIEGVlARXPHuzvES2clmQ%3D&reserved=0> | YouTube<https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.youtube.com%2Fuser%2FPALRobotics&data=02%7C01%7Cgavin.lambert%40tomra.com%7C04fb9669a65e4a8628df08d75d8b6027%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637080725509875939&sdata=TJA6vduSHtLn93DYqKU3EVEnYUxyZit2U5xCHfhPMdo%3D&reserved=0> | Blog<https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.pal-robotics.com%2F&data=02%7C01%7Cgavin.lambert%40tomra.com%7C04fb9669a65e4a8628df08d75d8b6027%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637080725509885933&sdata=Oi%2B7eys7YYEEGhMCvGHtjC3BjZgTXjRzc5Ry7DVikeY%3D&reserved=0>


AVISO DE CONFIDENCIALIDAD: Este mensaje y sus documentos adjuntos, pueden contener información privilegiada y/o confidencial que está dirigida exclusivamente a su destinatario.  Si usted recibe este mensaje y no es el destinatario indicado, o el empleado encargado de su entrega a dicha persona, por favor, notifíquelo inmediatamente y remita el mensaje original a la dirección de correo electrónico indicada. Cualquier copia, uso o distribución no autorizados de esta comunicación queda estrictamente prohibida.


CONFIDENTIALITY NOTICE: This e-mail and the accompanying document(s) may contain confidential information which is privileged and intended only for the individual or entity to whom they are addressed.  If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of this e-mail and/or accompanying document(s) is strictly prohibited.  If you have received this e-mail in error, please immediately notify the sender at the above e-mail address.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20191030/0c47f0d4/attachment-0003.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo_compac_5dcf97ef-52f5-498c-8b9b-728410ddffaf.png
Type: image/png
Size: 11438 bytes
Desc: logo_compac_5dcf97ef-52f5-498c-8b9b-728410ddffaf.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20191030/0c47f0d4/attachment-0028.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compacicon_82e8a8c7-154a-4a32-9720-a5badb6258e0.png
Type: image/png
Size: 1629 bytes
Desc: compacicon_82e8a8c7-154a-4a32-9720-a5badb6258e0.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20191030/0c47f0d4/attachment-0029.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: facebook_fa85b924-53b9-45cc-8162-0564f64ec3a3.png
Type: image/png
Size: 1750 bytes
Desc: facebook_fa85b924-53b9-45cc-8162-0564f64ec3a3.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20191030/0c47f0d4/attachment-0030.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: linkedin_4ec016ad-84fa-443c-85a3-b9615a4ccef8.png
Type: image/png
Size: 1855 bytes
Desc: linkedin_4ec016ad-84fa-443c-85a3-b9615a4ccef8.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20191030/0c47f0d4/attachment-0031.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: youtube_32142163-fc27-4aed-b14d-e8a377f98a6d.png
Type: image/png
Size: 1970 bytes
Desc: youtube_32142163-fc27-4aed-b14d-e8a377f98a6d.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20191030/0c47f0d4/attachment-0032.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: twitter_d89338d8-98c8-4b65-9a9e-7b1333160b0d.png
Type: image/png
Size: 20278 bytes
Desc: twitter_d89338d8-98c8-4b65-9a9e-7b1333160b0d.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20191030/0c47f0d4/attachment-0033.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: insta2_1cd85de9-b3a2-4971-9904-52b2481a7c82.png
Type: image/png
Size: 1506 bytes
Desc: insta2_1cd85de9-b3a2-4971-9904-52b2481a7c82.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20191030/0c47f0d4/attachment-0034.png>


More information about the Etherlab-users mailing list