Siemens S7 Read

This function block reads values from a Siemens S7 PLC data block (DB). Use it to fetch numeric values, booleans, strings or other PLC data types and bring them into your scenario for monitoring, logging or decision logic.

πŸ“₯ Inputs

Enable (Boolean) β€” When FALSE the block will skip reading and produce no output. Use this to control when reads occur. S7 Client (Generic) β€” PLC connection object provided by a connection block. Connect the client created by a PLC connection block here.

πŸ“€ Outputs

Data (Generic) β€” The value read from the PLC. The data type depends on the selection in the controls (number, list of booleans, text, etc.).

πŸ•ΉοΈ Controls

DB Number - Database (DB) number to read from on the PLC. DB Byte Address - Starting byte offset inside the selected DB. DB Data Type - Dropdown to select the expected PLC data type (examples: Boolean, Int, Real, String). Connection Type - Select Sync or Async. Sync keeps a shared connection mode suitable when multiple blocks use the same PLC bytes; Async gives the block its own connection behavior.

βš™οΈ How it works

  • When active, the block uses the connected S7 Client to read bytes from the specified DB Number and DB Byte Address.

  • The block interprets the raw PLC bytes according to the selected DB Data Type and returns a Python-friendly value via the Data output. For example, selecting Boolean may return a list of bit states, while String returns the decoded text.

  • The Enable input allows you to stop reads without removing the configuration.

  • The Connection Type influences sharing behavior: choose Sync when you want consistent, shared access across multiple blocks; choose Async for independent or isolated access.

✨ Features

  • Simple UI to specify DB number, byte address and expected PLC data type.

  • Supports many PLC types (booleans, signed/unsigned integers, reals, strings, time types, words/dwords, etc.).

  • Configurable connection mode to match your deployment (shared vs independent).

  • Error reporting in the UI when reads fail or if the provided parameters are out of range.

πŸ“ Usage Instructions

  1. Provide a valid PLC connection to the S7 Client input (from a PLC connection block).

  2. Enable the block by providing TRUE to the Enable input or leaving it enabled.

  3. Set the target DB Number and DB Byte Address.

  4. Choose the appropriate DB Data Type for the value you want to read.

  5. Read values will appear on the Data output; connect downstream blocks to consume or log them.

πŸ’‘ Tips and Tricks

  • Trigger reads on demand: combine with Logic Input or a single-shot trigger like Rising Edge to perform reads only when needed (reduces bus load).

  • Log and store values: send the Data output to CSV Export or SQL-DB Operations to build historical logs.

  • Publish readings to external systems: connect Data to MQTT Publish to stream PLC values to a cloud or broker.

  • Visualize trends: feed numeric outputs into Scope to monitor live values over time.

  • Keep recent values available: use Data Memory to hold the last-read value and release updates only when desired.

  • Handle missing values: use Is None and Replace None blocks to create safe fallback behavior if a read fails.

  • Compose JSON payloads: feed values into Data to JSON before publishing or saving to simplify downstream parsing.

  • Use Connection Type wisely: Sync is convenient when several blocks must read/write the same bytes; choose Async when you need isolated access or independent retries.

(hint) If you need a UI block that displays current values for operators, combine with display/output blocks like Show Image (for image-like data) or Led Output and simple text widgets for numeric indicators.

πŸ› οΈ Troubleshooting

  • No output appears: confirm the Enable input is TRUE and that a valid S7 Client is connected.

  • Connection errors or timeouts: verify PLC network settings, check the connection block providing the S7 Client, and try switching Connection Type modes.

  • Unexpected data format: ensure DB Number, DB Byte Address and DB Data Type match the PLC program layout. For strings, confirm the DB layout uses the same length/encoding.

  • High bus load: reduce read frequency, use triggered reads (Rising Edge) or share a connection with Sync mode where appropriate.

Last updated