Protocol:Modbus:32-bit Types

From Serious Documentation
Revision as of 12:52, 27 February 2015 by Admin (talk | contribs) (Created page with " A common question we get goes something like this: ''"Do you support read/write multiple?"''. The answer to that question is “it depends”. We support only the movement...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A common question we get goes something like this: "Do you support read/write multiple?".

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 v1 type=”Short” address=”0x0001” linkvar v2 type=”Short” address=”0x0002” linkvar v3 type=”Short” address=”0x0003” linkvar v4 type=”Short” address=”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.