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
Provide a PLC connection to the
Connectioninput. The typical way is to use theTwinCAT Connectblock and connect its output to this block.Enter the target PLC variable into the
Variable Namecontrol.Trigger evaluation (manually or from flow controls). The block will attempt to read the named variable and output
DataandSuccess.Use the
Successoutput 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 Connectto create and manage the PLC connection and feed it intoConnection.Combine with
Rising EdgeorCycle Timerto control read frequency (e.g., read once on start or periodically).Send successful reads to
CSV ExportorData to JSONto log values for later analysis.Use
Debug InputorScopeto inspect values while you build and test your system.To write values back to the PLC, pair this block with
TwinCAT Writeand use logic blocks (for exampleLogic InputorSet - Reset) to control when reads/writes happen.Use
Data Write LocalorData Write Globalto 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 Nameis 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 Inputto capture the raw response and theSuccessoutput to branch error handling.If you need periodic stability, control reads with timing blocks like
Cycle Timerand add simple retry logic using logic blocks.
Last updated
Was this helpful?