Difference between revisions of "Protocol:Modbus:32-bit Types"

From Serious Documentation
Jump to: navigation, search
(Does SHIP Modbus Support include Read/Write Multiple?)
Line 4: Line 4:
 
== Does SHIP Modbus Support include Read/Write Multiple? ==
 
== Does SHIP Modbus Support include Read/Write Multiple? ==
  
A common question we get goes something like this: ''"Do you support read/write multiple?"''.
+
This is a common question, and the answer to that question is “it depends”.
 
 
The answer to that question is “it depends”.
 
 
   
 
   
 
We support only the movement of one “logical variable” at a time.  Each variable is moved with a single function (i.e. packet).  If the variable is a short or Boolean type, this is FC06/FC05 respectively.  If the variable is a longer type, i.e. 32-bits like an Integer or Float, we use FC16 to move the pieces of the variable as a single transaction.
 
We support only the movement of one “logical variable” at a time.  Each variable is moved with a single function (i.e. packet).  If the variable is a short or Boolean type, this is FC06/FC05 respectively.  If the variable is a longer type, i.e. 32-bits like an Integer or Float, we use FC16 to move the pieces of the variable as a single transaction.
Line 12: Line 10:
 
So, if you have (for example) 4 independent link variables:
 
So, if you have (for example) 4 independent link variables:
 
   
 
   
linkvar  v1          type=”Short”    address=”0x0001”         
+
{| class="wikitable" style="margin: 1em 1em;"
linkvar   v2          type=”Short”    address=”0x0002”
+
! scope="col" style="text-align:left" | linkvar name
linkvar  v3          type=”Short”    address=”0x0003”
+
! scope="col" style="text-align:left" | Datatype
linkvar  v4           type=”Short”    address=”0x0004
+
! scope="col" style="text-align:left" | Address
+
|-
 +
|<code>v1</code>|| {{DataType|Short}}||<code>0x0001</code>
 +
|-
 +
|<code>v2</code>|| {{DataType|Short}}||<code>0x0002</code>
 +
|-
 +
|<code>v3</code>|| {{DataType|Short}}||<code>0x0003</code>
 +
|-
 +
|<code>v4</code>|| {{DataType|Short}}||<code>0x0004</code>
 +
|-
 +
|}
 +
 
 
You cannot use FC16 to set them all in a single packet; you have to call the FC06 4 times.
 
You cannot use FC16 to set them all in a single packet; you have to call the FC06 4 times.
 
   
 
   

Revision as of 13:00, 27 February 2015

See Also

Does SHIP Modbus Support include Read/Write Multiple?

This is a common question, and the answer to that question is “it depends”.

We support only the movement of one “logical variable” at a time. Each variable is moved with a single function (i.e. packet). If the variable is a short or Boolean type, this is FC06/FC05 respectively. If the variable is a longer type, i.e. 32-bits like an Integer or Float, we use FC16 to move the pieces of the variable as a single transaction.

So, if you have (for example) 4 independent link variables:

linkvar name Datatype Address
v1 Short 0x0001
v2 Short 0x0002
v3 Short 0x0003
v4 Short 0x0004

You cannot use FC16 to set them all in a single packet; you have to call the FC06 4 times.

However… if you are actually moving complex (larger) data types, we do use and require FC16.

linkvar x1 type=”Integer” address=”0x0001” -- moved with FC16 using a 2 register read/write multiple linkvar x2 type=”Float” address=”0x0002” -- moved with FC16 using a 2 register read/write multiple

Note that the addresses in SHIP are logical addresses. There is no concept of a byte-wise array that these address map down into. Therefore x1 and x2 above do not overlay in memory somehow like they might on a PLC which maps all addresses to bytewise memory, but rather x1 and x2 are completely independent entities each 32-bits in size.

The endianness of the 32-bit transaction as transported on the FC16 “2 register” transaction is fully controllable with all 8 options depending on your algorithms on your side of the communications.