SIEMENS S7/SINUMERIK Plugin

The Siemens S7 and SINUMERIK Plugin are used to read data from S7 PLCs (S7 300, S7 400, S7 1200, S7 1500) and SIEMENS SINUMERIK 840D controls.

Configuration location:

[Edge Main Folder]/configs/configurations/InputPlugins/SiemensPlc

These configs are only used for the Edge instance Luna.Console, executed directly from the [Edge Main Folder]. Click the "Service Application" tab above to check the location for Edge services.

Use the default DataMappings.xml for most use cases.

SiemensPlcSettings.xml

The SiemensPlcSettings.xml defines which data to read.

Example configuration

<?xml version="1.0" encoding="utf-8" ?>
<SiemensPlcConfig>
  <!--Specify configuration file for connection to PLC-->
  <Operationsettings>
	  <!-- path to the Accon AGLink configuration file with connection information of PLC (to generate this config file use the AGLink40_Config.exe) -->
    <AGLinkConfigFilePath>$(LunaAppDataPath)configurations/InputPlugins/SiemensPlc</AGLinkConfigFilePath>
	  <!-- device number which refers to the corresponding Accon AGLINK configuration file -->
    <DeviceNr>0</DeviceNr>
	  <!--SF Edge requires two separate connections to the PLC and the NCK part of the PLC.
		 The following settings should be the same as defined in the config file created by AGLink40_Config.exe -->
    <PLCNr>1</PLCNr>
    <NCKPLCNr>0</NCKPLCNr>
	  <!-- RackNr of the PLC -->
    <RackNr>0</RackNr>
	  <!-- internal Slot-Number of the PLC Module (usually Slot 2) -->
    <PLCSlotNr>2</PLCSlotNr>
	  <!-- internal Slot-Number of the NCK Module (usually Slot 3; in special cases Slot 4) -->
    <NCKSlotNr>3</NCKSlotNr>
  </Operationsettings>

  
  <!-- Definition of variables to read given their NCDDE/OPC conform item name -->
  <NCDDEDataBlocks>
	  <!-- Definition of a bundle of variables which should be read at the same time -->
    <NCDDEDataBlock>
	    <!-- polling interval for reading data (in milliseconds) -->
      <PollingIntervalMilliseconds>500</PollingIntervalMilliseconds>
	    <!-- Define if only changing values should be transmitted -->
      <OnlySendChanges>true</OnlySendChanges>
	    <!-- List of variables to read (it is not allowed to mix PLC and NCK data variables) -->
      <NCDDEDataList>
		    <!-- Definition of one variable -->
        <NCDDEData>
		      <!-- NCDDE/OPC conform item name of the variable to read -->
          <ItemName>/Nck/Configuration/chanAssignment[1]</ItemName>
		      <!-- Sets if variable of data type DWORD has to be interpreted as integer or float (has no influence on other data types) -->
		      <IsReal>true</IsReal>
		      <!-- Sets the threshold a variable has to change to be considered as "changed" -->
		      <DeltaToIgnore>0.57</DeltaToIgnore>
		      <!-- Filter condition for the given variable -->			
		      <Filter>
			    <!-- Relational operator to use for the condition (valid: Greater, Less, GreaterOrEqual, LessOrEqual, Equal, NotEqual) -->
			      <Comparer>Greater</Comparer>
			      <!-- Value to compare with -->
			      <Value>0</Value>
		      </Filter>
		      <!-- List of mathematical operations applied on the given variable -->
		      <!-- Valid operations on numeric variables: Add, Subtract, Multiply, Divide, Power -->
		      <!-- Valid operation on boolean variables: Invert -->
		      <MathOperations>
            <MathOperation>
              <Operation>Multiply</Operation>
              <Value>3.5</Value>
            </MathOperation>
			      <MathOperation>
              <Operation>Add</Operation>
              <Value>20</Value>
            </MathOperation>
          </MathOperations>
        </NCDDEData>
        <NCDDEData>
          <ItemName>DB100.DBD4</ItemName>
        </NCDDEData>
      </NCDDEDataList>
    </NCDDEDataBlock>
	<!-- Add several more instances of NCDDEDataBlock here... -->
  </NCDDEDataBlocks>

  <!-- Definition of variables to read from the PLC -->
  <PLCDataBlocks>
	  <!-- Definition of a bundle of variables which should be read at the same time -->
    <PLCDataBlock>
      <!-- polling interval for reading data (in milliseconds) -->
      <PollingIntervalMilliseconds>500</PollingIntervalMilliseconds>
	    <!-- Define if only changing values should be transmitted -->
      <OnlySendChanges>true</OnlySendChanges>
	    <!-- List of PLC data to read at once -->
      <PLCDataList>
		    <!-- Definition of one variable -->
        <PLCData>
		      <!-- Name of the variable -->
          <Name>PLC_DB10.DBX104.7</Name>
		      <!-- PLC OpArea to read from (valid: AREA_IN, AREA_OUT, AREA_FLAG, AREA_DATA, AREA_TIMER, AREA_COUNTER, AREA_SFLAG_200, AREA_VAR_200, AREA_TIMER_200, AREA_COUNTER_200, AREA_PERIPHERIE, AREA_SFLAG_S5, AREA_PLCINFO_200) -->
          <OpArea>AREA_DATA</OpArea>
		      <!-- PLC OpType of the data to read (valid: TYP_BIT, TYP_BYTE, TYP_WORD, TYP_DWORD, TYP_COUNTER, TYP_TIMER, TYP_COUNTER_200, TYP_TIMER_200, TYP_HS_COUNTER_200) -->
          <OpType>TYP_BIT</OpType>
		      <!-- PLC DBNr to read from -->
          <DBNr>10</DBNr>
		      <!-- Offset for the read operation -->
          <Offset>104</Offset>
		      <!-- BitNr of the data to read from -->
          <BitNr>7</BitNr>
		      <!-- Sets if variable of data type DWORD has to be interpreted as integer or float (has no influence on other data types) -->
		      <IsReal>false</IsReal>
		      <!-- Sets the threshold a variable has to change to be considered as "changed" 
		          This threshold as well as the RelativeDeltaToIgnorePercent threshold both need
		         to be exceeded to mark this variable as "changed".-->
		      <DeltaToIgnore>0.57</DeltaToIgnore>
    	              <!-- Sets the relative threshold a variable has to change to be considered as "changed" 
                          This threshold as well as the DeltaToIgnore threshold both need
		         to be exceeded to mark this variable as "changed".-->
                      <RelativeDeltaToIgnorePercent>21</RelativeDeltaToIgnorePercent>
		      <!-- Filter condition for the given variable -->			
		      <Filter>
			      <!-- Relational operator to use for the condition (valid: Greater, Less, GreaterOrEqual, LessOrEqual, Equal, NotEqual) -->
			      <Comparer>Greater</Comparer>
			      <!-- Value to compare with -->
			      <Value>0</Value>
		      </Filter>
        </PLCData>
		  <!-- Add several more instances of PLCData here... -->
      </PLCDataList> 
    </PLCDataBlock>
	<!-- Add several more instances of PLCDataBlock here... -->
  </PLCDataBlocks>

  <!-- Definition of variables to read from the NCK part of the PLC -->
  <NCKDataBlocks>
    <!-- Definition of a bundle of variables which should be read at the same time -->
    <NCKDataBlock>
	    <!-- polling interval for reading data (in milliseconds) -->
      <PollingIntervalMilliseconds>500</PollingIntervalMilliseconds>
	    <!-- Define if only changing values should be transmitted -->
      <OnlySendChanges>true</OnlySendChanges>
      <NCKDataList>
        <NCKData>
		      <!-- Name of the variable -->
          <Name>NCK_Test_RParam</Name>
		      <!-- DDEVarType of the data to read (valid: eNCK_Unknown, eNCK_LE_Uint8, eNCK_LE_Uint16, eNCK_LE_Int32, eNCK_LE_Float32, eNCK_LE_Float64, eNCK_LE_String, eNCK_LE_Bit, eNCK_LE_Int8, eNCK_LE_Int16, eNCK_LE_Uint32, eNCK_BE_Uint8, eNCK_BE_Uint16, eNCK_BE_Int32, eNCK_BE_Float32, eNCK_BE_Float64, eNCK_BE_String, eNCK_BE_Bit, eNCK_BE_Int8, eNCK_BE_Int16, eNCK_BE_Uint32) -->
		      <DDEVarType>eNCK_LE_Float64</DDEVarType>
		      <!-- NCK data area to read from (valid: eNCK_AreaNCK, eNCK_AreaBag, eNCK_AreaChannel, eNCK_AreaAxis, eNCK_AreaTool, eNCK_AreaFeedDrive, eNCK_AreaMainDrive, eNCK_AreaMMC)-->
          <Area>eNCK_AreaChannel</Area>
          <!-- NCK data block to read from (valid: eNCK_BlockY, eNCK_BlockYNCFL, eNCK_BlockFU, eNCK_BlockFA, eNCK_BlockTO, eNCK_BlockRP, eNCK_BlockSE, eNCK_BlockSGUD, eNCK_BlockLUD, eNCK_BlockTC, eNCK_BlockM, eNCK_Block0x1B, eNCK_BlockWAL, eNCK_BlockTISO, eNCK_BlockDIAG, eNCK_BlockCC, eNCK_BlockFE, eNCK_BlockTD, eNCK_BlockTS, eNCK_BlockTG, eNCK_BlockTU, eNCK_BlockTUE, eNCK_BlockTV, eNCK_BlockTM, eNCK_BlockTP, eNCK_BlockTPM, eNCK_BlockTT, eNCK_BlockTMV, eNCK_BlockTMC, eNCK_BlockMGUD, eNCK_BlockUGUD, eNCK_BlockGUD4, eNCK_BlockGUD5, eNCK_BlockGUD6, eNCK_BlockGUD7, eNCK_BlockGUD8, eNCK_BlockGUD9, eNCK_BlockPA, eNCK_BlockGD1, eNCK_BlockNIB, eNCK_BlockETP, eNCK_BlockETPD, eNCK_BlockSYNACT, eNCK_BlockDIAGN, eNCK_BlockVSYN, eNCK_BlockTUS, eNCK_BlockTUM, eNCK_BlockTUP, eNCK_BlockTF, eNCK_BlockFB, eNCK_BlockSSP2, eNCK_BlockPUD, eNCK_BlockTOS, eNCK_BlockTOST, eNCK_BlockTOE, eNCK_BlockTOET, eNCK_BlockAD, eNCK_BlockTOT, eNCK_BlockAEV, eNCK_BlockYFAFL, eNCK_BlockFS, eNCK_BlockSD, eNCK_BlockTAD, eNCK_BlockTAO, eNCK_BlockTAS, eNCK_BlockTAM, eNCK_BlockTAP, eNCK_BlockMEM, eNCK_BlockSALAC, eNCK_BlockAUXFU, eNCK_BlockTDC, eNCK_BlockCP, eNCK_BlockMTV, eNCK_BlockMTD, eNCK_BlockMTP, eNCK_BlockMTUD, eNCK_BlockMTUP, eNCK_BlockMTAD, eNCK_BlockMTAP, eNCK_BlockCCS, eBCK_BlockSDME, eNCK_BlockSPARPI, eNCK_BlockSEGA, eNCK_BlockSEMA, eNCK_BlockSSP, eNCK_BlockSGA, eNCK_BlockSMA, eNCK_BlockSALAL, eNCK_BlockSALAP, eNCK_BlockSALA, eNCK_BlockSSYNAC, eNCK_BlockSPARPF, eNCK_BlockSPARPP, eNCK_BlockSNCF, eNCK_BlockSPARP, eNCK_BlockSINF, eNCK_BlockS, eNCK_Block0x80, eNCK_Block0x81, eNCK_Block0x82, eNCK_Block0x83, eNCK_Block0x84, eNCK_Block0x85, eNCK_BlockO) -->		  <Block>eNCK_BlockRP</Block>
          <!-- NCK data unit to read from -->
		      <Unit>1</Unit>
          <!-- The row to read from -->
		      <Row>22</Row>
          <!-- The column to read from -->
		      <Column>1</Column>
          <!-- Buffer length required to read the defined data -->
		      <BufferLength>8</BufferLength>
		      <!-- Sets the threshold a variable has to change to be considered as "changed" -->
		      <DeltaToIgnore>2</DeltaToIgnore>
        </NCKData>
		  <!-- Add several more instances of NCKData here... -->
      </NCKDataList>
    </NCKDataBlock>
	  <!-- Add several more instances of NCKDataBlock here... -->
  </NCKDataBlocks>

  <!-- Define which PLC Alarms should be read -->
  <PLCAlarmBlocks>
    <PLCAlarmBlock>
	    <!-- polling interval for reading data (in milliseconds) -->
      <PollingIntervalMilliseconds>2000</PollingIntervalMilliseconds>
      <!-- PLCAlarmType: Symb, SFC or SFB (each type should only occur once) -->
      <PLCAlarmType>SFC</PLCAlarmType>
    </PLCAlarmBlock>
	  <!-- Add more instances of PLCAlarmBlock here... -->
  </PLCAlarmBlocks>

  <!-- Define if NCK Alarms should be read (otherwise delete this sections) -->
  <NCKAlarmBlock>
	  <!-- polling interval for reading data (in milliseconds) -->
    <PollingIntervalMilliseconds>1000</PollingIntervalMilliseconds>
	  <!-- Define if additional "Alarm Filltext" information should also be sent -->
    <ExtendedInfo>true</ExtendedInfo>
  </NCKAlarmBlock>

  <!--Specify file for message mapping-->
  <Mappings>
    <FilePath>$(LunaAppDataPath)configurations/InputPlugins/SiemensPlc</FilePath>
    <FileName>DataMappings.xml</FileName>
  </Mappings>

  <!--Specify file for logging-->
  <Logger>
    <FilePath>$(LunaAppDataPath)Logs</FilePath>
    <FileName>SiemensPlc.log</FileName>
    <!--LogLevel: Debug,Information,Warning,Error,Critical,None-->
    <LogLevel>Trace</LogLevel>
  </Logger>
</SiemensPlcConfig>

Setting

Description

AGLinkConfigFilePath

File path to the PLC connection definition file (see the section below)

DeviceNr

device number which refers to the corresponding PLC connection definition file. 0 for most use cases.

PLCNr/NCKPLCNr

SF Edge requires two separate connections to the PLC and the NCK part of the PLC. The settings should be the same as defined in the PLC connection definition file; 1 for PLCNr and 0 for NCKPLCNr for most use cases

RackNr

Rack number of the controller

PLCSlotNr

Slot number of the PLC controller

NCKSlotNr

Slot number of the NCK controller (only required if connecting to a SINUMERIK

Reading data blocks by their Item name

Datablocks in SIEMENS controllers (PLC and NCK) are uniquely identified by it's item name (eg. DB100.DBD4 for PLCs and /Nck/Configuration/chanAssignment[1] to access OPC conform datablocks of a SINUMERIK control)

Refer to lines 22 to 54 in the above example configuration.

You may add as many NCDDEDataBlock-elements as required. Each NCDDEDataBlock may contain as many NCDDEData elements as required. All NCDDEData elements inside an NCDDEDataBlock are sampled at the same time. Place NCDDEData elements that need different sampling intervals in different NCDDEDataBlocks!

Configuration options for each NCDDEDataBlock:

Setting

Description

PollingIntervalMilliseconds

Defines the polling interval for all data points in this NCDDEDataBlock.

OnlySendChanges

If set to true, data points that did not change compared to the previous polling cycle are thrown away. The rate of change is defined with DeltaToIgnore of each NCDDEData element.

Configuration options for each NCDDEData element inside an NCDDEDataBlock:

Setting

Description

ItemName

Name of the item to read. Eg. DB100.DBD4 or /Nck/Configuration/chanAssignment[1]

IsReal

Defaults to false; If set to true and the data point to read is of type DWORD, this data point is interpreted as REAL (a floating-point number). Is ignored for other types than DWORD

DeltaToIgnore

Sets the threshold a variable has to change to be considered as "changed". Use in combination with OnlySendChanges (see above)

RelativeDeltaToIgnorePercent

Sets the relative threshold a variable has to change to be considered as "changed". A variable is ONLY marked as "changed", when this threshold as well as the DeltaToIgnore threshold are exceeded.

Example: The current value is 5, DeltaToIgnore is 1 and RelativeDeltaToIgnorePercent is 10 (=10%). This means, the value needs to change for AT LEAST more than 1 (as DeltaToIgnore is higher than RelativeDeltaToIgnorePercent). If, for example, the current value is 50, then it needs to change more than 5, as the RelativeDeltaToIgnorePercent is higher. This combination of both features allows to set a minimum absolut value for change detection and use the relative value beyond this minimum change. This provides best resource utilization.

Use in combination with OnlySendChanges (see above)

Filter: Comparer

Relational operator to use for the condition (valid: Greater, Less, GreaterOrEqual, LessOrEqual, Equal, NotEqual)

Filter: Value

Filter value to compare the data with. If the filter value combined with filter comparer evaluates to false, the read data for this specific data point are thrown away

MathOperations

Applies all the defined mathematical operations to the variable in the given order.

MathOperations: Operation

Defines the mathematical operations which should be applied to the variable.

  • Valid operations for numerical variables are: Add, Subtract, Multiply, Divide, Power

  • Valid operations for boolean variables are: Invert

Operations that are defined for a variable it is not valid for (e.g. Add for a boolean variable) are ignored.

MathOperations: Value

All mathematical operations also require a Value that is used as an operand. This can be a decimal number.

Consider that Filters are always applied after the MathOperations! Otherwise, this could lead to results you are not expecting.

Applying MathOperations to variables of any integer datatype can cause them to be a decimal number. But this is no problem because when inserting the data in our database the value will be converted to an integer or long (depending on the definition of the attribute in the event schema, see Event Schema Management).

Using absolute address as ItemName

If you are using absolute addresses as ItemNames (like XXX) in the NCDDEDataBlock definitions. The name has to adhere to the following schema:

DBn.DBYz.i

n ... Address of the data block

Y ... Data type of the variable

z ... Start address/index of the variable within this data block

i ... Index of bit (only used for BOOL and BIT)

The notation of all possible data types are summarized in the following table:

Data type

Absolute address

Example

Description

BOOL, BIT

DBn.DBXx.y

DB13.DBX2.0

The first bit of byte 2 in data block address 13

BYTE, CHAR, SINT, USINT

DBn.DBBy

DB123.DBB1

data byte 1 in data block 123

WORD, INT, UINT

DBn.DBWy

DB42.DBW6

data word 6 in data block 42

DWORD, DINT, UDINT, REAL, TIME

DBn.DBDy

DB25.DBD2

data double word 2 in data block 25

Reading blocks by their memory location definition

Alternatively to reading data by its name, it is possible to use the exact memory location definition of a data point for reading specification.

It is recommended to use the reading by item name for most use cases.

Refer to the comments in the above sample configuration (lines 69 to 143) for how to configure blocks by their memory location.

Reading PLC alarms

PLC alarms are read by defining a PLCAlarmBlocks definition (line 145 to 154).

Start times of alarms are created at the PLC, Stop times are created by SF Edge as soon as a previously active alarm is terminated.

Only one PLCAlarmBlock for each PLCAlarmType must be inside the PLCAlarmBlocks definition.

Setting

Configuration

PollingIntervalMilliseconds

Interval in milliseconds defining how often to check for changes in alarms.

PLCAlarmType

Type of Alarm to read from PLC. Valid values: Symb, SFC or SFB.

Each type needs to be wrapped in an individual PLCAlarmBlock.

Reading NCK alarms

NCK alarms are read by defining an NCKAlarmBlock definition (lines 156 to 162).

Start times of alarms are created at the NCK, Stop times are created by SF Edge as soon as a previously active alarm is terminated.

Setting

Configuration

PollingIntervalMilliseconds

Interval in milliseconds defining how often to check for changes in alarms.

ExtendedInfo

Define if additional "Alarm Filltext" information should also be sent. For each available FillText, a datapoint with key InfoValueX is created - with X being a number from 1 to 15.

Connection State

This plugin automatically creates a "Connection_State" message, when the state of the connection to the PLC changes. The following message is created, when the connection to the PLC is established:

{"IngressKey":"SIEMENS","Timestamp":1659871724930,"Connection_State":"Connected"}

The following messages is created, when the connection to the PLC is dropped (eg. due to the PLC restarting, or due to networking issues)

{"IngressKey":"SIEMENS","Timestamp":1659871928597,"Connection_State":"Disconnected"}

You might use the data point "Connection_State" in your "EventDefinition.xml" for mapping this state message to our outgoing message stream. For example, to rename the data point to "my_state" and send it to the MQTT-Plugin, add the following line to your "Datas" section in your EventDefinition.xml

<Data name="my_state">$(Connection_State)</Data>

Last updated