<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to IoDrvModbus 3.5.15.0 - ModbusRequest2</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/dd4ace27af/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/dd4ace27af/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/dd4ace27af/</id><updated>2020-03-05T18:31:06.423000Z</updated><subtitle>Recent posts to IoDrvModbus 3.5.15.0 - ModbusRequest2</subtitle><entry><title>IoDrvModbus 3.5.15.0 - ModbusRequest2</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/dd4ace27af/?limit=25#7463" rel="alternate"/><published>2020-03-05T18:31:06.423000Z</published><updated>2020-03-05T18:31:06.423000Z</updated><author><name>Tim.Manning</name><uri>https://forge.codesys.com/u/tim-manning/</uri></author><id>https://forge.codesys.com499c37b6230fd5062a8f1f70651ab14b6616e86c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You are probably right.  When doing this in the past, I always had the luxury of having a driver that handled queuing for me.  The application could just issue requests and wait for the response.&lt;/p&gt;
&lt;p&gt;I'll look into creating a message queue to handle all of the requests for all of the potential devices hanging off of a port.  It shouldn't be too hard.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>IoDrvModbus 3.5.15.0 - ModbusRequest2</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/dd4ace27af/?limit=25#f414" rel="alternate"/><published>2020-03-05T17:56:02.704000Z</published><updated>2020-03-05T17:56:02.704000Z</updated><author><name>dFx</name><uri>https://forge.codesys.com/u/dfx/</uri></author><id>https://forge.codesys.com3c787cbdb13fb1b060c6efe2f8fd78299d22beff</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;To me it feels wrong using multiple instances. RTU aim one com port, so there is only one query at a time. Using only one instance is the guarantee you have only one running at a time.&lt;/p&gt;
&lt;p&gt;Just update the pointers and sizes to point to the query you want to execute.&lt;/p&gt;
&lt;p&gt;Cycle 1 : execute=true, instance call&lt;br/&gt;
Cycle 2 : if xDone, execute=false, instance call, update pointers, execute=true, instance call&lt;br/&gt;
Cycle n : same as cycle 2.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>IoDrvModbus 3.5.15.0 - ModbusRequest2</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/dd4ace27af/?limit=25#5eb3" rel="alternate"/><published>2020-03-05T17:09:51.061000Z</published><updated>2020-03-05T17:09:51.061000Z</updated><author><name>Tim.Manning</name><uri>https://forge.codesys.com/u/tim-manning/</uri></author><id>https://forge.codesys.com34bc839327dbb9565c2542c580ccf07afd5df314</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I think the proposed logic would handle this:&lt;/p&gt;
&lt;p&gt;cycle 1 - Execute instance 1 (execute.1 OFF to ON)&lt;br/&gt;
cycle 2 - look for instance 1 done (execute.1 should go from ON to OFF)&lt;br/&gt;
cycle 3 - If Instance 1 done, Execute instance 2 (execute.2 OFF to ON)&lt;br/&gt;
cycle 4 - look for instance 2 done (execute.2 should go from ON to OFF)&lt;br/&gt;
cycle 5 - If Instance 2 done, Execute instance 3 (execute.3 OFF to ON),&lt;br/&gt;
cycle 6 - look for instance 2 done (execute.3 should go from ON to OFF)&lt;br/&gt;
... etc.&lt;/p&gt;
&lt;p&gt;So, by the time we get back to the first instance, its execute flag should already be OFF, and we will set it ON.&lt;/p&gt;
&lt;p&gt;Our current logic is:&lt;/p&gt;
&lt;p&gt;Cycle 1 - Execute Instance 1 through Instance 8 (execute.1 through execute.8  OFF to ON)&lt;br/&gt;
Cycle 2 - look for instance 1 through instance 8 done&lt;br/&gt;
Cycle 3 - Execute Instance 1 through Instance 8 (execute.1 through execute.8  OFF to ON)&lt;br/&gt;
Cycle 4 - look for instance 1 through instance 8 done&lt;br/&gt;
etc.&lt;/p&gt;
&lt;p&gt;As I mentioned, our current logic only works for the first instance referenced in the code.  The 2nd and later instances return a 'busy' error.  So, the messages are being issued, they are just not being processed because the port is busy.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>IoDrvModbus 3.5.15.0 - ModbusRequest2</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/dd4ace27af/?limit=25#7b88" rel="alternate"/><published>2020-03-05T16:54:22.615000Z</published><updated>2020-03-05T16:54:22.615000Z</updated><author><name>dFx</name><uri>https://forge.codesys.com/u/dfx/</uri></author><id>https://forge.codesys.com5ba8718c82fdabdbc01104f9feaa4a7b0578edd9</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You may need a cycle with execute=false (or two successive calls) because queries are send with raising edge of execute.&lt;br/&gt;
A simple case may be appropriate to handle the queue/active queries, and one more to correctly sequence your queries.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>IoDrvModbus 3.5.15.0 - ModbusRequest2</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/dd4ace27af/?limit=25#d0a0/29b4" rel="alternate"/><published>2020-03-05T16:00:21.464000Z</published><updated>2020-03-05T16:00:21.464000Z</updated><author><name>Tim.Manning</name><uri>https://forge.codesys.com/u/tim-manning/</uri></author><id>https://forge.codesys.com6650ff345a246c5ae46acc70993da311c35edb07</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;The current results are as follows:&lt;/p&gt;
&lt;p&gt;First device referenced in code - communications are successful every scan&lt;br/&gt;
Second (and later) device reference in code - communications fail every scan&lt;/p&gt;
&lt;p&gt;From your question, it sounds like the application needs to handle queuing the messages when using ModbusRequest2.&lt;/p&gt;
&lt;p&gt;Our requirement is this:&lt;/p&gt;
&lt;p&gt;Communicate to up to 8 devices (per communication port) every second.&lt;/p&gt;
&lt;p&gt;When using the Modbus Driver in the device tree, all I needed to do was create 8 slave devices per port, and then create a Modbus channel for each of these devices that was cyclic.  Communications to each device was successful - I assume the Modbus driver was queuing the requests and processing them in order.&lt;/p&gt;
&lt;p&gt;Because we need more control over the communications than what we can get from the device tree, we've now created a program with 8 instances of a function block that includes the Modbus2 request.  We are running this program in a task that runs at 500 msecs.  The thinking was we would run with the execute set at the top of the second for each instance of the function block, and the execute would be cleared at the bottom of the second.  We were assuming that all of the messages would be queued to the driver, and processed in order.  &lt;/p&gt;
&lt;p&gt;However, it sounds like we need to rethink our logic.  &lt;/p&gt;
&lt;p&gt;Run the task 16 times a second (minimum - probably need to run it faster in order to provide some 'deadtime' during the 1 second interval, in case exception based comms need to occur) -&lt;/p&gt;
&lt;p&gt;cycle 1 - Execute instance 1&lt;br/&gt;
cycle 2 - look for instance 1 done &lt;br/&gt;
cycle 3 - If Instance 1 done, Execute instance 2&lt;br/&gt;
cycle 4 - look for instance 2 done &lt;br/&gt;
cycle 5 - If Instance 2 done, Execute instance 3,&lt;br/&gt;
..&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>IoDrvModbus 3.5.15.0 - ModbusRequest2</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/dd4ace27af/?limit=25#d0a0/319c" rel="alternate"/><published>2020-03-05T16:00:18.089000Z</published><updated>2020-03-05T16:00:18.089000Z</updated><author><name>Tim.Manning</name><uri>https://forge.codesys.com/u/tim-manning/</uri></author><id>https://forge.codesys.com6b0429b03ca14278a78fe82762bfd76fa72560fc</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;The current results are as follows:&lt;/p&gt;
&lt;p&gt;First device referenced in code - communications are successful every scan&lt;br/&gt;
Second (and later) device reference in code - communications fail every scan&lt;/p&gt;
&lt;p&gt;From your question, it sounds like the application needs to handle queuing the messages when using ModbusRequest2.&lt;/p&gt;
&lt;p&gt;Our requirement is this:&lt;/p&gt;
&lt;p&gt;Communicate to up to 8 devices (per communication port) every second.&lt;/p&gt;
&lt;p&gt;When using the Modbus Driver in the device tree, all I needed to do was create 8 slave devices per port, and then create a Modbus channel for each of these devices that was cyclic.  Communications to each device was successful - I assume the Modbus driver was queuing the requests and processing them in order.&lt;/p&gt;
&lt;p&gt;Because we need more control over the communications than what we can get from the device tree, we've now created a program with 8 instances of a function block that includes the Modbus2 request.  We are running this program in a task that runs at 500 msecs.  The thinking was we would run with the execute set at the top of the second for each instance of the function block, and the execute would be cleared at the bottom of the second.  We were assuming that all of the messages would be queued to the driver, and processed in order.  &lt;/p&gt;
&lt;p&gt;However, it sounds like we need to rethink our logic.  &lt;/p&gt;
&lt;p&gt;Run the task 16 times a second (minimum - probably need to run it faster in order to provide some 'deadtime' during the 1 second interval, in case exception based comms need to occur) -&lt;/p&gt;
&lt;p&gt;cycle 1 - Execute instance 1&lt;br/&gt;
cycle 2 - look for instance 1 done &lt;br/&gt;
cycle 3 - If Instance 1 done, Execute instance 2&lt;br/&gt;
cycle 4 - look for instance 2 done &lt;br/&gt;
cycle 5 - If Instance 2 done, Execute instance 3,&lt;br/&gt;
..&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>IoDrvModbus 3.5.15.0 - ModbusRequest2</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/dd4ace27af/?limit=25#d0a0" rel="alternate"/><published>2020-03-05T15:21:19.495000Z</published><updated>2020-03-05T15:21:19.495000Z</updated><author><name>dFx</name><uri>https://forge.codesys.com/u/dfx/</uri></author><id>https://forge.codesys.com8064128bb12f55eeaa0b488737ad819d20216c1c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Do you suceed with multiples different queries to the same slave ?&lt;br/&gt;
Do you correctly wait for the xDone=TRUE  plus a scan cycle with xExecute=FALSE ?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>IoDrvModbus 3.5.15.0 - ModbusRequest2</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/dd4ace27af/?limit=25#6c9f" rel="alternate"/><published>2020-03-04T17:15:30.312000Z</published><updated>2020-03-04T17:15:30.312000Z</updated><author><name>Tim.Manning</name><uri>https://forge.codesys.com/u/tim-manning/</uri></author><id>https://forge.codesys.com75e88b599ed1d61d13c54ee2ae3c52f6ef4c6227</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;We are trying to communicate to multiple Modbus Slaves via a serial port (RS-485).  &lt;/p&gt;
&lt;p&gt;We are using the ModbusRequest2 Function Block, and when we communicate with one device, communications are successful.&lt;/p&gt;
&lt;p&gt;If we attempt to communicate to more than one slave device, we are only able to successfully communicate to one device.  We get a 'busy' error when communicating to the other devices.&lt;/p&gt;
&lt;p&gt;Our application looks like this:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt; &lt;span class="n"&gt;SysComOpen&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;opens&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;

 &lt;span class="n"&gt;ModbusRequest2&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="k"&gt;first&lt;/span&gt; &lt;span class="n"&gt;device&lt;/span&gt;

 &lt;span class="n"&gt;ModbusRequest2&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="k"&gt;second&lt;/span&gt; &lt;span class="n"&gt;device&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;When using the ModbusRequest2, is the application responsible for buffering multiple requests to the Com Port?  &lt;/p&gt;
&lt;p&gt;If we configure the Modbus Master in the device tree, the buffering seems to be handled by the Modbus driver.  &lt;/p&gt;
&lt;p&gt;Unfortunately, we have project requirements that prevent us from using i the Modbus Master in the device tree.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>