A comprehensive CNC machine training and control system featuring Arduino-based hardware control and Raspberry Pi GUI interface. This project combines robust stepper motor control, limit switch monitoring, and a modern touchscreen-optimized graphical interface for educational and practical CNC operations.
- Overview
- Architecture
- Features
- Hardware Requirements
- Software Components
- Installation
- Usage
- Hardware Models
- Project Structure
- Configuration
- Development
- Contributing
- License
CNC Jog Trainer is designed as an educational and practical CNC control system that bridges the gap between hardware control and user interface. The system consists of two main components:
- Arduino Hardware Controller - Manages stepper motors, limit switches, piezo buzzer, and RTC clock with G-code interpretation capabilities
- Raspberry Pi GUI Interface - Provides a touchscreen-optimized interface for manual jogging, G-code file management, and real-time machine monitoring
The system is specifically designed for training environments where users need to learn CNC operation principles while having access to a robust, educational platform.
The CNC Jog Trainer follows a modular architecture with clear separation between hardware control and user interface:
┌─────────────────────┐ Serial/USB ┌──────────────────────┐
│ Raspberry Pi │◄────────────────►│ Arduino Uno/Nano │
│ - Python GUI │ │ - Stepper Control │
│ - G-code Sender │ │ - Limit Switches │
│ - Serial Comm │ │ - G-code Parser │
│ - Touch Interface │ │ - Safety Systems │
└─────────────────────┘ └──────────────────────┘
- Dual-Axis Stepper Control: Precise control of X and Y axis NEMA 17 stepper motors via TB6600 drivers
- Safety Systems: Limit switch monitoring with automatic motion stopping
- Audio Feedback: Piezo buzzer for operation alerts and status notifications
- Real-Time Clock: DS3231 RTC integration for timestamped operations
- G-code Interpretation: Support for G0/G1 movement commands with feed rate control
- Serial Communication: Robust command interface for external control systems
- Modular Design: Object-oriented C++ architecture with dedicated classes for each subsystem
- Feed Hold Support: Emergency stop and pause functionality
- Touchscreen Optimization: Large buttons and intuitive layout designed for 7-inch touchscreens
- Manual Jog Controls: Direct X/Y axis movement with customizable step sizes
- G-code File Management: Upload, validate, and send G-code files with progress tracking
- Real-time Status Display: Live machine coordinates, connection status, and operation feedback
- Serial Port Management: Automatic detection and connection to Arduino controllers
- Homing Operations: Automated machine homing with $H command support
- Emergency Controls: Pause, resume, and emergency stop functionality
- Cross-Platform: Compatible with Raspberry Pi and Windows environments
- Arduino Uno, Nano, or compatible microcontroller
- 2x NEMA 17 stepper motors
- 2x TB6600 stepper motor drivers
- 2x Limit switches (normally open)
- Piezo buzzer
- DS3231 Real-Time Clock module
- Power supply (24V recommended for stepper drivers)
- Connecting wires and breadboard/PCB
- Raspberry Pi 3B+ or newer
- 7-inch touchscreen display (800x480 resolution)
- MicroSD card (16GB minimum)
- USB cable for Arduino communication
- Optional: External keyboard/mouse for setup
- Arduino IDE 1.8.19 or newer
- Wire library (included with Arduino IDE)
- RTClib library for DS3231 integration
- Python 3.8 or newer
- tkinter (GUI framework)
- customtkinter (modern UI components)
- pyserial (serial communication)
- threading support
- Clone the repository and navigate to Arduino source:
git clone https://github.com/qppd/CNC-Jog-Trainer.git
cd CNC-Jog-Trainer/source/arduino/JogTrainer-
Install required libraries in Arduino IDE:
- Open Arduino IDE
- Go to Tools → Manage Libraries
- Install "RTClib" by Adafruit
-
Configure pin assignments in
Pins.hif needed -
Upload
JogTrainer.inoto your Arduino
- Navigate to Raspberry Pi source directory:
cd ../raspberry/JogTrainer- Install Python dependencies:
pip install -r requirements.txt- For Raspberry Pi with touchscreen, configure display settings:
# Add to /boot/config.txt
hdmi_group=2
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0- Run the application:
python main.pyConnect to Arduino via serial monitor (115200 baud) and use these commands:
| Command | Description |
|---|---|
X+ |
Jog X axis forward |
X- |
Jog X axis backward |
Y+ |
Jog Y axis forward |
Y- |
Jog Y axis backward |
LIM? |
Query limit switch status |
BUZ |
Test buzzer |
CLOCK |
Display current RTC time |
FEEDHOLD |
Emergency pause all motion |
G0 X10 Y20 |
Move to coordinates (rapid) |
G1 X15 Y25 F100 |
Move to coordinates (controlled feed) |
- Connection: Select Arduino port from dropdown and click "Connect"
- Manual Jogging: Use directional buttons to move axes
- G-code Operations:
- Upload files using "Browse" button
- Send files with "Send G-code" button
- Monitor progress in real-time
- Homing: Click "Home" button to execute $H command
- Emergency Stop: Use "Feed Hold" for immediate motion pause
The project includes 3D printable enclosure models for the complete system:
Complete system view showing the Raspberry Pi enclosure with integrated LCD mount and protective cover.
Base platform for mounting all CNC jog trainer components. Provides stability and alignment for the entire assembly.
Model Files:
model/Jog_Trainer_Base.stl- 3D printable STL file for basemodel/Jog_Trainer_Base.png- Reference image
The main controller enclosure provides:
- Secure mounting for Arduino and stepper drivers
- Ventilation for heat dissipation
- Cable management and strain relief
- Mounting points for external connections
- Professional appearance for educational environments
Model Files:
model/Jog_Trainer_Rpi_Board_Case.stl- 3D printable STL file for main board enclosuremodel/Jog_Trainer_Board_Case.png- Reference image
The LCD mount assembly includes:
- Precision mounting for 7-inch touchscreen displays
- Secure attachment to Raspberry Pi enclosure
- Cable routing channels
- Adjustable viewing angles
- Protection for display connections
Model Files:
model/Jog_trainer_LCD_Mount.stl- 3D printable STL file for LCD mountmodel/Jog_trainer_LCD_Mount.png- Reference imagemodel/CE3V3SE_Jog_trainer_LCD_Mount.gcode- Pre-sliced G-code for Creality Ender 3 V3 SE
Print Settings:
- Layer Height: 0.2mm
- Infill: 20%
- Supports: Yes (for overhangs)
- Print Speed: 50mm/s
- Material: PLA or PETG recommended
The Jog Trainer Plate is the main interface surface for the CNC jog system, providing a robust mounting platform for all control components and accessories.
Model Files:
model/Jog_Trainer_Plate.stl- 3D printable STL file for the platemodel/Jog_Trainer_Plate.png- Reference imagemodel/CE3V3SE_Jog_Trainer_Plate.gcode- Pre-sliced G-code for Creality Ender 3 V3 SE
Print Settings:
- Layer Height: 0.2mm
- Infill: 20%
- Supports: Yes (for overhangs)
- Print Speed: 50mm/s
- Material: PLA or PETG recommended
The Plate Holder secures the Jog Trainer Plate in place, ensuring stability and precise alignment during CNC operation. It is designed for easy installation and removal.
Model Files:
model/Jog_Trainer_Plate_Holder.stl- 3D printable STL file for the plate holdermodel/Jog_Trainer_Plate_Holder.png- Reference imagemodel/Jog_Trainer_Plate_Holder.f3z- Fusion 360 source file for advanced editing
Print Settings:
- Layer Height: 0.2mm
- Infill: 20%
- Supports: Yes (for overhangs)
- Print Speed: 50mm/s
- Material: PLA or PETG recommended
The Belt Guide Mount is designed to securely guide and support the timing belt in the CNC Jog Trainer system, ensuring smooth and accurate motion. It features robust mounting points and optimized geometry for minimal friction and reliable belt alignment.
Model Files:
model/Jog_Trainer_Belt_Guide_Mount.stl- 3D printable STL file for the belt guide mountmodel/Jog_Trainer_Belt_Guide_Mount.png- Reference image
Print Settings:
- Layer Height: 0.2mm
- Infill: 20%
- Supports: Yes (for overhangs)
- Print Speed: 50mm/s
- Material: PLA or PETG recommended
Mount for the bottom limit switch, ensuring accurate homing and safety stops for the CNC axes.
Model Files:
model/Jog_Trainer_Bottom_Limit_Switch_Mount.stl- 3D printable STL file for bottom limit switch mountmodel/Jog_Trainer_Bottom_Limit_Switch_Mount.png- Reference imagemodel/CE3V3SE_Jog_Trainer_Bottom_Limit_Switch_Mount.gcode- Pre-sliced G-code for Creality Ender 3 V3 SE
Mount for the top limit switch, providing safety and precise end-of-travel detection for the CNC axes.
Model Files:
model/Jog_Trainer_Top_Limit_Switch_Mount.stl- 3D printable STL file for top limit switch mountmodel/Jog_Trainer_Top_Limit_Switch_Mount.png- Reference imagemodel/CE3V3SE_Jog_Trainer_Top_Limit_Switch_Mount.gcode- Pre-sliced G-code for Creality Ender 3 V3 SE
The NEMA 17 Mount is engineered to securely hold NEMA 17 stepper motors, providing vibration resistance and precise positioning for CNC movement. It features universal mounting holes and cable management options.
Model Files:
model/Nema_17_mount.stl- 3D printable STL file for the NEMA 17 mountmodel/Nema_17_mount.png- Reference imagemodel/CE3V3SE_Nema_17_mount.gcode- Pre-sliced G-code for Creality Ender 3 V3 SE
T-nut for mounting accessories and panels to the CNC frame.
Model Files:
model/CE3V3SE_T-nut_M3_x12.gcode- Pre-sliced G-code for Creality Ender 3 V3 SE
Washer for spacing and securing CNC components.
Model Files:
model/CE3V3SE_washer2mm.gcode- Pre-sliced G-code for Creality Ender 3 V3 SE
Mount for zeroing switch, used for precise machine calibration.
Model Files:
model/CE3V3SE_ZeroingSwitchMount.gcode- Pre-sliced G-code for Creality Ender 3 V3 SEmodel/ZeroingSwitchMount.STL- 3D printable STL file
This project has migrated from a custom Arduino protocol to GRBL for CNC control. Key changes and new features:
- GRBL Serial Controller: Real-time commands (!, ~, \x18, \x85) sent without newline; regular commands ($J=, G-code) sent with newline. Automatic status polling every 200ms.
- Main Application: Removed legacy Arduino jog commands (X+, X-, Y+, Y-), replaced with GRBL jog commands ($J=G91 G21 X1 F500). Added E-STOP button (Jog Cancel + Feed Hold).
- Record/Replay Feature: Record manual jog commands, save to .gcode, load and replay recorded sequences. Auto-converts $J= commands to regular G-code when saving.
- G-code Sender: Improved comment filtering, error handling, and logging.
Real-Time (no newline):
!= Feed Hold (pause)~= Cycle Start (resume)?= Status Query\x18= Soft Reset (abort)
Jog Command Example:
$J=G91 G21 X1 F500(Jog X axis +1mm at 500mm/min)
See main.py and grbl_serial.py for implementation details.
- Upload Test Program
- Open Arduino IDE
- Load
source/arduino/LimitSwitchTest/LimitSwitchTest.ino - Select board/port, upload, open Serial Monitor (115200 baud)
- Test Limit Switches
- Send
TESTcommand, press each switch when prompted - System beeps when detected, confirms both switches work
- Send
- Test Auto-Homing
- Send
HOMEcommand, machine homes X then Y, buzzer confirms completion
- Send
- Test Movement Safety
- Jog X+ until limit is hit, motor stops, buzzer alerts, position updates
Essential commands: TEST, HOME, X+, Y+, LIM?, BUZ, FEEDHOLD
The CNC Jog Trainer GUI is optimized for touchscreen use (7-inch, 800x480):
- Large touch targets (min 48x48px), clear feedback
- Grid-based layout: header (status bar), main (jog panel, controls), footer (connection, file upload)
- Responsive design: flexible sizing, adaptive components
- Simplified navigation and workflows
See main.py and ui_components/ for implementation details.
CNC_JOG_TRAINER/
├── README.md # This file
├── diagram/ # System diagrams and documentation
├── model/ # 3D models and enclosure designs
│ ├── Jog_Trainer_Board_Case.png # Main board enclosure reference
│ ├── Jog_Trainer_Rpi_Board_Case.stl # 3D printable board enclosure
│ ├── Jog_trainer_LCD_Mount.png # LCD mount reference image
│ ├── Jog_trainer_LCD_Mount.stl # 3D printable LCD mount
│ ├── Jog_trainer_Rpi_Lcd_Case_And_Cover.png # Complete assembly view
│ ├── CE3V3SE_Jog_trainer_LCD_Mount.gcode # Pre-sliced G-code for Ender 3 V3 SE
│ ├── Jog_Trainer_Plate.png # Plate reference image
│ ├── Jog_Trainer_Plate.stl # 3D printable plate
│ ├── CE3V3SE_Jog_Trainer_Plate.gcode # Pre-sliced G-code for plate
│ ├── Jog_Trainer_Plate_Holder.png # Plate holder reference image
│ ├── Jog_Trainer_Plate_Holder.stl # 3D printable plate holder
│ ├── Jog_Trainer_Plate_Holder.f3z # Fusion 360 source for plate holder
│ ├── Nema_17_mount.png # NEMA 17 mount reference image
│ ├── Nema_17_mount.stl # 3D printable NEMA 17 mount
│ ├── CE3V3SE_Nema_17_mount.gcode # Pre-sliced G-code for NEMA 17 mount
└── source/
├── arduino/
│ └── JogTrainer/
│ ├── JogTrainer.ino # Main Arduino sketch
│ ├── ClockModule.cpp/.h # RTC functionality
│ ├── GCodeHandler.cpp/.h # G-code parsing and execution
│ ├── LimitSwitch.cpp/.h # Limit switch monitoring
│ ├── PiezoBuzzer.cpp/.h # Audio feedback system
│ ├── StepperModule.cpp/.h # Stepper motor control
│ ├── Pins.h # Hardware pin definitions
│ └── README.md # Arduino-specific documentation
└── raspberry/
└── JogTrainer/
├── main.py # Main GUI application
├── requirements.txt # Python dependencies
├── ui_ux_design.md # UI/UX design documentation
├── assets/ # GUI assets and resources
├── controller/ # Serial communication modules
│ ├── gcode_sender.py # G-code transmission logic
│ └── grbl_serial.py # GRBL communication protocol
├── ui_components/ # GUI component modules
│ ├── connection_panel.py # Serial connection interface
│ ├── file_upload.py # G-code file management
│ ├── jog_panel.py # Manual control interface
│ └── status_bar.py # Status display component
└── README.md # Raspberry Pi specific documentation
Default pin assignments in Pins.h:
// Stepper Motor Pins
#define X_STEP_PIN 2
#define X_DIR_PIN 3
#define Y_STEP_PIN 4
#define Y_DIR_PIN 5
// Limit Switch Pins
#define X_LIMIT_PIN 6
#define Y_LIMIT_PIN 7
// Buzzer Pin
#define BUZZER_PIN 8
// I2C Pins for RTC (A4=SDA, A5=SCL)Modify settings in main.py:
# Window Configuration
WINDOW_WIDTH = 800
WINDOW_HEIGHT = 480
# Serial Configuration
DEFAULT_BAUD_RATE = 115200
CONNECTION_TIMEOUT = 5.0
# Jog Step Sizes
JOG_STEPS = [0.1, 1.0, 10.0, 100.0]-
Arduino Development:
- Use Arduino IDE 1.8.19+
- Enable verbose compilation for debugging
- Use serial monitor for real-time debugging
-
Python Development:
- Use virtual environment for dependencies
- Follow PEP 8 style guidelines
- Test on both Windows and Raspberry Pi
- New Arduino Commands: Add to
GCodeHandler.cppcommand parser - GUI Components: Create new modules in
ui_components/ - Serial Protocols: Extend
grbl_serial.pyfor new communication patterns
- Hardware Testing: Use Arduino serial monitor for command validation
- GUI Testing: Test touch interface on actual hardware
- Integration Testing: Verify serial communication between components
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow existing code style and documentation patterns
- Test changes on actual hardware when possible
- Update documentation for new features
- Include comments for complex logic
- Verify cross-platform compatibility
This project is licensed under the MIT License. See the LICENSE file for details.
For questions, issues, or contributions:
- Issues: Report bugs and feature requests via GitHub Issues
- Discussions: Use GitHub Discussions for general questions
- Documentation: Refer to component-specific README files in subdirectories
Author: qppd
Repository: https://github.com/qppd/CNC-Jog-Trainer
Version: 1.0.0
Last Updated: October 2025









