SoftPLC7Sync.dll-Plugin

SUMMARY

The SoftPlc7Sync.dll-Plugin synchronizes all SoftPLC7-Instances in a network via a Token that is passed on cyclic.

CONTENTS

  1. Introduction
  2. Commands
  3. Configuration
  4. Data exchange via SHM (Shared Memory)
  5. SoftPLC7.ini

Introduction

Binding the SoftPLC7 Sync.dll-Plugin to SoftPLC7 enables a control application to synchronies several SoftPLC7 instances in a network. The synchronization is done by means of tokens which are passed on cyclic. That ensures only one SoftPLC7 is working at a time. If a SoftPLC7 gets the token, all OB cycles are carried out and the token is passed on to the next SoftPLC7. Any SoftPLC7 not having the token are in a wait state. As soon as the token comes around to the control application a command may be send to any S7-Instance to be carried out on the SoftPLC7 prior the next OB-cycle. Communication is done via a shared memory area with fixed structures for command parameters and user data.

Commands

Command Description CPU must in ...
CMD_STOP Stops the CPU RUN, UNFREEZE
CMD_START Warm start (OB100). Initial DBs loaded, not remanent Flags, counters and timers are set back. STOP, UNFREEZE
CMD_RESUME Resume start (OB101). DBs, Memory blocks, Counters and timers are kept unchanged. STOP, UNFREEZE
CMD_COLDSTART Cold start (OB102). Initial DBs loaded any Flags, counters and timers are set back. STOP, UNFREEZE
CMD_FREEZE Program execution is halted, including timer and IEC-timer Doesn’t matter
CMD_UNFREEZE Program execution continues, timers and IEC-timers are corrected, status continues with the state before FREEZE. Doesn’t matter
CMD_LOADPROGRAM The CPU is set back completely; the actual S7-program is loaded. STOP, UNFREEZE
CMD_SAVEPERSISTENT All variable data are saved in the persistent folder. STOP, UNFREEZE
CMD_WRITESNAPSHOT A complete image of all variable data is written to the user area of the shared memory. FREEZE
CMD_RESTORESNAPSHOT The CPU is set back completely except for the program DBs. The snapshot is restored. FREEZE

Configuration

The passing on of the token is realized by a named semaphore, its name is defined in the SoftPLC7.ini file, section [IPC-SYNC]; see also [Plugin-Functions].

Data exchange via SHM (Shared Memory)

In addition to the synchronized communication via SHM it is possible to define 2 DB-Areas, one to be used as receive buffer, the other as send buffer. The settings are made in the SoftPLC7.ini file.

INI-FILES

SoftPLC7.ini

Section [HLL-Functions]

Entry Type Description / Example Default
(FB |FC |SFB |SFC )<num> string
Defines the DLL-Function that replaces the Program-Module with the following syntax: <dll, function>
Example
FC13=MyDll, MyFunction
				

[HLL-Function]
PY0,0=S7Sync,DoDBEExchangeSHM
			        
The entry in section [HLL-Functions] causes that the function 'DoDBExchangeSHM' is called up inbetween any 2 OB1-cycles.
On the first time only the Shared-Memory-Areas are set up.
From the second time on, data for receiving are transferred from the shared memory to the DB with the number DBNumIn (resp. PI) and data from the DB with the number DBNumOut (resp. PO)are written to the shared memory for sending.
A second SoftPLC7 using the same SHM-Name may receive data written that way or provide data to be read by the first SoftPLC7.
Also a linking of several SoftPlc7 is imaginable.
If not only DBs, but also the PI-Area is to be exchanged, it must be taken care that in this area the PI and I are synchronized by the SoftPLC7.

The following entry in the SoftPlc.ini file changes:

[HLL-Functions]
"PY<Offset>,<Length>=S7Sync,DoDBExchangeSHM"

<Offset> and <Length> define the PI-Area.
If only the PO has to be handled no change is necessary.

The communication is not synchronized: If after an OB1-Cycle the Shared Memory is still be written to, it is not waited, but tried to read after the next OB1-Cycle.

Section [Plugin-Functions]

Entry Type Description / Example Default
Func<n> string
Activates Plugin-Functions of the SoftPLC7.
Example
Func1=S7Sync,S7SyncControl
				
Note:
This function is called up by the same fixed cycle that the OBs are synchronized with. It waits for the token, hands over the control to the S7-threads and on cycle end it passes on the token.

Section [DBExchangeSHM]

Entry Type Description / Example Default
DBNumIn integer
DB number of receiving DB. 0=peripheral input PI
0
DBNumOut integer
DB number of sending DB. 0=peripheral output PO
0
LengthIn integer
Length of receive buffer
0
LengthOut integer
Length of send buffer
0
OffsetIn integer
Offset within the receiving DB (resp. PI) for buffer start
0
OffsetOut integer
Offset within the sending DB (resp. PO) for buffer start
0
OffsetOutHandshake integer
Offset within the sending DB (resp. PO) for a handshake-byte. The SoftPLC7 only writes data if the result of anding the handshake-byte with the mask is zero. If no value, or a value smaller than 0 is inputted, writing is continued.
-1
OffsetOutHandshakeMask integer
Mask to be anded with the handshake-byte
255
SHMNameIn string
Name of the shared memory area for the receive buffer
-1
SHMNameOut string
Name of the shared memory area for the send buffer
255