<html>
<head>
</head>
<body>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">Hi</font> </p>
<br>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">Because EtherCAT works like a closed loop (kind of a huge shift register), you won't receive any data if you don't send it.</font> </p>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">Slaves do not send data, they manipulate the existing bits of the frame while it passes around.</font> </p>
<br>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">If you sleep long enough for the ethernet frame to travel around (roughly 80ns per byte), the new data is already there when you call ecrt_master_receive.</font> </p>
<br>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">Our cyclic loop works as follows:</font> </p>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">ecrt_master_receive</font> </p>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">ecrt_domain_process</font> </p>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">ecrt_domain_queue</font> </p>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">ecrt_master_send</font> </p>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">calculate</font> </p>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">sleep</font> </p>
<br>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">Pros: calculation occurs while frame is being sent</font> </p>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">Cons: calculated data will be sent a step later</font> </p>
<br>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">The sleep time is measured and recalculated and adjusted to a given cycle time relative to a given start time.</font> </p>
<br>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">Regards</font> </p>
<p style="margin-bottom: 0; margin-top: 0">
<font face="Dialog" size="2">Martin</font> </p>
<p style="margin-bottom: 0; margin-top: 0">
<br>
<br>
>>> Shahbaz Yousefi <shabbyx@gmail.com> 20/10/2011 14:41 >>><br>Hi Richard,<br><br>I wouldn't have responded in the mailing list per your request of continuing this outside the mailing list, but I didn't hear back from you and the conversation seems like it's still continuing here.<br><br>The way you describe what we need does sound bad, but what we need is in fact different. I will use your own analogy.<br><br>First of all, let's compute the times better:<br><br>- The real-time thread's working cycle is, let's say 40ms. Therefore, a complete 24-hour day is 40ms<br>- The time we process the data is 0.5ms. Therefore, the thread only works 0.5/40*24*60 = 18 minutes.<br>* Problem is you assume the thread is working from morning to night, while in fact it only works less than 20 minutes.<br>- The time it takes for EtherLab's packet to circulate (in our case with 100 slaves) is roughly 3.3ms. That is 3.3/40*24 ~= 2 hours<br>* I don't know if you actually computed that or it was a lucky guess, but yes, it does take the postman 2 hours to go take the mail! :))<br><br>Now imagine the postman brings you newspaper everyday. It takes the newspaper company (slaves) to produce newspaper only once a day and they produce it at 8 in the morning.<br><br>Your method is this:<br><br>- You wake up in the morning, take the newspaper that is already there.<br>- You read it for 20 minutes and you write a summary for the president.<br>- You tell the postman to go bring you the newspaper of today (because today you read the newspaper of yesterday)<br>- You start kicking dirt, drinking coffee, having beer, watching tv and do nothing. In the meantime, the postman has already brought you today's newspaper.<br>Regardless of the arrival of the new newspaper, you still do nothing. Finally you go to bed<br>- Next morning, you wake up again and take the newspaper that is already there (which is yesterday's newspaper) and all over again<br><br>Problem with your method? You are always one day behind. The enemy is moving in land, taking your city's one by one and you don't tell the president about it until the next day.<br><br>What we are proposing:<br><br>- You wake up in the morning.<br>- You tell the postman to go bring you the newspaper of **today**<br>- You know it takes the postman roughly 2 hours to go and return, so you go to sleep again.<br>- You wake up first after 2 hours, then every half hour to check if the postman has arrived. Most likely, if he hasn't arrived the first time you check he will the second time.<br>- When he arrives, you take the newspaper of today, read it for 20 minutes and report to the president.<br>You have done a great job of notifying the president of the newest threats and you dedicate the rest of the day to your family. At night you go to sleep.<br>- Next morning, you wake up and all over again<br><br>Problem with our method? The postman doesn't like ringing bells (no interrupts for arrival of data). Worse than that, there is a monster out the window so that if you try looking for the postman it pokes you in the eye (no polling of data arrival).<br><br>Our request? Please remove the monster so we could check to see when the postman has arrived.<br><br>Let me review:<br><br>The task's period is much larger than the time it takes the network to send an receive data (24 hours period compared to 2 hours for postman to go and come back)<br>With your method, once you wake up, you get data of 22 hours ago. But you immediately process them<br>With our method, once you wake up, you wait for 2 hours, then you process data of this instant.<br><br>Does the first method really look better to you? All that stands between the second method working or not is a simple "is_there_new_data()"!<br><br>Shahbaz<br><br>P.S. My colleague had visualized the two scenarios and emailed the list a few days ago, but apparently it has gone to spam. Is it possible for you to retrieve it? Or should I send on his behalf?<br><br> </p>
<div class="gmail_quote">
<p style="margin-bottom: 0; margin-top: 0">
On Thu, Oct 20, 2011 at 11:28 AM, <span dir="ltr"><<a href="mailto:etherlab-users-request@etherlab.org">etherlab-users-request@etherlab.org</a>></span> wrote:<br> </p>
<blockquote style="margin-bottom: 0; padding-left: 0; margin-left: 0; margin-top: 0; border-left: 1px #ccc solid; margin-right: 0" class="gmail_quote">
<p style="margin-bottom: 0; margin-top: 0">
<br>
Date: Thu, 20 Oct 2011 11:28:05 +0200<br>From: Richard Hacker <<a href="mailto:ha@igh-essen.com">ha@igh-essen.com</a>><br>Subject: Re: [etherlab-users] Knowing when the packet has finished<br>cycle<br>To: <a href="mailto:etherlab-users@etherlab.org">etherlab-users@etherlab.org</a><br>Message-ID: <<a href="mailto:201110201128.05123.ha@igh-essen.com">201110201128.05123.ha@igh-essen.com</a>><br>Content-Type: Text/Plain; charset="iso-8859-1"<br><br>Hi<br><br>thanks Jeff for trying to shed some light on the matter from another<br>perspective.<br><br>I have to correct a certain point though: A slave does not send its data to<br>the master. The master sends an ethercat packet where the slaves put in their<br>data. This packet is queued automatically in ecrt_domain_queue() together<br>with the output packet. That is what makes EtherCAT soooo efficient. Jeff, you<br>may stop reading here ;). Others who are still not convinced, read on.<br><br>You must think of EtherCAT like a postal system. In the morning, you go to<br>your inbox and pick up the post for the day. You go to your desk, open the<br>mail, process the stuff, write responses. At the end of the day you take all<br>your outgoing mail to the mailman, then your work for the day is finished -<br>you go home, have some rest, recover, have a beer, watch TV, sleep. In the<br>meantime, the postman is quite busy delivering all your letters, and at the<br>same time also collects new letters for you that he drops in your inbox,<br>sometime during the night. Next day, everything starts from the beginning<br>again.<br><br>The other EtherCAT option as requested by the initiators of this thread is:<br>In the morning, you run to the postman, scream at him so that he *immediately*<br>thrashes his horse, that he goes out at full speed fetching all the mail for<br>you ASAP and delivers the letters to your inbox. While the postman is running<br>around like a headless chicken, you go and have a cup of coffee and check<br>every 5 seconds whether new mail has arrived (note that the postman does not<br>ring when he delivers mail). Sometime during the morning with 2 hours delay<br>(mind you, you have been checking every 5 seconds because you were very eager<br>in getting the latest news), you eventually see that there is new mail. Now<br>you have the chance to react to the letters you receive. Late in the<br>afternoon, with 2 hours delay (because the postman was still toooooo slow in<br>the morning), your letters are ready for delivery. Then you run to the<br>mailman, scream at him to *immediately* thrash his horse so that he delivers<br>your responses ASAP. You go home, after a short night, everything starts from<br>the beginning again.<br><br>To save you from checking every 5 seconds for new mail in the morning, you<br>install a bell and request the mailman to ring when he drops new mail, so that<br>you have a more peaceful cup of coffee at least. However, you are still late<br>by 2 hours and your boss fires you for not getting finished in time.<br><br>Now I ask with tears in my eyes, which system is better???<br><br>Another side note: the senders of your letters had their mail for you ready in<br>time for their beer in the evening and they certainly will not get up in the<br>middle of the night to read your letters. They are a relaxed bunch, preferring<br>the first system. Hence your haste, little sleep and the poor old breathless<br>postman were all not worth their while, shame! The bell you installed also did<br>not have the intended effect, you are still fired.<br><br>I hope that I have now explained EtherCAT in such simple terms that everyone<br>understands what happens when:<br>ecrt_master_receive(): go to the inbox to fetch new mail in the morning<br>ecrt_domain_process(): mail gets distributed to the collegues<br>compute(): work work work<br>ecrt_domain_queue(): the collegues bring the mail to you<br>ecrt_master_send(): you go to the postman with new letters in the afternoon<br>sleep(): Have a beer<br><br>Note that not all collegues work every day. Some come every 2 days, others<br>once a week, etc. Also, some of the processing takes more than 1 day, maybe 2,<br>maybe 3 days. It really is not helpful that some collegues have 21 hour days,<br>others have 17 hour days, they really do not fit into our schedule of a 24<br>hour day (analogy why 30ms and 40ms tasks do not work together nicely)<br><br>The other system:<br>read inputs; calculate; write outputs; sleep<br>will require a mailing system where *all* the senders of letters to you<br>personally deliver their letters directly to your inbox. You personally go and<br>deliver your responses directly to the receivers. There is no postman<br>involved. This system also works, but only for a small environments. It is<br>fast but uses lots of resources. THIS IS NOT ETHERCAT! This is directly<br>attached IO. If that is what you want, then don't use EtherCAT.<br><br>Our ethercat system works like the first system. It does not *need* a bell<br>(the interrupt), that is why it does not *have* a bell (data_is_there()). The<br>postman is reliable, the mail is *allways* there in the morning. If the mail<br>is not there, the postman is dead and you need a new postman! Having redundent<br>postmen is a completely new aspect.<br><br>- Richard<br><br>On Wednesday 19 October 2011 20:26:55 Jeff Krasky wrote:<br>> > The question is "How long should the code Sleep ?!?" If it is too short,<br>> > the code would have trouble as mentioned above, if it is too long, there<br>> > will be not enough time to do following calculation.<br>><br>> I believe this is why it is up to the person writing the code to decide<br>> this. If you know your algorithm takes 800 microseconds to run, then don't<br>> pick a cycle time of 500 microseconds. If your algorithm is taking 800<br>> microseconds to run, pick a cycle time of 1 millisecond.<br>><br>> It seems like there is a difference of thought on what type of protocol<br>> EtherCAT is. Maybe someone can correct me, but I have been thinking of<br>> EtherCAT as an isochronous protocol. To me, that means you pick a cycle<br>> time, say 1 millisecond, and then your code gets an interrupt every<br>> millisecond. Upon detecting the interrupt, you read in new data,<br>> process/calculate, and send out new data. Then you just wait for the next<br>> interrupt.<br>><br>> It sounds like what some people are describing here is the desire for a<br>> non-cyclic protocol. If that is the case, one question comes to mind: will<br>> all the nodes send data to the Master at EXACTLY the same time? Lets say<br>> you modify EtherCAT to deliver an interrupt to your program when new data<br>> arrives on the network card (so you can process the new data as soon as<br>> possible). Well, if you have 30 nodes, you can expect 30 interrupts<br>> probably. So you detect one node's new data, go fetch it, and most likely<br>> before you even get done processing it, some other node will send<br>> something? How many times can your program be interrupted? Are you going<br>> to have a stack of nested interrupts? Even if you design the code to<br>> allow for all of these interrupts, most likely you won't finish processing<br>> data for any node until you have received all node's data, right? Like<br>> this:<br>><br>> <wait for Ethernet card to have one node's data><br>> start processing for one node<br>> get interrupted for more data<br>> do a little more processing<br>> get interrupted again<br>> ...<br>> ...<br>> ...<br>> get interrupted for the last node's data<br>> finish processing<br>> send<br>><br>> And if this somehow worked, like the nodes had VERY different timing<br>> requirements, then you wouldn't be operating synchronously. And isn't the<br>> idea of using EtherCAT to be synchronous?<br>><br>> I think the advantage of just waiting until your cycle time has elapsed is<br>> that you can go get the data from all nodes at once.<br>><br>> _______________________________________________<br>> etherlab-users mailing list<br>> <a href="mailto:etherlab-users@etherlab.org">etherlab-users@etherlab.org</a><br>> <a href="http://lists.etherlab.org/mailman/listinfo/etherlab-users" target="_blank">http://lists.etherlab.org/mailman/listinfo/etherlab-users</a><br>><br><br>Mit freundlichem Gru?<br><br>Richard Hacker<br><br>--<br>------------------------------------------------------------------------<br><br>Richard Hacker M.Sc.<br><a href="mailto:richard.hacker@igh-essen.com">richard.hacker@igh-essen.com</a><br>Tel.: <a href="tel:%2B49%20201%20%2F%2036014-16" value="+492013601416">+49 201 / 36014-16</a><br><br>Ingenieurgemeinschaft IgH<br>Gesellschaft f?r Ingenieurleistungen mbH<br>Heinz-B?cker-Str. 34<br>D-45356 Essen<br>Amtsgericht Essen HRB 11500<br>USt-Id.-Nr.: DE 174 626 722<br>Gesch?ftsf?hrung:<br>- Dr.-Ing. S. Rotth?user,<br>- Dr.-Ing. T. Finke,<br>- Dr.-Ing. W. Hagemeister<br>Tel.: <a href="tel:%2B49%20201%20%2F%20360-14-0" value="+49201360140">+49 201 / 360-14-0</a><br><a href="http://www.igh-essen.com/" target="_blank">http://www.igh-essen.com</a><br><br> </p>
</blockquote>
</div>
<p style="margin-bottom: 0; margin-top: 0">
<br>
</p>
<BR>
<div>
<img border="0" src="cid:CAWLVWPFDAFX.prod_8cm.jpg">
</div>
<font face="monospace"><br>
<br>
Note:<br>
This e-mail is for the named person's use only. It may contain confidential and/or privileged information. If you have received this e-mail in error, please notify the sender immediately and delete the material from any system. Any unauthorized copying, disclosure, distribution or other use of this information by persons or entities other than the intended recipient is prohibited.<br>
Thank You.</font></BODY></HTML>