TwinCAT Read

This function block reads a variable from a TwinCAT PLC and outputs the retrieved value along with a success indicator. It is intended for simple PLC data retrieval in automation scenarios.

πŸ“₯ Inputs (sockets)

Connection β€” Generic PLC connection object (provide using a connect block such as TwinCAT Connect).

πŸ“€ Outputs (sockets)

Data β€” Retrieved variable value from the PLC.

Success β€” Boolean flag indicating whether the read operation succeeded.

πŸ•ΉοΈ Controls

Variable Name β€” Text field where you enter the PLC variable name to read. This value must match the variable identifier defined in the PLC.

🎯 Features

  • Simple PLC read operation with clear success feedback.

  • Designed to accept a connection from a separate connection block, keeping connection management separated from reads.

  • Validates key inputs and reports clear error messages when connection or variable name is missing.

πŸ“ How to use

  1. Provide a PLC connection to the Connection input. The typical way is to use the TwinCAT Connect block and connect its output to this block.

  2. Enter the target PLC variable into the Variable Name control.

  3. Trigger evaluation (manually or from flow controls). The block will attempt to read the named variable and output Data and Success.

  4. Use the Success output to gate downstream logic (e.g., logging or storage) so you only act on valid reads.

πŸ“Š Runtime behavior

When evaluated, the block checks that a valid Connection is present and that Variable Name is not empty. If either is missing it reports an error and outputs a failed Success. On a valid configuration it performs a read and outputs the variable value on Data and a boolean on Success.

πŸ’‘ Tips and Tricks

  • Use TwinCAT Connect to create and manage the PLC connection and feed it into Connection.

  • Combine with Rising Edge or Cycle Timer to control read frequency (e.g., read once on start or periodically).

  • Send successful reads to CSV Export or Data to JSON to log values for later analysis.

  • Use Debug Input or Scope to inspect values while you build and test your system.

  • To write values back to the PLC, pair this block with TwinCAT Write and use logic blocks (for example Logic Input or Set - Reset) to control when reads/writes happen.

  • Use Data Write Local or Data Write Global to store values for other parts of your scenario.

πŸ› οΈ Troubleshooting

  • If you see "Connection is not established" errors, verify the connection block (for example TwinCAT Connect) is configured and connected.

  • If Variable Name is empty, the block will not attempt a read β€” enter a valid PLC variable identifier.

  • If a read fails despite valid inputs, check PLC access rights, variable name spelling, and network/PLC status. Use Debug Input to capture the raw response and the Success output to branch error handling.

  • If you need periodic stability, control reads with timing blocks like Cycle Timer and add simple retry logic using logic blocks.

Last updated

Was this helpful?