Siemens S7 Write
This function block writes data to a Siemens S7 PLC (Data Block). Use it to send numbers, booleans, strings and other supported types into a PLC address directly from your scenario.
π₯ Inputs
Enable Provide TRUE to allow writing. If FALSE or empty no write will occur.
Data The value to write to the PLC. Accepts numeric, boolean, text or complex data depending on the selected DB Data Type.
[Optional] Data on Stop If provided, this value will be written once when the scenario or block is stopped/removed.
S7 Client Provide a connection reference from a connection block (for example Siemens S7 Connect) so the block can reach the PLC.
π€ Outputs
This function block does not produce outputs.
πΉοΈ Controls
DB Number Data Block number to write into on the PLC.
DB Byte Address Starting byte address inside the chosen DB where the value will be written.
Bit Position Use this only for boolean writes to select which bit inside the target byte should be set.
DB Data Type Choose the data type to write (examples: Boolean, Int, Real, String, Time, etc.). The choice controls how the input value is encoded on the PLC side.
Connection Type Choose Async or Sync. Async schedules the write to a background worker; Sync performs the write immediately.
π― Features
Write a wide range of PLC data types including numerical types, booleans, and strings.
Optional "write on stop" value that will be pushed to the PLC when the block or scenario is stopped.
Two connection modes: synchronous immediate write and asynchronous background write to avoid blocking the main flow.
Automatic reconnection support when the provided client address changes (useful when reorganizing connections).
Simple UI controls for DB, byte address and bit position β no coding required.
βοΈ Running Mechanism
When
Enableis TRUE and a validS7 Clientis provided, the block attempts to write theDatato the selected DB and byte address using the chosenDB Data Type.If
Connection Typeis set toAsync, the write is scheduled to run in a background worker so the main scenario can continue without delay.If
Connection Typeis set toSync, the block performs the write as part of the current execution step.If a value is provided in
[Optional] Data on Stop, that value will be written automatically when the block is stopped or removed.The block logs informative messages on success, warnings when the PLC/client is busy, and errors when writes fail or parameters are invalid.
π Usage Instructions
Add a connection block such as
Siemens S7 Connectand configure the PLC address.Feed that connection into the
S7 Clientinput of this block.Set the
DB Number,DB Byte Address, and, if writing a boolean, theBit Position.Select the proper
DB Data Typefor the value you will write.Choose
Connection Type:Use
Syncfor immediate writes or when few writes are performed.Use
Asyncto offload frequent or slow writes to a background worker.
Provide a value to the
Datainput (for manual input you can use blocks likeNumber InputorString Input).Enable the block by providing TRUE to
Enableto perform the write.Optionally provide a value to
[Optional] Data on Stopto be written when the block is stopped.
π‘ Tips and Tricks
Use
Siemens S7 Connecttogether with this block to manage the PLC connection and provide theS7 Clientinput.After writing, verify values with
Siemens S7 Readto confirm the expected DB contents.For manual triggers, combine with
Logic InputorNumber Inputto control when writes occur.When writing textual values, feed text from
String Inputso encoding matches expectations.If you need to store values for later use or coordinate multiple blocks, consider combining with
Data Write Local/Data Read LocalorData Write Global/Data Read Global.Use
Debug Inputto log or inspect values before sending them to the PLC.Prefer
Syncmode when multiple blocks must write to the same exact bytes β it reduces race conditions. UseAsyncfor higher throughput when writes are independent.
π οΈ Troubleshooting
Connection errors or "cannot write" messages:
Confirm the
S7 Clientinput is connected and the connection block is configured with the correct PLC address and active.Try re-establishing the connection from the connection block.
Wrong values seen on PLC:
Verify
DB Number,DB Byte AddressandBit Positionare correct for the target variable.Ensure the selected
DB Data Typematches the PLC variable type (e.g., writing a float with an integer type will produce incorrect values).
String writes truncated or corrupted:
Check the PLC side expects a length byte or fixed-size buffer. Limit string length accordingly.
Writes are too slow or block the scenario:
Switch
Connection TypetoAsyncso writes occur in the background.
Multiple writers to same address cause conflicts:
Use
Syncmode for blocks writing to the same DB/bytes, or centralize writes using a single dedicated writer block.
If problems persist, re-check address mapping on the PLC and validate with a read operation (for example using Siemens S7 Read) before relying on subsequent writes.
Last updated