ModbusIP Master TLM
  SoftPLC    Font size:      



This document describes the installation, usage, and functionality of a TOPDOC Loadable Module (TLM) for SoftPLC version 4.x and later. The TLM implements the master (or client) side of the Modbus TCP protocol. As an extension of the standard, it also implements the same protocol on UDP/IP.

This TLM may be used to monitor and control ethernet based I/O and MMI graphical user interface stations, or it may be used to communicate with other controllers on an ethernet. Modbus protocol was designed for communicating with Modicon PLC's and was not designed for communicating with I/O. However, this TLM is an I/O driver first and foremost, and a peer to peer messaging service secondarily. Therefore it takes special steps to overcome most shortcomings in the Modbus protocol with respect to I/O control, resulting in a good I/O solution to most control applications.

This driver can be used without any application program logic required for configuring I/O modules or firing messages. Messages are ear-marked for either "configuration" or "RUN mode continuous" purposes. Configuration messages take place automatically just as SoftPLC enters RUN mode. RUN mode continuous messages are issued cyclically any time SoftPLC is in RUN mode. Lastly, the RUN mode continuous messages automatically use alternate "write" data on the last scan before SoftPLC enters PROGRAM mode, and thus the process outputs will be turned off as you would expect.


  • Modus TCP protocol is similar to simple Modbus serial protocol. Modbus TCP runs on top of a TCP/IP connection and has a 6 byte header at the beginning of each simple modbus frame, where frame means either a request or response packet.
  • Modbus UDP protocol is nearly identical to Modbus TCP except that it runs connectionless on UDP/IP. Unlike TCP which is a gauranteed delivery service, when using UDP the application layer is responsible for any retries required due to possible loss of frames.
  • A Modbus transaction is master - slave in nature, and consists of the master node sending a request and the slave node replying to the request with a response. The master node always sends the request and the slave node always sends the response. The slave node only speaks when spoken to with a request. Each request is owed exactly one response.
  • The term client is an alternative to master. The term server is an alternative to slave.
  • Some requests may be earmarked as configuration requests, so that they are only sent when it is appropriate to configure an I/O module.
  • In this TLM, all output (Modbus "write") requests have two alternative forms of output data associated with them, live data and idle data. Which of the two forms of data is used depends on the SoftPLC runtime engine's Operating Mode.
  • Modbus IP means either Modbus TCP or Modbus UDP but not simple Modbus serial protocol.


The SoftPLC runtime engine software supports TLMs, which are shared library extensions to SoftPLC. A TLM may be loaded either as a DRIVER or as a MODULE. The difference between a DRIVER and a MODULE is that a DRIVER is called once per SoftPLC scan, and optionally an additional number of times per scan. A MODULE is only called when the control program decides to call it and not as an inherent part of the scan. TLMs are made known to SoftPLC in the MODULES.LST file which may be edited by TOPDOC NexGen by traversing to: PLC | Modules.


In order to use the modbus IP master TLM you need a working ethernet connection. This TLM takes a configuration file named MODBUS.XML and acts as a "scanner" or as "master" or a "client", three terms which mean the same thing in the context of Modbus IP. On the other end of any Modbus conversation is a "slave" or a "server". Because the master implemented by this TLM supports both TCP and UDP carriers for the Modbus protocol, this allows you to talk to slaves which implement MODBUS/UDP in addition to slaves which implement only MODBUS/TCP. Up to 128 servers are supported by this master. Each slave may be addressed using TCP or UDP, or both.

When TCP is used by the master, there is a TCP connection established. When UDP is used by the master, the request response sequence takes place in a "connection-less" fashion. Because UDP is not a guaranteed delivery service, any Modbus master using UDP instead of TCP to carry the modbus requests and responses should implement timeout and retry logic. This master TLM allows you to configure the response timeout and attempts for each UDP server uniquely.

SoftPLC also provides a Modbus IP Slave TLM, which is documented here. A single SoftPLC machine can be both a master and a slave. This capability gives the systems designer the power and flexibility to develop very powerful, fast and flexible distributed control systems. Obviously a SoftPLC Modbus master can talk to a SoftPLC Modbus slave as well as third party slaves.

distributed control

The following is a list of the Modbus Commands and whether they are supported or not:

Modbus Command Support
Modbus FunctionNameSupported
1Read CoilsYes
2Read Input DiscretesYes
3Read Multiple RegistersYes
4Read Input RegistersYes
5Write CoilYes
6Write Single RegisterYes
7Read Exception StatusNo
15Force Multiple CoilsYes
16Write Multiple RegistersYes
20Read General ReferencesNo
21Write General RegistersNo
22Mask Write RegisterYes
23Read Write RegistersYes
24Read FIFO QueueNo


  • A working ethernet or PPP link.
  • Version 4.x SoftPLC or later.