Modbus Master

Modbus is an open and de facto standard communications protocol that is available in many programmable logic controllers (PLCs) and field devices for transfer of static data values using serial or IP messaging.

Modbus Object/Data Types

Data is presented in four data types, each with an address space, type, read/write mode and size.

00001 – 09999: Coils (read/write): 1 bit
10001 – 19999: Discrete Inputs (read only): 1 bit
30001 – 39999: Input Registers (read only): 16 bits
40001 – 49999: Holding Registers (read/write): 16 bits

Example – Using Modbus master protocol for connecting to field devices  

The example below shows a typical application where the RTU interfaces to a number of field devices using the Modbus master protocol. The data read from the field devices is stored in variables that can be used to map this data to other RTU protocol interfaces eg. data read using the Modbus master is exposed to the SCADA host using DNP3 slave protocol, and/or to a local HMI.

Modbus Master – setup is easy

Use the fieldbus configurator to add the Modbus master protocol, then create ‘master ports’ for each device.  Select TCP, UDP or serial  for each port and then add ‘master request’ blocks to the port for each message/data type eg. read input bits, read or write coil bits, read input registers and read or write holding registers. The master request blocks include parameters for the slave address, message type, start address, number of items, message activation type and an option to declare variables.  The message activation types include ‘Periodic’ eg. every 500ms, ‘On call’ eg. triggered by an associated logic variable, or ‘On change’.  Triggering a message on change is a convenient way to manage the sending of messages for write types, such as holding registers and coils.

Modbus Master – advanced setup with function blocks in the logic application

The methods shown above for managing Modbus master messages are suitable for most applications, but if the messages need to be more ‘dynamic’ then Modbus master function blocks can be used in the logic application.  The WorkSuite logic editor includes MODBUSMASTERRTU (serial) and MODBUSMASTERTCP (TCP/IP) function blocks that allow control of the message contents.  

Example – managing different field devices in the logic application 

For example in some pump controller applications a common logic program may be shared across multiple sites, but the sites may have a mix of field devices eg. flow meters from different vendors might have different data formats (16 bit integers, 32 bit floats) and use different data addresses.  If the flow meter  setup information is passed to the RTU from the SCADA host either as list of numbers, or in a CSV file, then the logic program could use this information to control the contents of the Modbus master messages dynamically, thus avoiding the need for unique logic programs in each pump station!

Click on an icon below to find out more about a particular protocol or driver.