Siemens S7: Read Node

The Siemens S7: Read Node allows you to read one or more values from a PLC that supports the Siemens S7 protocol.

Siemens S7 Read Node

Node Properties

There are three main parts of the configuration for this node.

Connection Config

Siemens S7 Read Node Connection

Connection Config contains five fields:

  • Host Template: (Required) A string template for the IP address at which the S7 PLC resides.
  • Port Template: (Required) A string template or integer for the HTTP port. Defaults to “102”.
  • Timeout Template: (Optional) A string template or integer for the number of milliseconds to wait before a timeout will occur. Defaults to “30000”.
  • Rack Template: (Required) A string template or integer for the PLC Rack number. Defaults to “0”.
  • Slot Template: (Required) A string template or integer for the PLC Slot number. Defaults to “0”.

Read Instructions

Siemens S7 Read Node Instructions

Read Instructions can be specified in one of two ways. At least one is required, but both can’t be specified at the same time.

  • Array of Template Strings: For each Read Instruction, fill out the following input configuration fields, all of which can utilize templates. You must define at least one instruction:

    • Database Template: (Required) A string template or integer for which database to read. This should resolve to an integer between “0” and “65535” inclusive.
    • Offset Template: (Required) A string template or integer for the offset at which to read within the database. This should resolve to an integer between “0” and “2147483646” inclusive.
    • Data Type Template: (Required) This field is a dropdown with a list of valid data types as options. This field can also accept a template string, but it must resolve to a valid data type.
    • Read multiple values (array): When checked, this field will expose the Number of Items Template field indicating you wish to receive the result in the form of an array.
    • Number of Items Template: (Required when Read multiple values is checked) A string template or integer for the length of the array you wish to read.
    • Result Key: (Required) The key at which to store the result of this read operation. This key will exist on the Result Path defined below the instructions. This can resolve to any string except errors, since that key is reserved for any errors that occur during reads.
  • Payload Path: Enter a payload path that resolves to an array of Read Instructions to be run on this node. The following are the object properties that each object in the array should contain for successful attempts:

    • db: (Required) An integer for which database to read. The integer must be between “0” and “65535” inclusive.
    • offset: (Required) An integer for the offset at which to read within the database. The integer must be between “0” and “2147483646” inclusive.
    • dataType: (Required) A string which must be a valid data type.
    • arrayLength: (Optional) An integer representing the length of the array to read, if you wish to read an array. If not provided, the node reads one value.
    • key: (Required) The key at which to store the result of this read operation. This key will exist on the Result Path defined below the instructions. This can resolve to any string except errors, since that key is reserved for any errors that occur during reads.

The following is an example of an array that you could pass in:

[
  {
    "db": 12,
    "offset": 10,
    "dataType": "DINT",
    "key": "doubleInt"
  },
  {
    "db": 12,
    "offset": 20,
    "dataType": "BOOL",
    "arrayLength": 10,
    "key": "boolArray"
  }
]

Result Path

Siemens S7 Read Node Result

The results of each read instruction are placed in an object at the Result Path (a payload path) at each instruction’s Result Key. If “Read multiple values (array)” is checked, the value will be returned as an array; otherwise, the value will be returned as a string, number, or boolean depending on the data type.

It is important that each key is named uniquely so the node does not overwrite another read result.

If the key is not present, the read failed, and there is an array of errors at the Result Path under “errors”. For this reason, this node restricts Result Keys from resolving to the path “errors”. If an individual read fails, an error object will be placed into the array at the key “errors”. A single read failing does not necessarily mean all reads will fail. If a connection is unable to be made to the S7 PLC, or if the request is too large, only one error will be returned for the entire operation.

Node Example

The following is an example of a successful read, where an instruction’s Result Keys are boolArray and doubleInt and the Result Path is working.result:

{
  "working": {
    "result": {
      "boolArray": [false, false, true],
      "doubleInt": 787
    }
  }
}

Node Errors

The following is an example of a failure to read, where a Result Key should have been boolArray, and the Result Path is working.result:

{
  "working": {
    "result": {
      "errors": [
        {
          "key": 'boolArray',
          "type": "S7_READ_ERROR",
          "message": "Failed to read key boolArray. ***Something useful to help you fix the issue.***"
        }
      ]
    }
  }
}

Was this page helpful?


Still looking for help? You can also search the Losant Forums or submit your question there.