Replacing a PC-based controller with a Raspberry Pi in a CNC milling system

Mantas Jozavitas1
Justas Makutėnas2
Andrius Dzedzickis3
1, 2, 3Department of Mechatronics, Robotics and Digital Manufacturing, Vilnius Tech, Vilnius, Lithuania
Corresponding Author: Mantas Jozavitas
Download PDF

Abstract

Single-board controllers such as the Raspberry Pi offer compact, low-cost alternatives to PCs for CNC control, with sufficient processing power and Linux real-time kernel support enabling deterministic timing [1]. They reduce hardware overhead, simplify interfacing with drivers, and offer energy-efficient operation compared to traditional desktop systems.

However, embedded platforms also introduce challenges: interrupt latency, background thread interference, and resource contention can degrade timing precision required for step-pulse generation and motion control. Achieving sub-20 µs jitter remains difficult on ARM-based SBCs for high-rate software stepping [2].

This study replaces the PC controller of a desktop CNC mill with a Raspberry Pi running a PREEMPT-RT Linux kernel. System latency was measured using the latency-histogram tool, capturing base-thread and servo-thread performance under a 25 µs and 1000 µs period respectively. The results show a maximum latency of ~10.5 µs for the base thread and ~9.1 µs for the servo thread (sdev ~0.3 µs), indicating stable timing behaviour suitable for small-scale milling tasks.

Fig. 1. Latency histogram of the Raspberry Pi-based CNC controller showing), base-thread timing (green) and servo-thread timing(blue)
Latency histogram of the Raspberry Pi-based CNC controller showing),  base-thread timing (green) and servo-thread timing(blue)

References

  • G. K. Adam, “Real-time performance and response latency measurements of Linux kernels on single-board computers,” Computers, Vol. 10, No. 5, p. 64, May 2021, https://doi.org/10.3390/computers10050064
  • Maker Yang, “How can I optimize latency for LinuxCNC on Raspberry Pi 4B with Debian12?,” in LinuxCNC Forum, Sep. 2023.
  • C. San Vicente-Gutiérrez, L. Usategui-San Juan, I. Zamalloa-Ugarte, and V. Mayoral-Vilches, “Real-time Linux Communications: an evaluation of the Linux communication stack for real-time robotic applications,” arXiv:1808.10821, 2018.

About this article

Received
November 25, 2025
Accepted
December 3, 2025
Published
December 1, 2026
Keywords
CNC milling
Raspberry Pi control
real-time Linux
PREEMPT-RT
latency analysis