---
title: "ESP32UDP - ESP32 + Native RMII or SPI Ethernet LinuxCNC Real time High Speed Smooth Motion Controlle"
url: "https://maker.wiznet.io/matthew/projects/esp32udp-esp32-native-rmii-or-spi-ethernet-linuxcnc-real-time-high-speed-smooth-motion-controlle/"
markdown_url: "https://maker.wiznet.io/matthew/projects/esp32udp-esp32-native-rmii-or-spi-ethernet-linuxcnc-real-time-high-speed-smooth-motion-controlle/md"
type: "UCC: User Created Content"
author: "Wez Hunter"
author_url: "https://github.com/wezhunter/ESP32_LinuxCNC_MotionController_RealTime"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "Wez Hunter"
original_url: "https://github.com/wezhunter/ESP32_LinuxCNC_MotionController_RealTime"
published: "2025-11-28"
language: "en"
likes: 0
views: 1902
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# ESP32UDP - ESP32 + Native RMII or SPI Ethernet LinuxCNC Real time High Speed Smooth Motion Controlle

> ESP32UDP turns an ESP32 plus RMII or W5500 Ethernet into a real-time LinuxCNC motion controller, generating multi-axis step pulses up to 200 kHz.

Original author: Wez Hunter (source: https://github.com/wezhunter/ESP32_LinuxCNC_MotionController_RealTime)

## Article

This project is an **ESP32-based, real-time motion controller for LinuxCNC** that uses **Ethernet (either RMII PHY or a WIZnet W5500 SPI module)** to turn a low-cost ESP32 board into a **multi-axis external step generator + I/O interface** capable of up to ~200 kHz step rates.

Below is an English-language curation aimed at makers and CNC tinkerers who want to understand what this project does, who’s behind it, how W5500 fits in, and where it’s making an impact.

---

## ESP32 LinuxCNC Motion Controller (ESP32UDP)

**ESP32_LinuxCNC_MotionController_RealTime by wezhunter**

---

### ![](https://maker.wiznet.io/upload/ckeditor5/1071068137%5F1764335039%2Epng)

### 1. What this project is

**ESP32_LinuxCNC_MotionController_RealTime** (often called **ESP32UDP**) is a firmware that turns a **dual-core ESP32** into a **real-time external motion controller for LinuxCNC**, connected over **UDP/Ethernet**.

In simple terms:

- **LinuxCNC** (on a PC) does the **trajectory planning** and high-level control.

- It sends **position/velocity commands and I/O values** to the ESP32 over **UDP**.

- The **ESP32** generates **step/dir pulses and handles I/O in real time**, offloading hard real-time work from the PC.

The project supports two Ethernet options:

- **Native RMII Ethernet** (ESP32 + LAN8720 or similar PHY)

- **WIZnet W5500 SPI Ethernet** module (the focus for WIZnet makers)

And it’s not just a toy: the firmware targets **up to ~200 kHz total step pulse frequency** (per axis up to 200 kHz; multi-axis combined limits depend on config), with newer work showing **300 kHz+ combined** on ESP32-S2/S3 USB “virtual Ethernet” variants.

---

### 2. Quick background: what is LinuxCNC?

![](https://maker.wiznet.io/upload/ckeditor5/1071068137%5F1764335387%2Epng)

**LinuxCNC** is an open-source CNC control system that runs on Linux and is used to control mills, lathes, routers, plasma cutters, 3D printers, hexapods, robot arms, and more.

A few key points:

- It uses a **real-time Linux kernel** (RTAI or PREEMPT_RT) so it can execute motion control loops with fixed timing (e.g., 1 ms servo loop).

- It has a **HAL (Hardware Abstraction Layer)** that lets it talk to many kinds of hardware – from classic parallel ports and FPGA cards to Ethernet-based controllers.

- Traditionally the PC itself had to generate step pulses, but at high speeds / many axes this becomes difficult. External motion controllers like this ESP32 project let LinuxCNC focus on **G-code and trajectory planning**, while a separate device handles **hard real-time step timing**.

ESP32UDP lives exactly in that space: it is **one of the main “ESP32 as a LinuxCNC motion controller” solutions**.

---

### 3. Project overview (ESP32UDP at a glance)

From the project’s own description:

> “Hardware based external step generator and IO interface for LinuxCNC over native RMII Ethernet or W5500 SPI Ethernet on a dual core ESP32…”

![](https://maker.wiznet.io/upload/ckeditor5/1071068137%5F1764335629%2Epng)

#### Features

- **Up to 6 axes** with **STEP/DIR + ENABLE** outputs

- **7 digital inputs + 7 digital outputs**, all outputs can be PWM driven

- Uses the **ESP32 RMT peripheral** for high-rate, smooth step generation

- Runs **position mode at low speeds** and **velocity mode at higher speeds** to balance accuracy and smoothness

- Designed to run at up to **~200 kHz total step frequency**, with newer variants (ESP32-S2/S3 USB virtual Ethernet) showing **300 kHz+** in testing

- **Core 0**: UDP networking + motion control logic

- **Core 1**: kept mostly free for user extensions / additional libraries

- Wi-Fi, ESP-NOW, Web UI, OTA and Telnet support exist in related repos / prototypes, but for deterministic motion the main path is **wired Ethernet (RMII or W5500)**.

In short: you get a **low-cost, 6-axis external motion controller** that speaks UDP with LinuxCNC and can be wired to stepper/servo drives like any other step/dir motion card.

---

### 4. Author & community footprint

#### 4.1 Who is behind it?

The main author is **Wez Hunter** (GitHub: `wezhunter`). The repo tagline is literally:

> **“ESP32 hardware based real-time LinuxCNC motion controller”**

On the **LinuxCNC forum**, he appears under the nickname **“wez”** and started a long-running, high-traffic topic titled:

> **“ESP32/S2/S3 LinuxCNC Controller (6 axis hardware step gen, USB plug-and-play)”**

That thread has ~200 replies and almost 50k views (as of mid-2025), which gives you an idea of how much interest there is in this family of controllers.

He also maintains **ESP32_LinuxCNC_Wireless_Client**, an ESP-NOW wireless pendant / MPG client that talks to the ESP32 motion controller over a low-latency point-to-point link.

#### 4.2 Where is the project active, and what impact does it have?

- **LinuxCNC forum**
  - The long thread **“linuxcnc-esp32 Software Stepping over Ethernet Using ESP32”** discusses HAL2UDP and then points users at this repo as the more modern, real-time controller.
  - Users report real machines running with **ESP32 + W5500 + LinuxCNC**, mentioning step rates in the tens of kHz per axis and stable operation over wired Ethernet.![](https://maker.wiznet.io/upload/ckeditor5/1071068137%5F1764334578%2Ejpg)![](https://maker.wiznet.io/upload/ckeditor5/1071068137%5F1764334567%2Ejpg)

- **YouTube & third-party content**
  - In videos like **“linuxcnc espnow wireless control MPG via 2 esp32's”**, the author explicitly credits: “Thanks wezhunter, whoever you are! github wezhunter/ESP32_LinuxCNC_Wireless_Client and wezhunter/ESP32_LinuxCNC_MotionController_RealTime.”
  - Other videos demonstrate **“LinuxCNC + ESP32 step generator + W5500 Ethernet”** and external step generation via W5500, further amplifying the pattern ESP32 + W5500 + LinuxCNC.

![](https://maker.wiznet.io/upload/ckeditor5/1071068137%5F1764334792%2Ejpg)

- **WIZnet maker ecosystem & HAL2UDP lineage**
  - WIZnet’s own maker site features a re-curation titled **“High-Speed CNC Step Generator: LinuxCNC, ESP32, W5500 Ethernet Integration”**, which is based on **HAL2UDP** – a closely related project that inspired this repo and also uses W5500.
  - In the README credits, Wez explicitly thanks **Juhász Zoltán (HAL2UDP)** for his original concept: an external step generator and I/O interface for LinuxCNC using **ESP32 + W5500 SPI Ethernet**.

- **CNC forums & semi-commercial use**
  - Various CNC forums (e.g., in Polish and French) link directly to this repo and describe it as an **“ESP32 LinuxCNC real-time motion controller”**, with some posts offering pre-flashed boards as retrofit modules.

In practice, this firmware is now one of the **go-to reference designs** when people ask, “Can I use an ESP32 as an external motion controller for LinuxCNC?”

---

### 5. Architecture & data flow

![](https://maker.wiznet.io/upload/ckeditor5/1071068137%5F1764336451%2Epng)

#### 5.1 High-level architecture

From the README and HAL docs:

1. **LinuxCNC host (PC)**

- A HAL component (commonly referred to as `esp32udp`) exposes pins such as:
  - `esp32udp.axis.N.position_cmd`, `.velocity_cmd`
  - `esp32udp.out.N`, `esp32udp.pwm.N`
  - `esp32udp.enable`, etc.

- At each servo cycle, LinuxCNC writes commands into these pins and the component sends them via **UDP** to the ESP32.

**2. ESP32 motion controller**

- Core 0 runs a main loop that:
  - Receives UDP packets
  - Parses axis commands and I/O values
  - Feeds these into RMT-based step generators and GPIO/PWM outputs
  - Computes feedback (position_fb, velocity_fb, I/O states, packet counters) and sends a reply packet back

- Core 1 is mostly free for user-level extensions or additional logic.

**3. Step generation & control modes**

- At low speeds, the controller operates in **position mode** (following LinuxCNC’s commanded positions).

- At higher speeds, it operates in **velocity mode**, which is more efficient and smoother for high-frequency stepping.

**4. Ethernet transport**

- Network connectivity can be provided by:
  - **RMII PHY** (e.g., LAN8720) using the ESP32’s native MAC, or
  - **WIZnet W5500 SPI Ethernet** module

- Both are supported; the key difference is whether Ethernet is handled inside the ESP32 or offloaded to W5500.

#### 5.2 What data actually crosses the wire?

Based on HAL pin structure and docs, the UDP payload contains:

**Host → ESP32 (commands)**

- Axis commands (float):
  - `position_cmd[N]`
  - `velocity_cmd[N]`

- Digital outputs: `out[N]` (booleans) for relays, coolant, spindle on/off, etc.

- PWM outputs: `pwm[N]` (0–1 duty) for spindle speed or analog-like control.

- Control flags: enable, reset, configuration triggers.

**ESP32 → Host (feedback)**

- Axis feedback (float):
  - `position_fb[N]`
  - `velocity_fb[N]`

- Digital inputs: `in[N]` (limit switches, home switches, E-stop, probes, etc.)

- Status & diagnostics: ready flags, lost packet counts, last packet time, sequence numbers, etc.

LinuxCNC’s real-time loop uses these to close the high-level control loop, while the **step timing and I/O pulse edges** are generated precisely on the ESP32.

---

### 6. W5500 in this project – what exactly does it do?

#### 6.1 HAL2UDP roots and W5500

The README’s credits section states (paraphrased):

> Credit goes to **Juhász Zoltán** for his original HAL2UDP concept — an external step generator and I/O interface for LinuxCNC using **W5500 SPI Ethernet** and software-based step generation on ESP32.
> ESP32UDP started from that work, but the firmware has since diverged significantly.

So historically:

- **HAL2UDP** = “ESP32 + W5500 + LinuxCNC over UDP,” mostly velocity-mode step gen.

- **ESP32UDP (this project)** generalises and extends the idea: position+velocity modes, higher step rates, more boards, RMII support, better tooling.

#### 6.2 Typical W5500 setups

You’ll see W5500 used in setups like:

- **Generic ESP32 DevKit + W5500 module** (via SPI)

- **MKS-DLC32 CNC board** with:
  - Direction/enable via I2S pins
  - Step lines on an EXP header
  - W5500 connected via SPI pins and an INT pin on another header

All of this is configured in `Config.h` and via the serial command interface (e.g., choosing SPI-W5500 as Ethernet type, setting SPI pins, IP/DHCP options).

#### 6.3 Why W5500, not just native Ethernet or Wi-Fi?

LinuxCNC users care a lot about **determinism**:

- Wi-Fi is convenient but has unpredictable latency and jitter.

- The ESP32’s native Ethernet MAC (RMII) is powerful, but LinuxCNC forum users have seen **buffer/ENOMEM-type issues** in certain configurations, especially under heavy load.

A W5500 brings a few concrete advantages:

- **Hardware TCP/UDP/IP offload**
  - W5500 includes MAC, PHY and a hardware TCP/UDP/IP stack with internal buffers.
  - The ESP32 talks to it via **SPI**, so it only sees relatively small chunks of data and socket-level events, not every frame and ARP/NIC detail.

- **More predictable timing**
  - Offloading Ethernet to W5500 stabilises **latency and jitter**, which is exactly what a CNC motion system cares about.
  - It also reduces the risk of the motion core being disturbed by spikes in the networking stack.

- **Proven pattern in the community**
  - HAL2UDP and numerous user builds (e.g., “external step generation using ESP32 + W5500” threads) demonstrate that **ESP32 + W5500 + LinuxCNC** is a well-trodden path.

So in this project, **W5500 is effectively the “wired Ethernet brain”**: the component that lets the ESP32 motion controller sit on an industrial Ethernet network in a robust, low-jitter way.

---

### 7. Why this project matters

1. **A flagship “ESP32 as LinuxCNC controller” example**

- For people searching “LinuxCNC ESP32 Motion Controller”, this repo is one of the top recommended solutions in forum threads, blogs, and YouTube videos.

** 2. Low-cost retrofit and hobby CNC**

- Compared to proprietary motion control cards, an **ESP32 + W5500 + open-source firmware** is incredibly affordable, and can be customised thanks to the ESP-IDF / Arduino ecosystem.

- Some CNC forums even show pre-flashed ESP32 motion controller modules based on this firmware being sold as plug-in retrofit solutions.

** 3. For WIZnet makers: a “real” industrial-ish reference**

- This is not a blinking-LED demo. It’s a project where **W5500 is used in a demanding real-time CNC motion context**.

- If you want to understand how to combine **ESP32 + W5500 + UDP** for high-rate, low-latency motion or machine control, this repo and its HAL2UDP ancestor are essentially **textbook-level references**.

---

### 8. Quick start (high-level checklist)

This is not a full setup guide, but a rough roadmap if you want to experiment.

#### Hardware (example)

- An **ESP32 DevKit** or CNC-oriented board (e.g., WT32-ETH01, MKS-DLC32)

- A **W5500 SPI Ethernet module** (or an RMII PHY like LAN8720)

- 3–6 stepper/servo drivers (TB6600, DM542, etc.) wired with STEP/DIR/ENABLE

- Limit switches, home switches, E-stop, probe, etc.

#### Firmware side

1. Clone the repo and open it in **VS Code + PlatformIO**.

2. In `Config.h` (and/or via serial commands):

- Select **SPI_W5500** as Ethernet type

- Configure SPI pins (MOSI/MISO/SCLK/CS) and W5500 INT pin

- Set IP / DHCP options

- Map STEP/DIR/ENABLE pins for each axis and I/O pins as needed

3. Build and flash the firmware.

#### LinuxCNC side

1. Install LinuxCNC with development headers and `halcompile`.

2. Build and install the `esp32udp` HAL component (or use the version provided in this project’s docs).

3. Configure a network interface on the same subnet as the ESP32 (e.g. 192.168.111.x/24 if that’s the default).

4. In your HAL file, load `esp32udp` and connect its pins (`position_cmd`, `position_fb`, `out`, `in`, etc.) to the relevant joints, I/O, and GUI signals.

At that point you’ve built a system where **LinuxCNC runs on a PC, planning trajectories, and an ESP32 + W5500 motion controller actually drives the motors and I/O in hard real time**.

---

이 프로젝트는 **LinuxCNC를 위한 외부 실시간 모션 컨트롤러를 ESP32 하나로 구현**한 것으로,
**ESP32 + Ethernet(RMII 또는 W5500 SPI)** 만으로 **최대 200kHz급 멀티축 스텝 제너레이터와 IO 인터페이스**를 만드는 것을 목표로 합니다.

아래 내용은 WIZnet Maker Site 등에서 **영문으로 소개하기 위한 한국어 큐레이션 **입니다.

ESP32 LinuxCNC Motion Controller (ESP32UDP)

**(ESP32_LinuxCNC_MotionController_RealTime by wezhunter)**

---

### 1. Overview — 이 프로젝트는 무엇을 하는가?

**ESP32_LinuxCNC_MotionController_RealTime**(별칭: **ESP32UDP**)는
**듀얼 코어 ESP32**를 이용해 **LinuxCNC와 UDP/Ethernet으로 통신하는 실시간 외부 모션 컨트롤러 & IO 인터페이스**입니다.

README의 헤드라인을 풀어서 정리하면:

**역할**

LinuxCNC가 호스트 PC에서 모션 계획(trajectory planning)을 수행하고,

그 결과(축별 위치/속도 명령)를 UDP 패킷으로 ESP32에 보내면,

ESP32가 하드웨어에서 직접 **스텝 펄스·IO를 실시간 생성/제어**하는 구조.

**Ethernet 옵션Native RMII Ethernet** (LAN8720 등 PHY)

**W5500 SPI Ethernet 모듈**

두 옵션 모두 지원하며, RMII/ W5500 별도로 빌드/설정 가능.

**성능**

최대 **200kHz급 스텝 출력(축당 최대 200kHz, 전체 400kHz까지 언급)**

최신 노트에서는 ESP32-S2/S3 USB 가상 Ethernet 환경에서 **멀티축 300kHz 이상**도 실험적으로 확인.

**운전 모드**

저속에서는 **position mode**, 고속에서는 **velocity mode**로 동작해
저속 정밀도와 고속 부드러움을 동시에 노립니다.

**하드웨어 리소스**

최대 6축 STEP/DIR + ENABLE

7개의 디지털 입력, 7개의 디지털 출력(모두 PWM 가능)

ESP32 RMT 주변장치로 고속·부드러운 스텝 생성

코어 0: 네트워크 + 모션 제어, 코어 1: 사용자 확장용

요약하면, 이 프로젝트는 **LinuxCNC의 실시간 스텝 생성·IO 처리를 ESP32로 외부 위임**하고,
그 연결을 **Ethernet(RMII 또는 W5500 SPI)** 로 처리하는 모션 컨트롤러 펌웨어입니다.

---

### 2. LinuxCNC란 무엇인가? — 배경 이해용

**LinuxCNC**는 리눅스 기반의 **오픈소스 CNC 제어 소프트웨어 시스템**으로,
밀링머신, 선반, 3D 프린터, 레이저/플라즈마 커터, 로봇 암, 헥사포드 등의 기계를 G-code로 구동할 수 있습니다.

**특징**

리눅스 실시간 커널(RTAI, PREEMPT_RT 등)을 사용해 **1ms 단위의 반복 실시간 루프**에서
위치 읽기 → 새 타겟 계산 → 하드웨어에 명령 쓰기 패턴을 수행.

최대 9축까지 제어 가능, G-code(ISO RS-274NGC)를 인터프리트하여 경로 계획.

HAL(Hardware Abstraction Layer)을 통해 PCI/병렬포트/Ethernet 등 다양한 하드웨어와 결합 가능.

**왜 외부 모션 컨트롤러가 필요한가?**

전통적으로는 PC가 직접 step/dir을 내보냈지만,
고속·고축 시스템에서는 **PC의 실시간 부담**이 커지고, I/O 확장이 제약됩니다.

이 프로젝트처럼 **ESP32 + Ethernet** 외부 스텝 제너레이터를 사용하면,

LinuxCNC는 “고수준 모션 계획”에 집중하고,

실제 스텝 펄스/IO 타이밍은 ESP32가 책임지는 듀얼 구조가 가능합니다.

---

### 3. Author & Community — 누가 만들고, 어디서 영향력이 있나?

#### 3-1. 저자: Wez Hunter (wezhunter)

GitHub 프로필 상 메인 프로젝트가 바로 이 리포지터리:
“ESP32 hardware based real-time LinuxCNC motion controller”로 소개되어 있습니다.

LinuxCNC 포럼에서는 닉네임 “wez”로 활동하며,

`ESP32/S2/S3 LinuxCNC Controller (6 axis hardware step gen, USB plug-and-play)` 스레드를 열어
ESP32/S2/S3 기반 저비용·플러그앤플레이 모션 컨트롤러 비전을 설명합니다.

USB 가상 Ethernet, 6축 RMT 스텝 제너레이터, 향후 ESP32-P4 가능성까지 논의하며
**LinuxCNC + ESP32 계열 논의의 핵심 기여자**로 자리 잡았습니다.

별도 리포지터리인 `ESP32_LinuxCNC_Wireless_Client`를 통해

ESP-NOW 기반 **무선 MPG/펜던트** 클라이언트도 제공하고 있어,

유·무선 혼합 제어 구조를 함께 제안하고 있습니다.

#### 3-2. 커뮤니티 & 파급력

**LinuxCNC 포럼**

`linuxcnc-esp32 Software Stepping over Ethernet Using ESP32` 스레드에서
HAL2UDP → ESP32UDP 계열 프로젝트들이 적극적으로 논의됩니다.

여러 사용자가 **ESP32 + W5500 + LinuxCNC** 구성으로
40kHz~100kHz급 스텝, 안정적인 UDP 통신 성능을 공유하며,
레트로핏/자작 CNC 장비에 실제 적용한 사례를 보고합니다.

**YouTube & 외부 UCC**

`linuxcnc espnow wireless control MPG via 2 esp32's` 영상에서는
“**Thanks wezhunter, whoever you are!**”라는 멘트와 함께
이 프로젝트와 ESP32 Wireless Client를 활용한 무선 MPG 데모를 보여줍니다.

**WIZnet Maker / HAL2UDP 계열 레퍼런스**

WIZnet Maker Site에 올라온
**“High-Speed CNC Step Generator: LinuxCNC, ESP32, W5500 Ethernet Integration”** 및
**“LinuxCNC + esp32 step generator + w5500 ethernet”** 리큐레이션 글은,
HAL2UDP + W5500 기반 구조를 소개하고 있는데,
이 프로젝트의 README에서도 HAL2UDP를 직접 **Credits**로 언급합니다.

**해외 CNC 포럼 / 상용화 시도**

폴란드·프랑스 CNC 포럼 등에서는
“ESP32 LinuxCNC RealTime Motion Controller”를 소개하며,
아예 이 펌웨어를 올린 ESP32 모듈을 **제품 형태**로 판매하는 글도 올라옵니다.

→ 결과적으로 이 프로젝트는 **LinuxCNC 세계에서 ‘ESP32 기반 외부 모션 컨트롤러’의 대표 레퍼런스**로 자리하고 있고,
W5500·ESP-NOW·ESP32-S2/S3 USB까지 엮어 새로운 **저비용 실시간 제어 흐름**을 만들어내는 인플루언서 역할을 하고 있습니다.

---

### 4. How It Works — 구조 & 데이터 플로우

#### 4-1. 시스템 아키텍처

README 및 관련 문서 기준 전체 구조는 다음과 같습니다.

**LinuxCNC 호스트(PC)**

HAL 컴포넌트 `esp32udp.comp`를 통해

각 축의 position_cmd / velocity_cmd,

디지털 출력/입력, PWM 값 등을 ESP32에 **UDP 패킷**으로 전송.

ESP32로부터 position_fb / velocity_fb / IO 상태 / 패킷 통계 등을 되돌려 받습니다.

**ESP32 모션 컨트롤러**

코어 0: UDP 통신, 명령 파싱, 스텝/IO 생성, 피드백 계산.

코어 1: 사용자 확장 코드/추가 라이브러리용 여유 코어.

ESP32 RMT 주변장치로 6축까지 고속 스텝 생성,
저속 position mode·고속 velocity mode 전환을 통해 부드러운 모션 구현.

**Ethernet 계층**

RMII PHY(LAN8720 등)를 사용하는 **Native EthernetW5500 SPI Ethernet 모듈**

둘 중 하나를 선택해 UDP를 사용하고, WiFi는 부가적인 관리/OTA 용도로 사용 가능합니다.

#### 4-2. LinuxCNC ↔ ESP32 사이에 오가는 데이터

HAL 핀 구조를 기준으로 보면, 다음과 같은 데이터가 W5500/RMII를 통해 오갑니다.

**호스트 → ESP32 (명령)**

축별 위치·속도 명령: position_cmd, velocity_cmd (float)

디지털 출력: out[0..N] (bit) — 예: 릴레이, 펌프, 스핀들 on/off

PWM 값: pwm[0..N] (float, duty 0..1) — 예: 스핀들 속도 등

enable, reset, config 관련 플래그

**ESP32 → 호스트 (피드백)**

position_fb / velocity_fb: 실제 위치·속도 피드백

디지털 입력: in[0..N] — 리미트 스위치, 홈 스위치, E-stop 등

네트워크 상태: lost_packets, seq_num, last_rx_time_ms 등

LinuxCNC는 이 데이터를 **1ms 단위 실시간 루프**에서 주기적으로 읽고 쓰며,
실시간 제약이 큰 **스텝 타이밍**은 ESP32로 넘기고,
G-code 실행·경로 계획·GUI 응답성에 집중할 수 있습니다.

---

### 5. W5500 & SPI Ethernet — 이 프로젝트에서의 WIZnet 역할

#### 5-1. HAL2UDP와의 관계, W5500의 출발점

README의 Credits에는 다음 문장이 있습니다:

> “**Credit goes to Juhász Zoltán** for his original great work and concept for the HAL2UDP components using **W5500 SPI Ethernet** and software-based step generation on ESP32. This project was originally based on it but the firmware source hardly resembles any of it now.”

즉, 이 프로젝트는 처음에 **HAL2UDP (jzolee/HAL2UDP)**,
즉 **ESP32 + W5500 모듈 기반 외부 스텝 제너레이터**를 바탕으로 시작했고,
현재는 RMII/W5500를 모두 아우르는 **대규모 리팩터 버전**으로 발전했습니다.

#### 5-2. 어떤 보드/구성에서 W5500을 쓰는가?

ESP32 DevKit + W5500 모듈 (일반적인 조합)

MKS-DLC32 같은 CNC 보드에서,

I2S 핀으로 DIR/ENABLE을 빼고,

STEP은 EXP1 헤더로,

**W5500 SPI는 EXP2 + I2C 핀에 배선**하는 예시를 README에서 설명합니다.

설정은 `Config.h`와 시리얼 CLI를 통해

Ethernet 타입(RMII or SPI),

SPI 핀맵, W5500 INT 핀, IP/DHCP 등을 지정하는 방식으로 이루어집니다.

#### 5-3. W5500이 가져다주는 이점

**하드웨어 TCP/UDP/IP 스택**

ESP32 자체 스택 대신, MAC/PHY + 소켓 처리는 W5500이 맡아
ESP32는 **순수 모션/타이밍에 집중**할 수 있습니다.

**예측 가능한 지연·지터**

실시간 CNC 제어에서는 패킷 로스·변동 지연이 곧 기계 품질 문제로 이어지기 때문에,
W5500 기반 하드웨어 Ethernet은 WiFi 대비 훨씬 안정적인 선택입니다.

**ESP32 Native Ethernet의 메모리 한계 회피**

LinuxCNC 포럼에서는
네이티브 ESP32 Ethernet 스택에서 ENOMEM 등 버퍼 부족 문제가 나올 수 있다는 의견이 있었고,
**외부 W5500을 사용하면 이런 리스크를 줄일 수 있다**는 경험담도 공유됩니다.

> 한 문장으로 정리하면,
> **W5500은 이 프로젝트에서 “ESP32 모션 컨트롤러를 LinuxCNC 네트워크에 안전하게 연결해주는 하드웨어 Ethernet 브레인” 역할**을 합니다.

---

### 6. Where This Content Has Impact — 어디서 의미가 큰가?

**LinuxCNC 커뮤니티의 대표 ESP32 모션 컨트롤러 레퍼런스**

LinuxCNC 포럼, WIZnet Maker, 여러 블로그/유튜브에서
“ESP32 + W5500 + LinuxCNC” 예제를 소개할 때
HAL2UDP와 함께 이 리포지터리가 거의 필수로 언급됩니다.

**저비용 CNC 레트로핏/자작시장**

기성 모션카드(예: Mesa, EtherCAT 보드 등)에 비해
**“ESP32 + W5500 + 오픈소스 펌웨어”** 조합은 가격이 매우 낮고,
ESP32 IDF/Arduino 생태계와 맞물려 커스터마이징 자유도도 큽니다.

일부 해외 포럼에서는 이 펌웨어를 올린 ESP32 보드를
**레트로핏용 모션 컨트롤러 모듈**로 판매하기도 합니다.

**WIZnet Maker 관점에서의 교과서적 사례**

단순 IoT 예제가 아닌,
수십~수백 kHz 스텝이 필요한 **실제 CNC/모션 제어**에서
**W5500 + ESP32 + LinuxCNC**가 어떻게 쓰이는지를 보여주는 생생한 프로젝트입니다.

WIZnet 기반 Ethernet을 “**공장·기계 레벨 실시간 통신에 적용하는 패턴**”을 배우기에 좋은 UCC입니다.

---

### 7. Quick Reproduce (요약 체크리스트)

**하드웨어 예시**

ESP32 DevKit 또는 WT32-ETH01 / MKS-DLC32 등

**W5500 SPI Ethernet 모듈** (또는 RMII PHY)

3~6축 스텝 드라이버(TB6600, DM542 등) + 리미트 스위치/홈 스위치

**펌웨어 측**

리포지터리 클론 → VSCode + PlatformIO로 오픈

`Config.h`에서

Ethernet 타입: `SPI_W5500` 선택

SPI 핀(CS/MOSI/MISO/SCLK), INT 핀, IP/DHCP 설정

축 수, STEP/DIR/ENABLE 핀맵 설정

빌드/플래시 후, 시리얼 콘솔로 `boardconf` 등 명령을 사용해 세부 설정

**LinuxCNC 호스트 측**

`linuxcnc-uspace-dev`, `build-essential` 설치 후

`sudo halcompile --install esp32udp.comp`

ESP32 IP에 맞는 NIC 설정 (예: 192.168.111.x/24)

HAL 파일에서 `esp32udp.*` 핀을 각 축·입출력 신호에 매핑

이 구성을 통해,
**LinuxCNC는 고수준 모션 계획을 담당하고,ESP32 + W5500은 외부에서 실시간 스텝/IO를 안정적으로 처리하는 듀얼 컨트롤 구조**를 완성할 수 있습니다.

---

Source: https://maker.wiznet.io/matthew/projects/esp32udp-esp32-native-rmii-or-spi-ethernet-linuxcnc-real-time-high-speed-smooth-motion-controlle/
