Collector Siemens S7
  • 05 Apr 2023
  • 6 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Collector Siemens S7

  • Dark
    Light
  • PDF

Article Summary

The purpose of this article is to be a reference for the Siemens S7 collector part of the full Data Collection Module documentation.

Prerequisite

A Starter package (SiteManager + accounts) A Siemens S7 capable device.

Config main

The Config main (array of objects, mandatory) contain the following fields:

FunctionTypeImportanceDescription
ConfigNamestringmandatoryUnique name for this configuration file. Follows the rules for names.
ConfigDescriptionstringoptionaltext describing this configuration.
CheckpointIntervalinteger == 0 or >= 60optionalThe interval with which all data from the internal datasample cache is saved to disk. This more unstable (power) the SiteManager, the more often data should be saved. Saving it often, however will also cost performance and wear on the hard-disk/flash. A value of 0 means, never checkpoint, otherwise it means interval in seconds between saves. If not specified the value 15 * 60 (15 minutes) is used.
AlarmsSavedinteger >= 4optionalThe number of alarms saved in the store-and-forward database. If this values is not specified, it will default to 32.
WaitForNTPbooleanoptionalSynchronize DCM data collection with NTP time. If this parameter is true, all DCM collectors will not begin collecting data until NTP is enabled and configured and NTP has synchronized date/time. If not specified, the value is true.

Since the JSON format itself doesn't define a comment notation, DCM accepts a fieldname comment with any type of value in any section.

Example of comment

"Comment": "Example of a comment for use in any section.": 


The Collectors (array of objects, mandatory) list elements contains the following fields:

FunctionTypeImportanceDescription
CollectorNamestringmandatoryUnique name (within this configuration file) of a device to collect data from. (This is the name used in the agent configuration). Follows the normal rules for names.
CollectorDescriptionstringoptionalDescription of this collector. For your use, no system function.)
CollectorIPAddrstringoptionalDefault IP address (or DNS name) for the device to be polled. The agent Target IP address will take precedence over this.
CollectorPortnointeger > 0 and < 65535optionalDefault port number for the device to be polled. The agent Target Port number will take precedence over this. If neither CollectorPortno , nor agent Target Port Number, is specified, the appropriate port will be used, depending on the Protocol parameter value.
AliasstringoptionalThis is the CollectorName of another collector, from which all the parameters (except CollectorName, CollectorDescription, CollectorIPAddr and CollectorPortno ) are copied from. An alias cannot refer to another alias.
Protocolstring-enummandatoryThe protocol used to collect data. Currently 3 possible values exists: "OPC-UA/TCP", "Modbus/TCP", "Http/GET" and "Simulator".
ConnectRetryMininteger > 0mandatoryMinimum number of seconds before trying to reestablish a connection to the device being sampled. An exponential backoff algorithm is used to retry connection establishment, starting after ConnectRetryMin and increasing to ConnectRetryMax.
ConnectRetryMaxinteger > 0mandatoryMaximum number of seconds before trying to reestablish a connection to the device being sampled.
S7AccessobjectoptionalCollection of parameters needed to access a given S7/TCP server.
SamplePointsarray of objectsmandatoryList of samples to be collected, possibly aggregated and stored in the Store'n'Forward database.

S7Access


The S7Access objects contain the following elements:

FunctionTypeImportanceDescription
S7Modelstring-enummandatoryThe PLC model/type. The supported values are "S7-200", "S7-300" and "S7-1200".
S7RackInteger >= 0 and <= 7optionalThe Rack number for this unit. If not present, the value 0 is used.
S7SlotInteger >= 0 and <= 31optionalThe Slot number for this unit. If not present, the value 1 is used.
S7ConnectionTypestring-enumoptionalThe connection type used by this collector. The supported values are "PG", "OP" and "APP". If not present, the value "OP" is used.
S7Timeoutinteger > 0,optionalThe default timeout (in millisecond) for all S7 requests. If not present, the value 3000 is used.
S7LocalTSAPInteger >= 0 and <= 65536optionalThe local protocol TSAP value needed to access the S7 server. If not present, 256 is used.


Samplepoint items

The Samplepoints objects contain the following elements:

FunctionTypeImportanceDescription
SampleNamestringmandatoryName of this sampled value (sometimes called a tagname). Follows the normal rules for names.
SampleDescriptionstringoptionalIs a text description of this sample value.
SampleUnitstringoptionalIs a description of the unit of measurement for this sample.
SampleGroupstringoptionalDesignates (in some datasrvs) that all samplepoints in that group should be handled (displayed) together. The DCM system itself places no meaning on this group affiliation.
SamplesSavedinteger > 0optionalis the number of values collected that is saved in the Store'n'Forward database even after the values have been sent to all dataservers. When 0 is specified, the value can be used in aggregators. but nothing is sent via dataservers to cloud system. If left unspecified, values are only saved in the Store'n'Forward database until they have been delivered to all dataservers.
OnlySaveOnChangedbooloptionalControl if new sample values should only be saved to the Store’n’Forward database if the values have changed since last sample. If not set, it is false.
SampleDataTypestring-enummandatoryThe type of data collected. The possible values are: "bool" (1 bit), "sbyte" (8 bit signed), "byte" (8 bit unsigned), "int16" (16 bit signed), "uint16" (16 bit unsigned), "int32" (32 signed), "uint32" (32 bit unsigned), "int64" (64 bit signed), "uint64" (64 bit unsigned), "float" (32 bit), "double" (64 bit), "string" (variable text up to 24575 bytes. Includes terminating NUL), "data" (variable variable data up to 24575 bytes).
SampleMaxVDataSize
integer > 0 and <= 24575
optional
is the max size of variable data enforced for this sample. This is only relevant for SampleDataType "string" or "data". If not specified, the value is 1024.
SampleLowerLimitinteger/doubleoptionalThe lower limit for the collected data. If the collected data value is less than SampleLowerLimit, it is evaluated in accordance to SampleLimitDiscard and SampleLimitAlarm.
SampleUpperLimitinteger/doubleoptionalThe upper limit for the collected data. If the collected data value is more than SampleUpperLimit,  it is evaluated in accordance to SampleLimitDiscard and SampleLimitAlarm.
SampleLimitDiscardboolmaybe-optionalControls if a sample limit violation results in the sample value being discarded. Mandatory if either SampleLowerLimit or SampleUpperLimit is present.
SampleLimitAlarmboolmaybe-optionalControls if a sample limit violation generates an alarm. Mandatory if either SampleLowerLimit or SampleUpperLimit is present.
S7VarObjectmaybe-optionalDescription of how to address a specific datavalue from an S7 server. Mandatory if the protocol type is "S7/TCP".


S7Var

The S7Var object contains the following fields:

FunctionTypeImportanceDescription
S7PLCVarStringmandatory
This is the absolute address of an S7 PLC variable using the S7 international syntax.
S7SampleIntervalinteger >= 0mandatoryThe number of seconds between each sample of this S7 variable. If the interval is 0, only eventdriven polling is used.
S7TimeoutInteger > 0optionalTimeout (in millisecs) for reading this S7 variable. If not present, the S7Timeout value from S7Access is used.
The S7 PLC variable absolute address syntax is as follows

AREA[DBNO][TYPE]BYTEOFFSET[.BITPOS].

BYTEOFFSET is the offset within the AREA, where this value starts. It is a decimal number between 0 and 16777215.
If the TYPE is "X" (or ""), an additional BITPOS is used to designate which bit within the BYTEOFFSET is addressed. BITPOS is a digit between 0 and 7.
Here AREA can one of the following strings:
• "I" or "E" for Digital input.
• "Q" or "A" for Digital output.
• "AI" or "AE" for Analog input.
• "AQ" or "AA" for Analog output.
• "M" for internal memory.
• "SM" for special memory. (only for S7-200).
• "DB" for data block.
• "DI" for indirect data block.
• "L" for local variables (corresponds to DB2 area).
• "V" for global variables (corresponds to DB1 area).
• "C" or "Z" for counters (for S7-200 this is the IEC Counter type).
• "T" for timers (for S7-200 this is the IEC Timer type).
while DBNO is only used if AREA is "DB" or "DI".
TYPE can be one of the following strings:
• "B" for byte (unsigned 8bit value)
• "C" for char (signed 8bit value)
• "W" for word (unsigned 16bit value)
• "WI" or "WINT" for word (signed 16bit value)
• "D" for doubleword (unsigned 32bit value)
• "DI" or "DINT" for double word (signed 32bit value)
• "R" for real (IEEE floating point 32bit value)
• "X" or "" for bit (1bit value)


Siemens DatatypeSecomea SampleDataTypeGeneral definitionS7Var definition
bytebyteunsigned 8bit
B
charsbytesigned 8bit
C
worduint16unsigned 16bit
W
wordint16signed 16bitWI or WINT
doubleworduint32unsigned 32bitD
double wordint32signed 32bitDI or DINT
realfloatIEEE floating point 32bit
R
bitbool1bitX


{
     "CollectorDescription": "S71500 example",
     "CollectorName": "s7-1500",
     "ConnectRetryMax": 240,
     "ConnectRetryMin": 2,
     "Protocol": "S7/TCP",
     "S7Access": {
         "S7Model": "S7-1200",
         "S7Rack": 0,
         "S7Slot": 1
     },
     "SamplePoints": [
         {
             "SampleName": "DB1500Switch1",
             "SampleDescription": "DB1500DState0 S7",
             "SampleDataType": "bool",
             "SampleUnit": "On/Off",
             "SamplesSaved": 1000,
             "S7Var": {
                   "S7PLCVar": "DB1500X0.0",
                   "S7SampleInterval": 1
             }
         }
     ]
}

See complete Siemens S7 examples here:


Was this article helpful?