KC868-A16 EtherNet/IP
EtherNet/IP controller firmware for the Kincony KC868-A16 (ESP32 + Ethernet)
Status: This project is a proof-of-concept implementation and requires further development, testing, and validation before production use.
Overview
A proof-of-concept port of the OpENer EtherNet/IP stack to ESP32 with Ethernet, targeting the Kincony KC868-A16 Ethernet I/O controller. The firmware exposes 16 relay outputs, 16 opto-isolated digital inputs, and 4 analog inputs over EtherNet/IP implicit messaging, suitable for PLC integration and industrial automation.
This implementation demonstrates the feasibility of running industrial EtherNet/IP communication protocols on cost-effective, widely available microcontroller platforms. The device acts as an EtherNet/IP adapter, supporting both explicit messaging (for configuration and diagnostics) and implicit I/O connections (for real-time data exchange).
Hardware Platform
The Kincony KC868-A16 is an ESP32-based Ethernet I/O controller with the following specifications:
- Microcontroller: ESP32 (Espressif)
- Ethernet: LAN8720 PHY with RMII interface (PHY address 0)
- Digital Outputs: 16 relay outputs via PCF8574 I/O expanders (active-low)
- Digital Inputs: 16 opto-isolated inputs via PCF8574 I/O expanders (active-low)
- Analog Inputs: 4 channels via ESP32 ADC
- I2C Configuration: SDA GPIO4, SCL GPIO5 @ 400 kHz
Analog Input Configuration
The device provides four analog input channels with the following mapping:
- A1 (INA1): 4–20 mA current input
- A2 (INA2): 0–5 V voltage input
- A3 (INA3): 0–5 V voltage input
- A4 (INA4): 4–20 mA current input
All analog inputs are sampled at 12-bit resolution (0–4095 counts) with 11 dB attenuation.
EtherNet/IP Assembly Structure
The device implements two EtherNet/IP assemblies for I/O data exchange:
Output Assembly (Instance 150)
2-byte output assembly used to send relay control data from the EtherNet/IP scanner (PLC) to the device:
| Byte | Bits | Outputs | Description |
|---|---|---|---|
| 0 | 0–7 | Y01–Y08 | Relay outputs 1–8 |
| 1 | 0–7 | Y09–Y16 | Relay outputs 9–16 |
Note: Bit value 1 = relay on, 0 = relay off. Outputs are active-low at the PCF8574, so the firmware inverts bits when writing to the expander.
Input Assembly (Instance 100)
10-byte input assembly used to send digital input states and analog readings from the device back to the EtherNet/IP scanner:
| Offset | Size | Inputs | Description |
|---|---|---|---|
| 0 | 1 | X01–X08 | Opto-isolated inputs 1–8 |
| 1 | 1 | X09–X16 | Opto-isolated inputs 9–16 |
| 2 | 2 | A1 (INA1) | 4–20 mA raw ADC count (little-endian) |
| 4 | 2 | A2 (INA2) | 0–5 V raw ADC count (little-endian) |
| 6 | 2 | A3 (INA3) | 0–5 V raw ADC count (little-endian) |
| 8 | 2 | A4 (INA4) | 4–20 mA raw ADC count (little-endian) |
Implementation Notes:
- Digital inputs are active-low; the firmware reports a bit as 1 when the physical signal is low.
- Analog values are 12-bit (0–4095 counts), little-endian byte order.
- Analog input mapping: A1 (INA1) and A4 (INA4) are 4–20 mA inputs; A2 (INA2) and A3 (INA3) are 0–5 V inputs.
Software Stack & Tooling
This project uses the following software components:
- ESP-IDF: Version 5.5.1 or later
- OpENer: Open-source EtherNet/IP stack for I/O adapter devices
- lwIP: Lightweight TCP/IP stack for embedded systems
- Web UI: Minimal HTTP interface for IP configuration (
/api/ipconfig)
Device Identity
The device presents the following identity information to EtherNet/IP scanners:
- Vendor ID: 55512 (AG Sweeney Automation)
- Product Name: KC868-A16
- Device Type: Generic Device
- Product Code: 1
Connection Types
The device supports standard EtherNet/IP connection types:
- Exclusive Owner: Bidirectional I/O connection (Output Assembly 150 → Input Assembly 100)
- Input Only: Unidirectional input connection (Input Assembly 100 only)
- Listen Only: Unidirectional multicast input connection (Input Assembly 100 only)
Network Configuration
The device supports both DHCP and static IP configuration:
- DHCP: Automatically obtains IP address, gateway, and DNS from network DHCP server
- Static IP: Manually configured IP address, netmask, gateway, and DNS servers
- NVS Storage: Network configuration is saved to NVS flash and persists across reboots
A minimal web interface is provided at http://<device-ip>/api/ipconfig for network configuration and diagnostics.