What is Host Link? How a PC talks to a KEYENCE KV series PLC
Host Link is the communication function that lets a PC or other external device read and write the devices of a KEYENCE KV series PLC. This article covers port 8501, the ASCII commands, TCP vs UDP and the available commands, based on the KEYENCE manual.
Updated
Host Link (上位リンク) is the communication function that lets a PC, touch panel or other external device access a KEYENCE KV series PLC. You connect over Ethernet and send a command written as text in a fixed format; the PLC returns or rewrites the value of a device.
The PLC (an EtherNet/IP unit or the CPU unit’s built-in port) is the server and the PC is the client. You do not need to write any ladder program for communication on the PLC side.
Commands are ASCII strings
Every Host Link command and response is an ASCII string. To read the value of DM100, for example, you send the string RD DM100 followed by CR (0x0D).
RD Command read dataDM100 Device type + numberCR Terminator 0x0DThe PLC returns the value as text and ends it with CR LF.
01234 Value read .U (5 digits)CR LF Terminator 0x0D 0x0AA command may end with either CR or CR LF. LF is ignored, and anything after it is treated as the next command. Responses always end with CR LF.
Communication settings
The main specifications in the manual are:
| Item | Value |
|---|---|
| Protocol | TCP/IP and UDP/IP (can be used at the same time) |
| Port | 8501 by default (set separately for TCP and UDP) |
| Connections | TCP: 15 shared with the MC protocol; UDP: 1 |
| Data code | ASCII |
| Receive timeout | 10 s by default |
| TCP keep-alive | 600 s by default (0 disables it) |
8501 is the default and can be changed within 1–65535. Other ports have their own roles: 8500 is used by KV STUDIO, 8502 by VT (touch panels) and 5000 by the MC protocol.
TCP and UDP
With TCP, the PLC starts listening when it is powered on. Once connected, every command you send gets a response. When the client closes the connection, the PLC closes its side automatically and starts listening again.
UDP does not establish a connection. You send a command to the PLC’s IP address and port, and the response comes back. Only one peer can communicate over UDP at a time.
Available commands
Host Link commands are two or three letters.
| Function | Command |
|---|---|
| Read / continuous read | RD / RDS |
| Write / continuous write | WR / WRS |
| Write set value / continuous write set value | WS / WSS |
| Force set / reset | ST / RS |
| Continuous force set / reset | STS / RSS |
| Register monitor / read monitor | MBS, MWS / MBR, MWR |
| Change mode (PROGRAM / RUN) | M0 / M1 |
| Check operating mode | ?M |
| Query model | ?K |
| Check error number / clear error | ?E / ER |
| Set clock | WRT |
| Read comment | RDC |
| Switch bank | BE |
| Read / write expansion unit buffer memory | URD / UWR |
The ones you will use most are RD, RDS, WR and WRS, which read and write devices: reading the production count in DM to show it on a screen, or rewriting an MR relay to change the operation, for example.
Which PLCs it connects to
The manual covers the built-in Ethernet ports of the KV-8000(A), KV-7500 and KV-5500, the KV-EP21V EtherNet/IP unit (mounted on a KV-8000, 7500, 7300, 5500, 5000 or 3000) and the KV-NC1EP for the KV Nano series. The device ranges and the number of points you can read or write at once differ by model.
Relation to the MC protocol
The KV series also supports the MC protocol (port 5000), which shares the TCP connections with Host Link. With Host Link you write KV device names (DM, MR and so on) as text, so you specify devices by the same names you use in your ladder program.
Using a library
KcpX for .NET builds these commands and parses the responses for you. You only specify a type and an address.
using KcpXLib;
using KcpXLib.Enums;
using var kcpx = new KcpX("192.168.0.10", 8501, series: PlcSeries.KV8000);
short value = kcpx.Read<short>(Prefix.DM, "100");The next article looks at the command and response format in detail.
Sources
- KEYENCE KV-EP21V/KV-8000(A)/KV-7500/KV-5500/KV-NC1EP User's Manual, EtherNet/IP Functions (Japanese edition) pp.1-11, 3-10–3-12
- Same manual, chapter 8 "Host Link communication" pp.8-2–8-8