For the complete documentation index, see llms.txt. This page is also available as Markdown.

Siemens S7 Write

This function block writes values into a Siemens S7 PLC. It accepts a data input and a client reference, and can perform immediate (synchronous) or scheduled background (asynchronous) writes. An optional value can be provided to be written when the system stops or the block is removed.

πŸ“₯ Inputs

Enable Provide a boolean to allow or inhibit writes. When not provided or True, writes proceed.

Data The value to write to the PLC. Accepts the data type selected in the controls.

[Optional] Data on Stop Optional value that will be written when the block is stopped or removed.

S7 Client The PLC client/connection reference used to perform the write. (Provide using a connection block such as Siemens S7 Connect.)

πŸ“€ Outputs

This function block does not produce outputs.

πŸ•ΉοΈ Controls

DB Number Specify the DB number inside the PLC where the value will be written.

DB Byte Address Specify the byte offset inside the selected DB.

Bit Position For boolean writes, select the bit position inside the targeted byte.

DB Data Type Choose the data type to write (for example: boolean, integer, float, string). The block converts the input value according to this selection.

Connection Type Choose between Sync and Async modes. Sync performs the write immediately and shares a common connection; Async schedules the write to run in the background and uses a dedicated connection for this block.

πŸŽ›οΈ Key Features

  • Support for multiple PLC data types with explicit selection via DB Data Type.

  • Byte and bit addressing for precise placement of boolean or scalar values.

  • Two write modes:

    • Synchronous (immediate) writes for deterministic single-step operations.

    • Asynchronous (background) writes to avoid blocking the main flow and to offload longer write operations.

  • Optional safe-write-on-stop: a value provided to [Optional] Data on Stop is written automatically when the block is stopped or removed.

  • Connection management and reconnection when the client address changes.

  • Clear error and warning messages to help diagnose connectivity or type issues.

βš™οΈ How it runs

  • When Enable is absent or True, the block attempts to write the value provided on Data into the PLC at the configured DB and byte address.

  • If Connection Type is set to Sync, the block uses a shared synchronous connection and performs the write immediately.

  • If Connection Type is set to Async, the block schedules the write to a background worker so the main flow is not blocked; this uses a dedicated connection instance for the block.

  • If a client reference on S7 Client is not connected, the block will try to (re)connect before attempting the write.

  • On stop or removal, the block will try to write the value provided to [Optional] Data on Stop to ensure a defined final state.

πŸ“ Usage Instructions

  1. Provide a PLC client reference to S7 Client (use Siemens S7 Connect to create the connection).

  2. Configure target address using DB Number and DB Byte Address.

  3. If writing booleans, set the Bit Position.

  4. Select the appropriate DB Data Type for the data you will write.

  5. Choose Connection Type:

    • Use Sync when you want immediate writes and share the connection across blocks.

    • Use Async to offload writes to the background and avoid blocking the flow.

  6. Feed the value to write into Data and enable writing with Enable.

  7. Optionally provide a value to [Optional] Data on Stop to be written when stopping or removing the block.

πŸ’‘ Tips and Tricks

  • Use Siemens S7 Connect to provide a reliable client reference to the S7 Client input.

  • Combine with Siemens S7 Read to verify registers before or after writes.

  • Use Logic Input to drive the Enable socket from a simple UI toggle.

  • If you need to prepare or format text/structured data before writing, consider String Input or Data to JSON upstream.

  • Use Data Write Global / Data Write Local or Data Memory to store values you intend to write from multiple places in your flow.

  • For logging or diagnostics, connect a CSV Export or Debug Input to capture or inspect values you are writing.

  • Prefer Sync mode when multiple blocks write to the same DB/byte to avoid write conflicts; choose Async when writes can be handled independently to reduce processing latency.

πŸ› οΈ Troubleshooting

  • Lost connection / Write failures: Check the PLC reachability and client provided to S7 Client. Use Siemens S7 Connect to test the connection separately.

  • Incorrect data values: Ensure the selected DB Data Type matches the actual PLC variable type and adjust DB Byte Address / Bit Position accordingly.

  • Server busy or concurrent writes: If you see warnings about the server being busy, try switching to Sync mode for shared, serialized writes to the same addresses or ensure each writer uses separate addresses.

  • Value not written on stop: Make sure a valid value is provided to [Optional] Data on Stop and the block is allowed to perform finalization (some shutdown scenarios may prevent final writes).

βœ… Safety and Best Practices

  • Double-check DB and byte addresses before writing to live PLCs to avoid unintended changes.

  • Use write-on-stop carefully; ensure the stop sequence allows the block to complete the final write.

  • Prefer dedicated connections (Async) for heavy or frequent write tasks that should not block the main flow; prefer Sync when coordinating writes across multiple blocks.

Last updated