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:

  1. Reads the provided Connection and Value inputs and the Variable Name control.

  2. Validates that a variable name, a valid connection, and a value are present.

  3. Attempts to write the provided value into the specified PLC variable via the supplied connection.

  4. Emits Success as 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

  1. Add a PLC connection block such as TwinCAT Connect and configure it.

  2. Feed the connection output into the Connection input of this block.

  3. Provide a value to write using a suitable input block (for example a Number Input or String Input) into the Value input.

  4. Enter the PLC variable name in the Variable Name control.

  5. Run the scenario and check the Success output to confirm the write.

πŸ’‘ Tips and Tricks

  • Use TwinCAT Connect to create and supply the Connection input.

  • Use Number Input, String Input or Logic Input to prepare the Value input 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 Converter before writing to ensure type compatibility.

  • Add a Debug Input or Is None check 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 Success is False: verify the Variable Name is exactly as defined in the PLC (including namespaces/paths).

  • Ensure the provided Connection is 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?