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 Stopis 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
Enableis absent or True, the block attempts to write the value provided onDatainto the PLC at the configured DB and byte address.If
Connection Typeis set toSync, the block uses a shared synchronous connection and performs the write immediately.If
Connection Typeis set toAsync, 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 Clientis 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 Stopto ensure a defined final state.
π Usage Instructions
Provide a PLC client reference to
S7 Client(useSiemens S7 Connectto create the connection).Configure target address using
DB NumberandDB Byte Address.If writing booleans, set the
Bit Position.Select the appropriate
DB Data Typefor the data you will write.Choose
Connection Type:Use
Syncwhen you want immediate writes and share the connection across blocks.Use
Asyncto offload writes to the background and avoid blocking the flow.
Feed the value to write into
Dataand enable writing withEnable.Optionally provide a value to
[Optional] Data on Stopto be written when stopping or removing the block.
π‘ Tips and Tricks
Use
Siemens S7 Connectto provide a reliable client reference to theS7 Clientinput.Combine with
Siemens S7 Readto verify registers before or after writes.Use
Logic Inputto drive theEnablesocket from a simple UI toggle.If you need to prepare or format text/structured data before writing, consider
String InputorData to JSONupstream.Use
Data Write Global/Data Write LocalorData Memoryto store values you intend to write from multiple places in your flow.For logging or diagnostics, connect a
CSV ExportorDebug Inputto capture or inspect values you are writing.Prefer
Syncmode when multiple blocks write to the same DB/byte to avoid write conflicts; chooseAsyncwhen writes can be handled independently to reduce processing latency.
π οΈ Troubleshooting
Lost connection / Write failures: Check the PLC reachability and client provided to
S7 Client. UseSiemens S7 Connectto test the connection separately.Incorrect data values: Ensure the selected
DB Data Typematches the actual PLC variable type and adjustDB Byte Address/Bit Positionaccordingly.Server busy or concurrent writes: If you see warnings about the server being busy, try switching to
Syncmode 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 Stopand 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; preferSyncwhen coordinating writes across multiple blocks.
Last updated