<html 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" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;}
span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:993601919;
mso-list-type:hybrid;
mso-list-template-ids:-558066252 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></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="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">No, in fact you <b>must not</b> call ecrt_sdo_request_write on each cycle; you must call it only to begin a write.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The proper sequence is:<o:p></o:p></p>
<ol style="margin-top:0cm" start="1" type="1">
<li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1">Call ecrt_sdo_request_index[_complete] to set the SDO to write (not required if this is the same SDO as the previous request / when created).<o:p></o:p></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1">Call ecrt_sdo_request_data and write the data value to be written by the request into this buffer.<o:p></o:p></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1">Call ecrt_sdo_request_write[_with_size] to begin the write request.<o:p></o:p></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1">Each subsequent cycle, call ecrt_sdo_request_state to check the progress – do not call any of the above again on the same object while the status is EC_REQUEST_BUSY.<o:p></o:p></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1">After completion, you may stop calling ecrt_sdo_request_state (although it’s harmless if you continue), and you may start over at #1 again on any subsequent cycle.<o:p></o:p></li></ol>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">#1-3 happen in the same cycle. You don’t have to do #4 on <i>
every</i> cycle, but you must not try to use the request object again in any other way until the request is completed (with success or error). You
<i>can</i> have multiple request objects active for a single slave at a time, but bear in mind that they will happen in series, not parallel. (Multiple requests for different slaves will happen in parallel, although only up to a preset concurrency limit.)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Since this is asynchronous functionality, you may find it useful to implement it with a state machine, although this is not required.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<span style="FONT-FAMILY: Gotham, Calibri, 'sans-serif'; COLOR: #231f20">
<strong>Gavin Lambert<br></strong>
<br>
Senior Software Developer TOMRA Fresh Food<br>
<br>
</span><br>
<br><img style="HEIGHT: 45px; WIDTH: 350px" src="cid:TOMRAFresh_final_size_times_two_2_99d242b2-ba06-4c25-ab26-020cca7ee6dd.png" width="350" height="45" border="0">
<br> <A href="https://www.facebook.com/TOMRAFreshFood" target=_blank><IMG
alt="tomra facebook" src="cid:TF-FB-icon_b77c57e4-4990-4f9d-b3a2-8e6ab45df7f2.jpg"
height=30></A> <A href="https://www.linkedin.com/company/tomra-fresh-food/"
target=_blank><IMG alt="tomra linkedin"
src="cid:TF-LinkedIn-icon_d54c4829-dcb9-450c-9187-34b26e85ebaa.jpg"
height=30></A> <A href="https://vimeo.com/tomrafreshfood"
target=_blank><IMG alt="tomra vimeo" src="cid:TOMRA-Vimeo_4673038e-313a-491f-b3a4-0b39ace6df88.jpg"
height=30></A> <A href="https://www.instagram.com/tomrafood/"
target=_blank><IMG alt="tomra instragram"
src="cid:TOMRAinstagram_45b30c55-490a-4f32-8fd3-998c152e3494.jpg"
height=30></A><BR>
<span style="FONT-SIZE: 75%; FONT-FAMILY: Calibri, Candara, Segoe, Optima, Arial, sans-serif; COLOR: #6e8186"> <b>Compac Technologies Ltd</b>
| 4 Henderson Place | PO Box 13 516 | Onehunga 1061 | New Zealand </span><br>
<p style="FONT-SIZE: 10pt; MARGIN-BOTTOM: 5pt; FONT-FAMILY: Arial; MARGIN-TOP: 0px"></p>
<span style="FONT-SIZE: 75%; FONT-FAMILY: Calibri, Candara, Segoe, Optima, Arial, sans-serif; COLOR: #6e8186"> Phone: +64 96 34 00 88 | <a href="https://www.compacsort.com">https://www.compacsort.com</a></span><br>
<span style="FONT-SIZE: 60%; FONT-FAMILY: Gotham, Calibri, 'sans-serif'; COLOR: #6e8186">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. </span><br>
<span style="FONT-SIZE: 60%; FONT-FAMILY: Gotham, Calibri, 'sans-serif'; WIDTH: 75%; COLOR: #6e8186">
</span><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> BUSSIERES Vincent<br>
<b>Sent:</b> Monday, 25 October 2021 08:55<br>
<b>To:</b> etherlab-users@etherlab.org<br>
<b>Subject:</b> [Etherlab-users] ecrt_sdo_request_state : error<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div id="divtagdefaultwrapper">
<div>
<pre><span style="color:black">Dear Etherlab users,<br><br>I use a Beckhoff module EL5102 (2 channels encoder interface) and two servodrives to control motors.<o:p></o:p></span></pre>
<pre><span style="color:black"><o:p> </o:p></span></pre>
<pre><span style="color:black">I develop a homing sequence as below :<o:p></o:p></span></pre>
<pre><span style="color:black"><o:p> </o:p></span></pre>
<pre><span style="color:black">1- Enable counter reset on channel 1 when index encoder is encountered<o:p></o:p></span></pre>
<pre><span style="color:black">2- Move axis 1 until index is encoutered<o:p></o:p></span></pre>
<pre><span style="color:black">3- Unable counter reset on channel 1 <o:p></o:p></span></pre>
<pre><span style="color:black">4- Enable counter reset on channel 2 when index encoder is encountered<o:p></o:p></span></pre>
<pre><span style="color:black">5- Move axis 2 until index is encoutered<o:p></o:p></span></pre>
<pre><span style="color:black">6- Unable counter reset on channel 2<o:p></o:p></span></pre>
<pre><span style="color:black"><o:p> </o:p></span></pre>
<pre><span style="color:black">Unabling and disabling counter reset is done using SDOs 0x80n0:01 where n is the channel number.<o:p></o:p></span></pre>
<pre><span style="color:black"><o:p> </o:p></span></pre>
<pre><span style="color:black">In my program, I create 2 SDO requests with « ecrt_slave_config_create_sdo_request » before changing master state in OP with « ecrt_master_activate ».<o:p></o:p></span></pre>
<pre><span style="color:black">Then, before entering in cyclic task, I write SDOs for the first time and I get « EC_REQUEST_UNUSED » SDO request state (trigger first write), it seems to be OK.<o:p></o:p></span></pre>
<pre><span style="color:black"><o:p> </o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black">void enableIndexResetCh_n(state)</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black">{</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> switch (ecrt_sdo_request_state(mReqIndexResetCh_n)) {</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> case EC_REQUEST_UNUSED: </span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> ecrt_sdo_request_write(mReqIndexResetCh_n); </span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> break;</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> </span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> case EC_REQUEST_BUSY:</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> break;</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="color:black"><o:p> </o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> case EC_REQUEST_SUCCESS:</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> EC_WRITE_U8(ecrt_sdo_request_data(mReqIndexResetCh1), static_cast<uint8_t>(state));</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> ecrt_sdo_request_write(mReqIndexResetCh_n); </span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> break;</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="color:black"><o:p> </o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> default:</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> ecrt_sdo_request_write(mReqIndexResetCh_n);</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> break;</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> }</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black"> break;</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="font-size:8.0pt;color:black">}</span><span style="color:black"><o:p></o:p></span></pre>
<pre><span style="color:black"><o:p> </o:p></span></pre>
<pre><span style="color:black">Then, I realize homing sequence in the cyclic task as described before.<o:p></o:p></span></pre>
<pre><span style="color:black">For the fisrt channel, I write « 1 » into SDO 0x8000:01, request state is « EC_REQUEST_SUCCES » but for the second channel 0x8010:02 I get « EC_REQUEST_ERROR » and SDO value remains at false state.<o:p></o:p></span></pre>
<pre><span style="color:black">I don’t understand why I get this error.<o:p></o:p></span></pre>
<pre><span style="color:black"><o:p> </o:p></span></pre>
<pre><span style="color:black">Moreover I want to let you know that I don’t call « ecrt_sdo_request_write » at each loop of cyclic task but only when I need to change sdo state. Perhaps this is not the right way to call this function. Do I have to call this function at each iteration ?<o:p></o:p></span></pre>
<pre><span style="color:black">How can I be sure that sdo state corresponds to the right state ? Do I have to read sdo state (if sdo is R/W) also at each iteration ?<o:p></o:p></span></pre>
<pre><span style="color:black"><o:p> </o:p></span></pre>
<pre><span style="color:black">Regards<o:p></o:p></span></pre>
</div>
</div>
</div>
</div>
</div>
</body>
</html>