Skip to Content
On this page

S7 master

The S7 master plugin connects to Siemens S7 PLCs over TCP and reads or writes S7 areas.

Compatible devices and models

Device series / model examplesConnection requirements
S7-200, S7-200 SMARTS7-200 requires an interface such as CP243-1 that supports S7 Ethernet access. Use the corresponding Ethernet interface and S200Smart type for S7-200 SMART. Use the PPI plugin for PPI serial connections.
S7-300, S7-400Connect through the CPU’s built-in Ethernet interface or a suitable CP module and configure the actual rack and CPU slot.
S7-1200, S7-1500The target CPU and firmware must allow the S7 address access used by this driver. Allow PUT/GET as required by the PLC project, and use non-optimized DBs for absolute DB addressing.

Configure the PLC before connecting

For S7-1200/1500 in TIA Portal, open the CPU’s Properties → General → Protection & Security → Connection mechanisms and enable the PUT/GET access required by the approved project. Check the CPU firmware’s access-control requirements as well. Use a global DB with Optimized block access disabled for absolute addresses, compile, download through the site’s normal procedure, and confirm the actual online value and byte offset.

Siemens TIA Portal example: remote PUT/GET access

Siemens TIA Portal example: non-optimized DB access

These figures are from the Siemens PUT/GET application guide , V3.0, pages 13 and 31. Menus and permission combinations depend on the installed TIA and CPU firmware versions. No PUT/GET program call is needed merely to expose an existing DB to this client.

For S7-200, configure a suitable S7 Ethernet CP in Micro/WIN; its RS-485 programming port is a PPI interface. For SMART, download and verify the CPU Ethernet address in Micro/WIN SMART. For S7-300/400, obtain the CPU rack and slot from the actual hardware configuration, rather than using the CP slot.

Open the plugin

Open Development Configuration → Collection Configuration, create a device, and select S7 master.

Create the channel and device through Collection Configuration. This page covers S7-specific properties, address formats, special methods, and debug actions.

Read one DB point first

  1. Confirm a readable DB and known Int16 value with the PLC engineer.

  2. Create a TCP client channel at the PLC’s actual IP:102.

    S7 TCP client channel; the screenshot uses the local simulator port 15102

  3. Create an S7 master device, select the actual CPU family, and enter its rack and slot. Keep Local TSAP at its default unless the connection resource requires another value.

    S7 device and associated channel

    S7 CPU family, rack, slot and plugin properties

    Scroll down to scheduling and data format. Use ABCD for the PLC’s usual big-endian INT/REAL layout and keep string byte reversal off. Adjust timeout, retries and write priority using the parameter descriptions below.

    Lower S7 properties: timeout, scheduling, string byte reversal and ABCD

  4. Start with a 1000 ms execution interval and add an enabled Int16 variable at the confirmed address, for example DB1.0 for byte offset 0 of DB1.

    S7 scalar Int16 variable at DB1.0

  5. Compare its value, quality, and advancing collection time with the PLC engineering tool before importing more points.

Use the address Field editor to select the area, DB number, byte offset and optional bit offset. Leave optional converter overrides unset to inherit defaults; an explicit false or zero is a different setting. Confirm the address back into the variable and then save the variable itself.

S7 address editor and optional converter overrides

For example, %DB1.DBW0=1234, %DB1.DBD2=12.5 (REAL) and %DB1.DBX6.3=true map to DB1.0 / Int16, DB1.2 / Float and DB1.6.3 / Boolean. Their byte ranges do not overlap. Offset is measured in bytes, while the final .3 selects a bit from 0 to 7. Use array length 0 for a collection scalar and read quantity 1 for one direct debug read.

Reproduce the example with a simulator

Create an S7Slave endpoint in the built-in simulator, initialize one fixed value, then configure the master to read it.

  1. In the built-in protocol simulator, create an S7Slave / TcpService endpoint at an unused local port, for example 127.0.0.1:15102. Set rack 0, slot 0, local TSAP 0x0100, and allocate DB1.
  2. Define a fixed UInt16 point at DB1.DBW0 with value 1234 and start it.
  3. Connect an S7 master using S1200, rack/slot 0, Local TSAP 0, and an Int16 collection point at DB1.0. Compare the source, advancing collection timestamp and direct read result.

S7 simulator source at DB1.DBW0

S7 collection result: online device and value 1234

S7 direct read: DB1.0, Int16, quantity 1, result 1234

A Called TSAP does not match server configuration message requires matching the simulator’s local TSAP to the master’s called TSAP. The example uses 0x0100, rather than the simulator’s slot-1 0x0101 configuration. Increasing retries does not fix a TSAP mismatch.

The DB must already exist. For S7-1200/1500, have the PLC engineer confirm the required remote-access permission and non-optimized DB access for absolute addressing. Check the actual CPU and TIA project settings before changing protection.

Supported channel and data types

Channel typeCheck before configuration
TCP clientConfirm the PLC IP address, port, and network reachability from the gateway.

Supported data types: Boolean, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Float, Double, String, and Decimal.

Plugin properties

S7 master supports only the TcpClient channel. Set the remote address and connection timeout in the associated channel; retry count, protocol timeout, duty cycle, write priority, and data format are device plugin properties. The string byte/word reversal switch is currently not applied by the S7 collection connection. See Collection Configuration for common fields.

SettingDefault / description
PLC typeDefault S200. Select the PLC family that matches the CPU.
RackDefault 0. Rack number of the PLC CPU.
SlotDefault 0. Slot number of the PLC CPU module.
Local TSAPDefault 0. Local TSAP connection identifier. Set it to match the PLC connection resource when required.
Maximum pack sizeDefault 200. The current S7 read planner does not use this value directly as each request’s span cap. Inspect actual requests and the negotiated PDU after changing it.
Read/write timeoutDefault 3000 ms. Response budget, independent of the collection interval.
Pre-frame delayDefault 0 ms before sending; adds to complete scan time.
Data formatMatch the PLC byte layout. Compare a known multibyte source before choosing the order.
String byte reversalNot applied by the current S7 collection connection. Check the PLC string layout instead.
Failure retriesDefault 3; do not use retries to repair an invalid DB address or permission.
Read/write duty cycle and write priorityShared scheduling settings; see Collection strategy.

PLC type options are S200, S200Smart, S300, S400, S1200, and S1500. Rack, Slot, and Local TSAP are used when establishing the S7 session; restart or re-enable the device after changing them.

Address rules

Use the S7 area prefix followed by the byte address. Add .bit for a bit address.

FormatArea / example
TxxxxxTimer, for example T100 or T100.1.
CxxxxxCounter, for example C100 or C100.1.
AIxxxxxAnalog input, for example AI100 or AI100.1.
AQxxxxxAnalog output, for example AQ100 or AQ100.1.
IxxxxxInput area, for example I100 or I100.1.
QxxxxxOutput area, for example Q100 or Q100.1.
MxxxxxMarker area, for example M100 or M100.1.
DB...Data block, for example DB100.1 or DB100.1.1.

Prefix a wide-string address with W=true;, for example W=true;DB1.0; without the prefix the normal string decoder is used. In a DB address, the first number is the DB block and the next number is the byte offset; a final .0–.7 is a bit index. Thus DB100.1 is byte 1 of DB100, while DB100.1.1 is bit 1 of that byte. V addresses are equivalent to DB1.

Confirm the area, byte offset, bit offset, data type, and array length with the PLC point list before importing variables.

Address editor fields

The field editor and manual address describe the same point. Confirm the generated address, then save the parent variable dialog; validating the address does not read the PLC.

FieldRule and effect
AreaI, Q, M, DB, T, C, AI, AQ, or V. V is DB1. Choose an area and access mode supported by the selected CPU; the editor does not verify CPU permissions.
DB numberFor DB only, default 1, range 0–65535. A number accepted by the editor does not establish that the block exists or is accessible.
Offset0–2097151. Ordinary memory uses byte offsets; timer/counter addresses use the protocol’s item index. The complete value or array must remain inside the source area.
BitLeave unset for a whole numeric value. Boolean uses .0–.7, for example DB1.6.3; the suffix selects a bit, not a fractional offset.
WSTRING overrideSet only for the S7 wide-string structure; produces W=true. Encoding and the available source range must still match.
Data order overrideABCD/BADC/CDAB/DCBA for this point; unset inherits the device setting. Compare a known PLC INT/REAL before overriding.
Encoding and string byte lengthencoding= selects the source character encoding and len= describes byte capacity. Neither changes the numeric array element count or corrects a wrong start address.
BCD overrideUse only when the source bytes have that BCD layout. Use the dedicated date method for DATE_AND_TIME rather than treating it as an ordinary integer.
Variable string length overridevsl=true uses the matching length header; false selects fixed-capacity decoding. Unset and explicitly false remain distinct. The address must point to the correct string structure.

Arrays, strings, and connection verification

Collection array length 0 means scalar; debug read count 1 means one element. Three Int16 elements starting at DB1.600 occupy six bytes. Float, Double, and Decimal occupy 4, 8, and 16 bytes respectively. Decimal uses the gateway converter layout, not PLC REAL/LREAL; use Float/Double for those PLC types.

For fixed ASCII, use DB1.600;len=4;encoding=ascii to read bytes 41 42 31 32 as AB12. len is bytes: UTF-8 text may require several bytes per character. For S7 STRING use the matching capacity/current-length header and vsl=true;encoding=ascii; check S200Smart separately. For a big-endian UTF-16 WSTRING, use an address such as W=true;DB1.600;encoding=bigendianunicode and verify the four-byte header plus content range. W=true selects the wide-string structure; it does not correct the character encoding. Debug and collection header validation differ, so a small-capacity WSTRING can fail direct debug while collection succeeds.

PLC types are S200, S200Smart, S300, S400, S1200, and S1500. Rack, slot, and TSAP affect the new session. LocalTSAP=0 selects defaults; a nonzero decimal value such as 258 does not establish that Calling TSAP bytes are 01 02. Inspect the handshake. The form has no independent PduLength or ConnectionType setting. Negotiated PDU and configured pack length are separate; the current read planner does not directly use the latter as each request’s span cap. The string byte/word reversal switch is not applied by the current S7 collection connection.

Date methods use an outer address argument array such as ["DB1.700"]. DATE is days since 1990-01-01; big-endian 00 01 means 1990-01-02. DATE_AND_TIME is an eight-byte BCD layout. Clear the special method and restore ordinary address/type/length when returning to a regular point.

Special methods

MethodUseParameters
ReadWriteDateAsyncReads or writes an S7 date value.address, optional value
ReadWriteDateTimeAsyncReads or writes an S7 date-time value.address, optional value

For a read, leave the value empty. For a write, use a safe address and a value approved by the site procedure.

Device debug

Open Development Configuration → Collection Configuration, select the S7 master device, open Protocol Debug at the top of the workspace.

Read and write

Read one confirmed address first. Before writing, check PLC state, address, data type, and field safety conditions.

Messages

S7 master: Messages

Use the message view to inspect connection, handshake, request, response, and parsing errors.

Functions

FunctionPurpose
Read and writeRead a confirmed point and write only to an approved test point.
MessagesInspect connection/receive summaries and errors. Use a source communication monitor or packet capture when raw S7 bytes are required.

Verify the configuration

  1. Confirm the PLC type, rack, slot, and Local TSAP.
  2. Read one known input, marker, output, timer, counter, or DB address.
  3. Compare the value and data type with the PLC engineering tool.
  4. Test a special date method only on a safe point.
  5. Import the remaining point list after the single-point check passes.

Troubleshooting

SymptomCheck
Cannot connectPLC IP, port, firewall, PLC type, rack, slot, and Local TSAP.
Handshake failsPLC family, rack/slot, Local TSAP, and the PLC connection resource configuration.
Address read failsArea prefix, byte/bit offset, DB number, data type, and array length.
Value is incorrectData type, byte order, address offset, and the PLC engineering tool’s display format.
Special method failsMethod name, address format, parameter value, write permission, and PLC operating state.
Wide string is garbled or truncatedConfirm W=true;, the variable data type, array length, and the PLC string layout.