OPCServer

SUMMARY

This document provides information about OPC environment.

CONTENTS

  1. Registering
  2. Settings for an OPC Client
  3. Structure of OPC-Items
  4. Synonyms
  5. Examples
  6. Output to Window
  7. Log-File
  8. IP-Addresses
  9. SoftPLC7.ini

Registering

Before a SoftPLC7 OPC Server can be brought into operation it must be registered. This is done by the command “SoftPLC7OPCServer.exe –regserver”. Deregistration is done via the parameter ‘unregserver’

Settings for an OPC Client

In order to provide actual data for the SoftPLC OPC Server the section [HLL-Functions] of the SoftPLC7.ini file must be amended.

Structure of OPC-Items

The exact Syntax for an OPC-Item is:

SoftPLC7:[<Instance Number>]<Area><Type><Offset>,<Number>
            

SoftPLC7:
The identifier in front of the colon defines the OPC-Item as SoftPLC-Item; the identifier is not case-sensitive.

[<Instance Number>]
The square brackets do not define an optional parameter, but has to be there. The therein specified <Instance Number> is the instance number of the SoftPLC7. 99 Instances distributed on several PCs may be defined for a project. The Instances must be numbered consecutively (01…99) and be able to communicate among each other via LAN. The OPC Server itself may reside on any of the PCs.

<Area><Type><Offset>,<Number>
Definition of the operands within that instance, divided into: Area, Type, Offset and Number.

The following areas and types are valid for an OPC-Item:

Area Description Remark
DB<nr> Data block with number Is the DB with number<nr> nonexistent than the item is BAD
M Flag Independent of the CPU-Type always 16 KB are addressable
I Input Independent of the length of the defined process image 16 KB are addressable
O Output Independent of the length of the defined process image 16 KB are addressable
PI Peripheral Input Independent of the really allocated Peripheral bytes always 16KB are addressable
PO Peripheral Output Independent of the really allocated Peripheral bytes always 16KB are addressable

Type Description Offset Number
B
BYTE
CHAR
Byte (unsigned) <Byte index of first Byte> <Number of Bytes>
W
WORD
INT
Word (signed) <Byte index of first Word> <Number of Words>
D
DWORD
DINT
DWord (signed) <Byte index of first DWord> <Number of DWords>
REAL 32 Bit Floating Point <Byte index of first Floating Point digit> <Number of Floating Point digits>
x Bit <Byte index of the Bit>.<Bit Number (0...7)> 1

Note:
1. That by <Offset> and <number> addressed element must be located within the range.
2. The VARIANT-Types for signed 8 bit, unsigned 16 bits and unsigned 32 bits are not fully supported by MFC, therefore in that context other adequate data types for CHAR, W(ORD) and D(WORD) are used.
3. For bit operands only number=1 is allowed.

Synonyms

Alternatively synonyms may be used to form the prefix 'SoftPLC7:[nn]' of the OPC item name.
Synonyms are defined in section [OPC-Items] of the SoftPLC7OPCServer.ini file.
The file always resides in the same folder as the SoftPLC7OPCServer.exe application.

The format for a synonym definition reads as follows:
WantedText=SubstitutedText

If, for example,

an OPC-Item should be defined:
'S7:[Control3]MB0,1' instead of 'SoftPLC7:[15]MB0,1'
    
    the following 2 entries are necessary
    
[OPC-Items]
S7=SoftPLC7
Control3=15    
            

Note:
The original naming is still valid

Examples

OPC Item Description
SoftPLC7:[01]DB60,B10,11 From Instance 01 11 bytes starting at Index10 are read out of DB60
SoftPLC7:[01]DB60,REAL20,4 From Instance 01 4 floating digits starting at Index20 are read out of DB60
SoftPLC7:[01]DB10,X20.5,1 From Instance 01 bit 5 from byte 20 is read out of DB10
SoftPLC7:[02]EX20.5,1 From Instance 02 the input bit 5 from byte 20.5 is read
SoftPLC7:[03]PEDWORD20,2 From Instance 03 the DWORDs 20 and24 are read out of the Peripheral input.

Output to Window

On a new project it is helpful to get messages on specified actions. Hence the environment variable SOFTPLC7_OPCSERVER_DEBUG must be set to TRUE. The message ‘Trying to create <OPC-Item> … OK’ is issued on creating a new OPC-Item. The annex 'found' implies that the item already exists. A write access returns the message ‘Write request on <OPC-Item>: Value=<value>’.


After the test phase the messages should be suppressed to increase performance. Hence the environment variable SOFTPLC7_OPCSERVER_DEBUG must be set to FALSE, or deleted at all.

Log-File

In addition the outputs may be written to the file ‘SoftPlc7OPCServer.err’. Although the environment variable SOFTPLC7_DEBUG_FILE has to be set to maximum length for the log file. Value=0 implements that no log file is written. A length of 10 MBs is recommended.

IP-Addresses

Normally SoftPLC7OPCServer, SoftPLC7 and OPC-Clients reside in a LAN whereas the applications may run on several PCs. To keep up UDP-Communication the following entries must exist:

in the SoftPlc7.ini file
See section [OPC]


in the SoftPlc7OPCServer.ini file
[Settings]
RemoteAddr=127.0.0.1
LocalAddr=<IP-Address>

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
				

Entry for the SoftPlc7OPC Server:
[HLL-Function]
PY0,0=SoftPlc7OPCServerDll,DoDataExchangeUDP
			        

Section [OPC]

Entry Type Description / Example Default
UpdateTimeFactor integer
Defines the interval for CPU update related to a time slice. The value 5 at a given time slice of 200 ms leads to a refresh rate of 1 sec.
1
LocalAddr string
Defines the IP address used for calling up the function “blind”
0.0.0.0
RemoteAddr string
Defines the target IP address the UDP packages for the SoftPLC7 OPC server are send to.
IP address 255.255.255.255 stands for BROADCAST and may be used within a LAN.
IP address 127.0.0.1 stands for LOCAL HOST and has to be used if the system is not part of a LAN
Example
RemoteAddr=127.0.0.1
				
Note:
To keep sockets from allocating the whole address area when using the function ’bind’ a special local IP-Address can be selected.