SoftPLC
 
Font size:      

Overview

Introduction

This document describes the installation, usage and functionality of a TLM (TOPDOC Loadable Module) for SoftPLC versions 4.6 and later. This TLM implements the master side of the Modbus Master/Slave Protocol using a serial line. See here and here for definitions of this protocol.

The TLM described by this document is called MODBMAST. This software capability is implemented as a TOPDOC Loadable Module (TLM), written in C++ and implements a fairly comprehensive driver which can manage up to 247 slaves on each of up to 32 serial ports.

This TLM may be used to monitor and control serial RS485, RS422, or RS232 attached slaves. Modbus protocol has been used as the basis of SCADA systems, but was originally designed for communicating with Modicon PLC's. This TLM has features in it that allow it to also do a reasonable job controlling I/O. That is, it can be configured to takes special steps to drive outputs in a way consistent with programmable controller outputs, such as turning outputs off when transitioning to a program/stopped from a run mode. Both Modbus RTU and Modbus ASCII are supported, however Modbus ASCII support requires SoftPLC version 4.6.160608 and TOPDOC NexGen version 1.6.160608 or later.

SoftPLC offers other TLMs in support of Modbus TCP/UDP, as well as Modbus RTU/ASCII Slave. This TLM only implements the serial line form of the protocol and only the master side of it.


Four types of Modbus TLMs
Media TypeMasterSlave
Serial Line*this TLM*MODBSLAV
TCP and UDPModbusIPmasterModbusIPslave

TLMs may be developed by any competent C/C++ programmer who has access to the SoftPLC C/C++ Programmer's Toolkit, a product readily available from SoftPLC Corporation. There are a number of Systems Integrators who are SoftPLC Partners who possess the requisite expertise. End users may also have this capability.

Definitions

  • Modbus RTU and ASCII protocols are Modbus serial protocols. They support up to 247 slaves on any party-line type bus such as RS485, RS422, or radio packet network.
  • 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.
  • A Modbus query is another name for request.
  • Within a request is a Modbus function code, which is the byte which actually determines the purpose of the request.

Concepts

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.

Features

Serial Ports and Slaves

To use the Modbus Master you need one or more Modbus serial slaves and one or more compatible serial ports on your SoftPLC master machine. (SoftPLC Corporation can provide master machines with many serial ports.) Up to 32 serial ports can be configured and are supported by the software. On each port there can be up to 247 slaves.

Optional Hardware Handshaking

As a configuration option, the TLM can manipulate the RTS (request to send) serial port signal line, and watch for the CTS (clear to send) line. This can be useful to drive a radio packet modem, by using RTS to fire up a radio transmitter. The RTS line will be asserted just before it is time to send, and the CTS line can be a condition of sending. This is optional on a per port basis, and with port specific timing adjustments.

Request Specific Cycle Time

Each request may have its own timeout and retry count. Each request can be given its own cyclical period of repetition, or may run on the basis of "as fast as possible". Generally, all the requests on a port are handled on a round robin basis, but the requests configured with a specific cycle time can modify this behavior within reason.

Configuration File Supports Inheritance

The configuration file uses XML, and a dedicated configuration editor is provided to make the entry of requests user friendly. The nature of the XML attributes used makes it possible for an XML element to inherit a value from its parent/container XML element if not explicitly provided at nested element level.

Requests Operate Using Scatter/Gather

When declaring a request in the configuration file, the master's source datatable does not need to be contiguous for any single Modbus write, nor does the master's destination datatable for any single Modbus read. That is, a single read may put the results obtained from a single read into various places within the datatable. And the datatable values used in a single write do not have to come from a single block within the master's datatable.

Slave Specific Error Reporting

The driver includes some ladder instructions which manage slave specific error and reporting status, and are used to troubleshoot a Modbus network and track down problematic slaves.

Massive Datatable

SoftPLC controllers have access to massive amounts of datatable and this makes it possible to use this TLM to manage large multi-bus SCADA systems. The SoftPLC master can be a data concentrator of the highest class.

No Extensive Programming

This TLM can be used without extensive application program logic. Only a few rungs are needed to retrieve slave status blocks. This makes it easy to deploy.

Each request can be earmarked with one of three "when" attribute values as a means of determining when the request may be sent.

The Three Types of Scheduling Earmarks
WhenDescription
start These are messages which are sent only once to a slave upon a transition of the SoftPLC master to a RUN mode, and can be used as single shot configuration data.
run These are continuous scan type messages issued when the SoftPLC master is in a RUN mode. Messages of this kind can also have a cyclical periodic rate defined, or can run as fast as possible.
stop These are single shot requests issued once when the master transitions to a PROGRAM (stopped) mode.


SoftPLC also provides a Modbus RTU/ASCII 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 common Modbus functions and whether they are supported by this TLM or not:

Modbus Function 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