MBLogic
for an open world in automation
The soft logic system has its own data table which is independent of the main system (or communications) data table). The soft logic IO configuration provides the connection between the two data tables. Without a soft logic IO configuration, the soft logic program will run, but it will have no way to connect to real world IO or to the HMI.
Configuration is performed through a configuration file called "mblogic.config". This file holds all the data table names, addresses, and other required information. This is a plain text file which can be edited with any text editor. The configuration file is defined as follows:
The configuration must include a section named "&system". The system identification section is used to define parameters which apply to the overall soft logic system. These factors are:
Example:
[&system] type=ck plcprog=plcprog.txt scan=50
The configuration must include a section named "&logicsave". This section is used to define parameters which apply to the data table save and restore system (see the help topic on "Soft Logic Data Table Save" for details on how this works). These factors are:
Example:
[&logicsave] updateinterval=2.0 wordaddr=DS1,DS2,DS3,DS4,DS5,DS6,DS7,DS8,DS9,DS10
The remainder of the configuration consists of "IO sections". An IO section defines a group of addresses which are two be transferred between the two data tables. The section names are arbitrary, and the user is free to select any name desired provided it does not start with an ampersand ("&"). Names starting with an ampersand (e.g. "&system") are considered special and reserved for use by the soft logic system.
Address types determine how data is stored in the system data table. This includes the number of storage locations (e.g. registers) and the byte ordering. For numeric address types which occupy multiple registers, the least significant word is stored in the platform's native format. For Intel type CPUs (big endian), the first (lower address) register. For string data types, characters are stored in consecutively increasing addresses. The following address types are currently defined:
| Address Type | Data Type | Storage Location | # Storage Elements | Soft Logic Address Compatibility | Extended Data Type |
|---|---|---|---|---|---|
| coil | boolean | coil | 1 | X, Y, C | No |
| discrete | boolean | discrete inputs | 1 | X, Y, C | No |
| holdingreg | signed 16 bit integer | holding register | 1 | 'DS', 'XD', 'YD', 'XS', 'YS' | No |
| inputreg | signed 16 bit integer | input register | 1 | 'DS', 'XD', 'YD', 'XS', 'YS' | No |
| holdingreg32 | signed 32 bit integer | holding register | 2 | DD | Yes |
| inputreg32 | signed 32 bit integer | input register | 2 | DD | Yes |
| holdingregfloat | single precision (32 bit) floating point | holding register | 2 | DF | Yes |
| inputregfloat | single precision (32 bit) floating point | input register | 2 | DF | Yes |
| holdingregdouble | double precision (64 bit) floating point | holding register | 4 | DF | Yes |
| inputregdouble | double precision (64 bit) floating point | input register | 4 | DF | Yes |
| holdingregstr8 | string | holding register | 2 characters per register | TXT | Yes |
| inputregstr8 | string | input register | 2 characters per register | TXT | Yes |
| holdingregstr16 | string | holding register | 1 character per register | TXT | Yes |
| inputregstr16 | string | input register | 1 character per register | TXT | Yes |
An IO section must contain the following items:
Example:
[PBs] addrtype=coil base=32100 action=read logictable=X1,X2,X3,X4,X5,X6,X7,X8
[PartCount] addrtype=holdingreg32 base=42 action=write logictable=DS101
[PartName] addrtype=inputregstr16 base=1234 action=read logictable=TXT99 strlen=10
Review the documentation on the system data table before deciding which registers, coils, or discrete inputs to use.
A configuration must include one (and only one) "system identification" ("&system") section. It may include as many "IO" sections as desired. The IO sections may be given meaningful names (e.g. "PushButtons"). However, the primary purpose of a section is to group associated addresses together so they can be dealt with efficiently. A good approach is to have each IO section represent an field device module or IO card(s). This of course assumes that the client and server commands for the system data table have been grouped in this manner.
Addresses in the system data table are handled most efficiently when they are read or written in consecutive blocks.
For the soft logic data table, it does not matter what order addresses are in, or whether they are grouped together. This means that if you wish to group or organise addresses in your program differently in your soft logic program than they are organised in the actual field devices, it is best to do this in the soft logic configuration and to leave the actual IO communications in their natural order.
The name used for the soft logic program is defined in the system parameters (see above). Any name can be used, provided it doesn't conflict with the name of a file which is part of the system (e.g. one of the configuration files). The file can also have any file extension desired or even no file extension. This allows names such as "Machine_021.prog" or "Water_System.txt" (or whatever else is desired).
The soft logic program target scan rate is defined in the system parameters (see above). The target scan rate means that the system will attempt to run one scan of the soft logic program at the requested interval. Note that this is the desired scan rate, not the measured rate.
A soft logic system differs from a conventional PLC in that the soft logic system is running on a general purpose computer platform. There may be other things such as HMIs, databases, and other tasks running on the same platform. On a conventional PLC, to add more features you would normally just add more hardware modules (with each feature needing its own hardware to run on). A soft logic system will often have to share the hardware with other applications. This means that the soft logic system cannot assume that all the computing resources are available for its exclusive use.
For a soft logic system, this means that taking up 100% of the CPU capacity to scan the program as fast as possible is not a good idea. In a new application, the target scan rate should be initially set to a larger value (e.g. 50 msec) and then adjusted downwards to smaller values as needed. The amount of CPU capacity being used can be measured by using the normal operating system utilities for whatever operating system you are using (e.g. "top" or "System Monitor" for Linux, or the equivalent utility for MS Windows).
The program scan rate is set at system start up and cannot be changed while the system is running. This means that to change the scan rate, you need to stop and restart the system.
The soft logic IO configuration is specified in a configuration file. This file is read when the system starts up. However, the configuration can also be changed while the system is running by reloading the configuration using the system "status" interface. Details of how to do this may be found in the help pages which are part of the status system.
The following shows a complete example.
# Test configuration for soft logic system.
# 17-Jun-2009
# System parameters.
# Set the type of soft logic, the default PLC program name,
# and the target scan rate.
[&system]
type=ck
plcprog=plcprog.txt
scan=50
# Data table values to save to disk, along with
# the minimum update interval.
[&logicsave]
updateinterval=2.0
wordaddr=DD1,DF2,DS10
############################################
# Each section must be given a unique name. The name can be descriptive, but
# must not start with an ampresand ('&').
# Get the push buttons.
[PBs]
addrtype=coil
base=32100
action=read
logictable=X1,X2,X3,X4,X5,X6,X7,X8
# Set the pilot lights.
[PLs]
addrtype=discrete
base=32100
action=write
logictable=Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8
# Get PB4 register.
[PB4]
addrtype=holdingreg
base=32200
action=read
logictable=XD1
# Set PL4 register.
[PL4]
addrtype=inputreg
base=32200
action=write
logictable=YD1
# Tank Readings. These are Tank1 level, Tank2 levell, and Pump Speed (actual).
[Tanks]
addrtype=inputreg
base=32210
action=write
logictable=YS10,YS11,YS12
# Pump command speed.
[PumpCommand]
addrtype=holdingreg
base=32210
action=read
logictable=XS10
#########################################################
# Strip charts.
[StripCharts]
addrtype=inputreg
base=32213
action=write
logictable=YS20,YS21
############################################
# Events.
[Events]
addrtype=coil
base=32300
action=write
logictable=Y20,Y21,Y22,Y23,Y24,Y25,Y26,Y27,Y28
# Alarms.
[Alarms]
addrtype=coil
base=32400
action=write
logictable=Y30,Y31,Y32,Y33,Y34,Y35,Y36,Y37,Y38
############################################
# Test the extended data types.
# 32 bit integer.
[HRInt32Read]
addrtype=holdingreg32
base=32215
action=read
logictable=DD10
[IRInt32Read]
addrtype=inputreg32
base=32215
action=read
logictable=DD11
# Single precision floating point.
[HRFloat32Read]
addrtype=holdingregfloat
base=32217
action=read
logictable=DF10
[IRFloat32Read]
addrtype=inputregfloat
base=32217
action=read
logictable=DF11
# Double precision floating point.
[HRFloat64Read]
addrtype=holdingregdouble
base=32219
action=read
logictable=DF13
[IRFloat64Read]
addrtype=inputregdouble
base=32219
action=read
logictable=DF14
# Strings
[HRStrin8Read]
addrtype=holdingregstr8
base=32223
action=read
logictable=TXT10
strlen=10
[HRStrin8Write]
addrtype=inputregstr8
base=32223
action=write
logictable=TXT50
strlen=10
[Testholdingregstr16]
addrtype=holdingregstr16
base=32233
action=read
logictable=TXT100
strlen=14
[Testinputregstr16]
addrtype=inputregstr16
base=32233
action=write
logictable=TXT150
strlen=14
[Testholdingregstr16]
addrtype=holdingregstr16
base=32233
action=read
logictable=TXT100
strlen=14
[Testinputregstr16]
addrtype=inputregstr16
base=32233
action=write
logictable=TXT150
strlen=14
############################################