This TwinCAT 3 sample provides a compact introduction to TF6310 TCP/IP communication in PLC code. It contains both TCP client and TCP server function blocks and demonstrates local loopback communication.
| Item | Description |
|---|---|
TF6310_GettingStarted.sln |
Solution file for the Getting Started sample. |
- TwinCAT 3 XAE engineering installed on Windows
- TwinCAT 3 XAR runtime (local or remote)
- TF6310 TCP/IP installed (local or remote)
- Open
TF6310_GettingStarted.slnin TwinCAT XAE. - Select your target system.
- Build the solution and activate the configuration.
- Download the PLC project and set the runtime to Run.
- Observe client/server communication variables in
MAIN.
- Demonstrates basic TCP client and TCP server usage in one PLC project
- Shows loopback communication using configurable local ports
- Provides a minimal baseline for extending TCP/IP logic in TwinCAT
- The sample runs one client (
fbTcpClient1) and one echo server (fbTcpEchoServer1) in the sameMAINprogram and connects them via loopback (sServer1Host := '127.0.0.1',nServer1Port := 12000). - On each send cycle, the client payload is written to
sClient1SendData. IfbAutogenerateData = TRUE, the value is updated cyclically toTestString No.<counter>usingnCntandtClient1CycleTime. - The client sends
sClient1SendDatato the server and receives the server response intosClient1ReceivedData. - The server receives the incoming client telegram internally (server FB internal receive buffer), copies it to its send buffer, and exposes that send buffer at
MAINlevel throughsServerData(sSendData => sServerData). This is the echoed value sent back to the client. - For online observation, monitor these communication variables in
MAIN:sClient1SendData(client transmit value)sServerData(server echo/transmit value)sClient1ReceivedData(client receive value)bClient1ConnectedandbServer1Connected(connection state)
Should you have any questions regarding this sample, please contact your local Beckhoff support team. Contact information can be found on the official Beckhoff website at https://www.beckhoff.com/contact/.