Skip to the content
PCBKitNew board
2 layers104.1 × 132.1 mmCNC PCB, the printed circuit board in 3D

3D-printed CNC mill using stepper motors with PyGame based user interface. Supports 3D lines, arcs, and cubic Bezier curves with velocity and acceleration limits.

Size
104.1 × 132.1 mm
Copper layers
2
Thickness
1.6 mm
Parts
11
Nets
122
Pads
182
Tracks, vias
192, 0
Routed
Yes
KiCad
KiCad 9.0 (file 20241229)
Created
18 Aug 2025
Updated
17 Sep 2026

Overview

CNC PCB is an open-source printed circuit board by VedantGithub123, from the VedantGithub123/DIY-CNC-Mill repository on GitHub. It is a 2-layer board of 104.1 × 132.1 mm with 11 parts on 122 nets, routed with 192 tracks and 0 vias.

Its parts include 5 ICs and 5 connectors. It belongs with the robots and motor control boards and the AVR (ATmega, ATtiny) boards of this library.

README

README.md

Project Overview

The goal of this project is to develop a G-code interpreter and CNC mill. The CNC mill can follow straight lines, arcs and cubic bezier curves. It is 3D-printed with PETG, uses stepper motors, which are controlled with an Arduino Mega. The code ran on the laptop sends motor speeds to the Arduino, which moves the motors accordingly. To use the program, connect the Arudino Mega to your laptop with a USB cable. Run the Python file

Getting Started

SolidWorks is used for the CAD

KiCAD is used for the circuit diagram and PCB

Ensure Git is installed and setup to work with he repository

Clone the project repository to your local machine and navigate into the directory:

text
git clone https://github.com/VedantGithub123/DIY-CNC-Mill
cd DIY-CNC-Mill

Python and the PyGame library are needed

Arduino and the AccelStepper library are needed

Repository Structure

The main branch is the organized working branch. Below is an overview of the folder structure for the main branch of this repository

text
DIY-CNC-Mill/
├── build/
├── electrical/
├── input/
├── media/
├── src/
│   ├── arduino/
│   ├── assets/
│   └── run.py
└── README.md

Folder Descriptions

build/: Contains files relating to the physical construction of the device

  design/: Contains the CAD files of the design

electrical/: Contains files relating to the electrical wiring of the device

input/: Location of G-code files to run

media/: Contains photos of the mill

src/: Contains all source code and assets

  arduino/: Code to run on the Arduino

  assets/: Photos needed for the GUI

  run.c: Program to run on the laptop

README.md: Project repository documentation

Program Design Process

Before deciding on how the program specifications were, I needed to determine how I wanted to organize the code. I wanted to keep the UI, G-code interpreter, and serial communication sections separate. A constant loop was needed for the UI, then when buttons are pressed, it would tell the CNC how to move or change the data, such as what file is being read. Finally, during the loop, the interpreter should calculate what speeds are needed and use the serial communication to send it to the Arduino.

G-Code Protocol

I decided to follow this marlin G-code protocol (mostly): https://marlinfw.org/meta/gcode/

However, the only commands that can be used are:

  • G0: Straight line max speed
  • G1: Straight line controlled
  • G2: Clockwise Arc
  • G3: Counterclockwise Arc
  • G4: Stop for time
  • G5: Cubic Bezier Curve
  • G9: Stop
  • M0/M1/M2/M30: Stop the machine and spindle
  • M3: Spindle on clockwise
  • M4: Spindle on counterclockwise
  • M5: Stop the spindle

Speed Calculations

The path-following algorithms in run.py use the same control approach for straight lines, arcs, and cubic Bezier curves. Each path can provide a position and tangent for a given parameter, allowing the main update loop to follow different G-code commands without duplicating the motion-control logic.

During each update, the program determines the point on the active path that is closest to the current spindle position. It calculates the tangent at that point and combines it with a correction vector from the spindle to the path. The correction keeps the tool close to the programmed path, while the tangent continues the motion toward the end of the command. This produces the velocity vector that run.py sends to the Arduino through the serial connection.

The requested velocity is then constrained by the machine's acceleration and deceleration limits. At the beginning of a movement, the speed increases gradually. As the spindle approaches the endpoint, the speed is reduced so the target can be reached without overshooting. If the next movement is compatible with the current direction, the code can transition directly into it instead of stopping between commands; commands such as stops and dwells require the velocity to reach zero.

The update loop repeats these calculations while the machine is running. When the spindle is sufficiently close to the endpoint and its remaining velocity is small enough, run.py completes the current command and advances to the next one. This separates path geometry, speed limiting, and serial output while allowing the same motion loop to control lines, arcs, and Bezier curves.

Serial Communication Protocol

When the computer tries to connect with the Arduino, the Arduino will say CNC Ready. The computer will need to read this before continuing. The Python program opens the Arduino's serial connection, waits for this ready message, and then begins sending movement and spindle commands generated by the G-code interpreter.

The Arduino program reads the commands received over the serial connection, converts them into motor and spindle actions, and uses the stepper-motor controllers to execute them. It continues processing incoming commands while the machine is running and reports status messages back to the computer when necessary. The Python program reads these responses so that it can keep the user interface and machine state synchronized.

If the ready message is not received, the Python program should not send movement commands. The Arduino must be connected over USB and powered before starting the Python program.

Parts

11
QtyValueFootprintReferences
112V Power SourceLibrary:2 Pin ConnectorJ5
1ARDUINO_MEGA_SHIELDLibrary:ARDUINO MEGA SHIELDSHIELD1
1Motor DriverLibrary:L298U5
1Stepper 1Library:4 Pin ConnectorJ1
1Stepper 2Library:4 Pin ConnectorJ2
1Stepper 3Library:4 Pin ConnectorJ3
1Stepper 4Library:4 Pin ConnectorJ4
1Stepper Driver 1Library:TMC2209U1
1Stepper Driver 2Library:TMC2209U2
1Stepper Driver 3Library:TMC2209U3
1Stepper Driver 4Library:TMC2209U4

Questions

How big is the CNC PCB PCB?

It measures 104.1 × 132.1 mm and has 2 copper layers, 1.6 mm thick.

What parts does the CNC PCB use?

11 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the CNC PCB KiCad files?

From the VedantGithub123/DIY-CNC-Mill repository on GitHub, at the commit this page was made from: the board is electrical/CNC PCB/CNC PCB.kicad_pcb and its schematic electrical/CNC PCB/CNC PCB.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the CNC PCB design in my own project?

Its repository states no licence, so its author keeps all rights: ask VedantGithub123 before reusing the design.

Similar boards

  • 2 layers60 × 30 mmController, the printed circuit board in 3D

    Controller

    google/mozc-devices

    Circuit diagrams and firmware source code for Gboard DIY keyboards

    11 parts3kApache-2.0
  • 2 layers103 × 30.5 mmTS Front Endcap, the printed circuit board in 3D

    TS Front Endcap

    EEVengers/ThunderScope

    ThunderScope GitHub Repo

    11 parts1.3kMIT
  • 2 layers26 × 30 mmExpansion Card, the printed circuit board in 3D

    Expansion Card

    FrameworkComputer/ExpansionCards

    Reference designs and documentation to create Expansion Cards for the Framework Laptop

    11 parts1.1kCC-BY-4.0
  • 2 layers53.9 × 23.2 mmBuffer, the printed circuit board in 3D

    Buffer

    hoglet67/RGBtoHDMI

    Bare-metal Raspberry Pi project that provides pixel-perfect sampling of Retro Computer RGB/YUV video and conversion to HDMI

    11 parts1kGPL-3.0
  • 2 layers10 × 20 mm2 connector Sensor Board, the printed circuit board in 3D

    2 connector Sensor Board

    hackclub/OnBoard

    💡 Join 1,000 teenagers and make your first PCB with a $100 grant!

    11 parts915
  • 2 layersFet module, the printed circuit board in 3D

    Fet module

    ByteWelder/Decktility

    A handheld PC

    11 parts855CC-BY-SA-4.0
  • 2 layers47 × 33 mmSevensegment led display module, the printed circuit board in 3D

    Sevensegment led display module

    tardate/LittleArduinoProjects

    a collection of "Little Electronic & Arduino Projects", most involving electronics or an Arduino in one way or another!

    11 parts803MIT
  • 2 layers42.5 × 36.8 mmDevboard, the printed circuit board in 3D

    Devboard

    basilfx/TRADFRI-Hacking

    Hacking IKEA TRÅDFRI products, such as light bulbs, window blinds and other accessories.

    11 parts743CC-BY-4.0