Siemens S7 Write
This function block is used to send values into a Siemens S7 PLC (DB area). It lets you pick the DB number, byte address, data type and optionally a bit position for boolean writes. You can choose immediate (synchronous) writes or background (asynchronous) writes and provide an optional value to be sent when the scenario stops.
π₯ Inputs
Enable Boolean input that enables the block. When False, the block will not send data.
Data Generic input containing the value to write to the PLC (number, boolean, text, depending on the selected data type).
[Optional] Data on Stop Generic input to provide a value that will be written when the block stops or the scenario finishes.
S7 Client Generic input that accepts a PLC connection reference (use with Siemens S7 Connect or a shared client provider).
π€ Outputs
This block does not produce outputs.
πΉοΈ Controls
DB Number DB number in the PLC where data will be written.
DB Byte Address Byte offset inside the DB where the write will start.
Bit Position Bit index inside the target byte (used only for boolean writes).
DB Data Type Dropdown to select the data type to write (examples: Boolean, Int, DInt, Real, String, Time, ...).
Connection Type Dropdown to choose between Async and Sync write modes.
π― Key Features
Background writing option: choose
Asyncto queue writes and run them in the background for better throughput.Immediate writes: choose
Syncto write immediately (recommended when multiple blocks write to the same bytes).Wide data type support: supports numeric types, strings, boolean writes (with bit selection), and time types.
Optional stop-time write: specify a separate value to be written when the block is stopped or removed.
Automatic client reconnection guidance: the block can be paired with a connection provider to manage PLC connections.
βοΈ Running mechanism (user-facing)
Provide a valid
S7 Clientfrom a connection block such asSiemens S7 Connect.Send values into
DatawhileEnableis True to perform writes.If
Connection Typeis set toAsync, writes are queued and executed on a background worker so the rest of the flow continues without waiting.If
Connection Typeis set toSync, writes happen immediately and the block waits until the write finishes. This is safer when multiple writers target the same bytes.If you provide
[Optional] Data on Stop, that value will be written when the block is stopped or removed.
π How to use (simple)
Add a connection provider block like
Siemens S7 Connectand connect its client output toS7 Client.Enter the destination DB number in
DB Numberand the byte offset inDB Byte Address.Select the correct
DB Data Typefor the value you intend to write. If writing a boolean, setBit Position.Provide the value to be written to the
Datainput (useNumber Input,String Inputor other producers).Toggle
Enable(or drive it with a trigger block such asLogic InputorRising Edge) to perform the write.Optionally set
[Optional] Data on Stopif you need a final value to be written when stopping.
π‘ Tips and Tricks
For connection setup, pair with
Siemens S7 Connectso the connection is shared and managed separately.Use
Siemens S7 Readafter this block to verify the written value (read-then-compare).Use
Logic InputorRising Edgeto trigger single-shot writes when an event occurs instead of continuous writes.Use
Number InputorString Inputblocks to feed clean, user-editable values intoData.Choose
Syncwhen multiple blocks may write to overlapping DB addresses to avoid conflicting updates. UseAsyncfor higher throughput when writes target different areas.Combine with
Data Memoryto hold a value and only send when it changes (prevents unnecessary writes).Add a
Debug Inputor connect a logger (CSV ExportorImage Loggerwhere appropriate) to keep a write history for troubleshooting.If you want to publish write events externally, route the same value to
MQTT PublishorREST API - Postblocks after a successful write.
π οΈ Troubleshooting
No connection / write fails: check that a valid
S7 Clientis connected (useSiemens S7 Connect).Wrong data type: ensure the selected
DB Data Typematches the type of theDatayou provide (e.g., do not feed text when a numeric type is selected).Boolean not changing: confirm the correct
Bit Positionis set and that the DB byte address is correct.Conflicting writes: if multiple blocks write to the same byte(s) and results are inconsistent, switch to
Syncor consolidate writes into a single block.Need a guaranteed final write: provide the final value to
[Optional] Data on Stopso it will be written when the block is removed or the scenario stops.
If you need example combinations, try: Number Input β Data and Logic Input β Enable for manual writes, or Siemens S7 Read β verify written values after using this block.
Last updated
Was this helpful?