TwinCAT Write
This function block writes a value to a TwinCAT PLC variable using an existing PLC connection. Use it to push numeric, boolean or textual values from your scenario into the PLC and receive a simple success indicator.
π₯ Inputs
Connectionβ PLC connection object (provide from a communication setup block such as TwinCAT Connect).Valueβ The value to be written into the PLC variable (number, text, boolean, or structured value depending on your PLC variable).
π€ Outputs
Successβ Boolean indicating whether the write operation succeeded.
πΉοΈ Controls
Variable Nameβ Enter the exact PLC variable name/address you want to write to (as defined in your TwinCAT project).
βοΈ Running mechanism
When this block runs it:
Reads the provided
ConnectionandValueinputs and theVariable Namecontrol.Validates that a variable name, a valid connection, and a value are present.
Attempts to write the provided value into the specified PLC variable via the supplied connection.
Emits
Successas True when the write completes, otherwise False and logs an error message for troubleshooting.
π― Features
Simple single-variable write operation with a clear single boolean result.
Input-flexible: accepts generic values so it can be used with numeric, textual and boolean data sources.
Error reporting: informs you when connection, variable name or value is missing or when a write fails.
π Usage instructions
Add a PLC connection block such as TwinCAT Connect and configure it.
Feed the connection output into the
Connectioninput of this block.Provide a value to write using a suitable input block (for example a Number Input or String Input) into the
Valueinput.Enter the PLC variable name in the
Variable Namecontrol.Run the scenario and check the
Successoutput to confirm the write.
π‘ Tips and Tricks
Use
TwinCAT Connectto create and supply theConnectioninput.Use
Number Input,String InputorLogic Inputto prepare theValueinput depending on the variable type in the PLC.After writing, verify the result by reading the same variable with
TwinCAT Read.If your value type is unclear, pass the data through
Data Type Converterbefore writing to ensure type compatibility.Add a
Debug InputorIs Nonecheck upstream to detect missing or invalid values and avoid failed writes.Log successful writes or failures using CSV Export or MQTT Publish for audit trails or remote monitoring.
π οΈ Troubleshooting
If
Successis False: verify theVariable Nameis exactly as defined in the PLC (including namespaces/paths).Ensure the provided
Connectionis active and correctly configured (check TwinCAT Connect status).Confirm the value type matches the PLC variable type; convert types upstream if necessary.
Check logs shown by the block for descriptive error messages to guide corrective actions.
Last updated
Was this helpful?