NEW v0.1.0 — first release →
KEYENCE PLC — KV SERIES

Talk to KEYENCE KV PLCsin just a few lines.

KcpX is a .NET library for communicating with KEYENCE KV series PLCs over Host Link. It reads and writes devices over TCP/UDP. The library builds the commands and parses the responses, so all you write is the type and the address.

PROTOCOL
Host Link · TCP/UDP
LICENSE
MIT
PLATFORM
Win · Linux · macOS
PLC
KV-8000 · 7000 · 5000 · Nano

// WHY KcpX

Simple, safe PLC communication

Read and write a PLC by passing a type and an address — and every message it sends is verified character by character in tests.

Intuitive, type-safe API

All you specify is the type and the point count. Generics keep bool as bool and short as short. The library picks the data format (.U / .S / .D / .L) and splits 32-bit values into words, and invalid addresses throw before anything is sent.

Verified on a real PLC and the simulator

An MSTest suite checks Host Link commands and responses character by character, plus integration tests against a real KV-7500 and the KV STUDIO simulator. PLC error responses (E0–E6) arrive as typed exceptions.

Free, open source, runs anywhere

MIT-licensed open source — no license fees, commercial use included. Pure .NET, so it is not tied to Windows: it runs on Linux, macOS and Raspberry Pi as-is.

KcpX vs. KV COM+ Library

FeatureKcpXKV COM+ Library
License costFree (MIT, open source)Paid (sold per license)
Supported OSLinux / Windows / macOSWindows only
ImplementationPure .NETActiveX controls (Windows-dependent)
Development environment.NET 7–9 / .NET Framework 4.6.1+ / .NET Core 2.0+Visual Basic / Visual C++ / Excel / Access
SetupAdd from NuGetInstaller / license purchase
Source codeOpen (GitHub)Closed

* A general comparison based on public information on KEYENCE’s product page (KV-DH1L).

// CAPABILITIES

Everything you need for PLC communication

Focused on PLC communication and nothing else, it stays out of your app’s architecture. Drop it into monitoring, control or logging apps as a building block.

01 COMBINED READ / WRITE

Ranges and single devices, one builder

Add a point count and it becomes a batch read (RDS); leave it out and it is a single read (RD). Put consecutive ranges and scattered devices in the same builder, and KcpX picks the right command for each. Different types, different devices — the same code.

Example.cs
short[] block = [];
int  total   = 0;
bool running = false;

// With a point count → batch read (RDS), without → single read (RD)
kcpx.Read(b => b
    .Add<short>(Prefix.DM, "400", 100, v => block = v)
    .Add<int>(Prefix.DM, "2000", v => total = v)
    .Add<bool>(Prefix.MR, "10", v => running = v));

kcpx.Write(b => b
    .Add<short>(Prefix.DM, "500", [1, 2, 3])
    .Add<bool>(Prefix.MR, "20", true));
02 KV STUDIO SIMULATOR

No PLC on your desk? Use the simulator

KcpXSimulator connects to the KV STUDIO simulator over Host Link (TCP). The read/write API is the same as for a real PLC, so you can develop and test without hardware — and switch to a real PLC by changing the connection to KcpX. (KV-8000 / KV-X500 projects, verified with KV STUDIO Ver.12.41.)

Example.cs
// Connect to the KV STUDIO simulator (127.0.0.1:8501)
using var sim = new KcpXSimulator();

// The read/write API is the same KcpX you use with a real PLC
sim.Write(b => b
    .Add<short>(Prefix.DM, "100", 123)
    .Add<bool>(Prefix.MR, "0", true));

short dm100 = sim.Read<short>(Prefix.DM, "100");

// Timer contact, current value and set value read just the same
TimerCounterValue t0 = sim.ReadTimerCounter(Prefix.T, "0");

Other commands

CommandDescriptionMethods
Single read/writeRead or write one device as the type you specify (RD / WR).Read<T>/Write<T>
Batch read/writeRead or write thousands of consecutive devices in one call, split automatically when a point limit is exceeded (RDS / WRS).BatchRead<T>/BatchWrite<T>
Timers / countersRead a T / C contact, current value and set value together, and rewrite set values (RD / RDS / WS / WSS).ReadTimerCounter/BatchReadTimerCounter/WriteSetValue<T>/BatchWriteSetValue<T>
Force set / resetForce bit devices ON or OFF. Requests over 16 consecutive points are split automatically (ST / RS / STS / RSS).ForceSet/ForceReset/BatchForceSet/BatchForceReset
MonitoringRegister up to 120 bit and 120 word devices once, then call Read() to get the latest values (MBS / MWS / MBR / MWR).MonitorRegist(build)/MonitorSession.Read()
Operating modeCheck the PLC operating mode (PROGRAM / RUN) and switch it from code (?M / M0 / M1).ReadOperatingMode/ChangeOperatingMode

Every command has an async/await-friendly …Async counterpart.

NO LIMITS

Point limits and word handling, automatic

Host Link limits how many points one command can read or write, per device and PLC series. KcpX looks up the limit from the series you pass at connection and splits commands automatically when needed. It also works out the word count and data format for values such as int and double, so you never have to think about protocol limits.

SAME API AS McpX

Write it the way you write for Mitsubishi

KcpX shares its API design with McpX, the library for Mitsubishi Electric PLCs. Read<T>, BatchRead<T>, combined read/write builders, MonitorRegist — the code you know from McpX carries straight over to KEYENCE PLCs.

// USE CASES

What you can build with KcpX

Typical scenarios where KcpX shines.

Use cases

Equipment monitoring

Real-time monitoring dashboards

Register devices for monitoring and poll their current values. Show equipment status and alarms on a web dashboard in real time.

ASP.NETMonitoringAsync
SCADA integration

A communication layer for SCADA

Implement the layer between your SCADA app and the PLC with KcpX. Type-safe reads and writes give tag collection and control commands a stable foundation.

Comms layerSCADAType-safe
Gateway

PLC ↔ server over MQTT

Build a gateway that publishes device values read from the PLC to a server over MQTT, streaming shop-floor data to the cloud through a broker.

MQTTGatewayIoT
Test automation / CI

Automated tests & CI for PLC software

Verify ladder program inputs and outputs from code: automate write-then-read-expected checks and put them in your CI pipeline. Connect to the KV STUDIO simulator and run the tests without a physical PLC.

CIAutomated testsSimulator

// PLATFORMS

Broad platform & PLC support

Runs on every major OS, from the latest .NET back to .NET Framework. Generic support for 9 data types and 24 device types.

Frameworks

.NET 7.0+.NET 8.0+.NET 9.0+.NET Core 2.0+.NET Framework 4.6.1+

Operating systems

LinuxWindowsmacOS

Supported PLCs

KV-8000KV-7500 / 7300KV-5500 / 5000 / 3000KV NanoKV STUDIO simulator

Protocols

Host LinkTCPUDPASCIIPort 8501

Data types

boolshortushortintuintlongulongfloatdouble

Device types

RBMRLRCRVBDMEMFMZFWTMZTTCTSCCCCSCTHCTCATCMVM

// QUICK START

Up and running in two steps

1 · Add the package

terminal
dotnet add package KcpX

2 · Read and write devices

Program.cs
using KcpXLib;
using KcpXLib.Enums;

// Connect to the PLC (Host Link port 8501, TCP)
using (var kcpx = new KcpX("192.168.12.89", 8501, series: PlcSeries.KV7000))
{
    short[] block = [];
    int total = 0;

    // Read a range (with a point count) and single devices in one call
    kcpx.Read(b => b
        .Add<short>(Prefix.DM, "400", 100, v => block = v)
        .Add<int>(Prefix.DM, "2000", v => total = v));

    // Write different devices and types in one call
    kcpx.Write(b => b
        .Add<short>(Prefix.DM, "500", [1, 2, 3])
        .Add<bool>(Prefix.MR, "20", true));
}

Want to learn how Host Link works first? Host Link Guide →

// PROJECT HEALTH

Why you can adopt it with confidence

Developed and maintained in the open, with the groundwork needed for production.

Maintained

Changes are published in the CHANGELOG, and bugs and requests are handled on GitHub. It inherits the design and practices proven in McpX.

Verified in CI and on hardware

Every change is built and tested in CI, with integration tests against a real KV-7500 and the KV STUDIO simulator.

Wide range of runtimes

Targets everything from .NET Framework 4.6.1 / .NET Core 2.0 (.NET Standard 2.0) to the latest .NET 9.

First released in 2026. Like McpX, features ship in minor versions and fixes in patches.

// ROADMAP

What’s next

We keep adding features that make KcpX easier to use on the shop floor.

  • Shipped · v0.1

    First release

    Single, batch and combined read/write, timers/counters, force set/reset, monitoring, operating-mode check and change, and KV STUDIO simulator connection.

  • Planned

    Devices as strings

    Specify the device type and number as one string, as in Read<short>("DM100").

  • Planned

    More Host Link commands

    Model query (?K), error number (?E), error clear (ER), clock setting (WRT), comment read (RDC), bank switch (BE) and expansion unit buffer memory (URD / UWR).

  • Planned

    String read/write

    Add ReadString / WriteString to read and write device values as strings.

  • Planned

    XYM notation

    Address devices with XYM notation: X / Y / M / L / D / E / F.

// GET STARTED

Get started now

Add the package, point it at an IP, and your first read/write runs in a few lines. Free, MIT-licensed, commercial use included.

$ dotnet add package KcpX