Back to projects
embedded
2024

CNC Milling Machine Control System

Safety-critical Arduino control system for a CNC milling machine with door interlocks, emergency stop, state machine firmware and LCD feedback

Overview

Designed and programmed a safety-critical control system for a CNC milling machine built around an Arduino ATmega328P. The system implements an 8-state finite state machine (INIT, DOOR_OPEN, READY, RUNNING, COOLDOWN, FAULT) with strict transition validation - no state change is permitted unless all relevant safety conditions are satisfied. A magnetic reed switch continuously monitors the door and immediately halts the motor if it opens during the cutting cycle.

An emergency stop mushroom-head button triggers a hardware interrupt for sub-millisecond motor shutdown, engages a latching mechanism that requires manual reset, activates a buzzer alarm and locks out all inputs until cleared. A 10-second cutting cycle and a mandatory 5-second post-cycle safety delay (to allow the spindle to coast to a stop before the door can be opened) are both implemented using millis() non-blocking timing so interrupt handlers and sensor polling continue throughout. A TL071 op-amp configured as a Schmitt trigger buffers and conditions sensor signals for clean digital transitions into the Arduino, isolating it from the noisy industrial environment.

A 16x2 HD44780 LCD driven over a 4-bit parallel interface displays real-time status messages for every state and a countdown during the safety delay. Multi-color LED indicators (green for ready, yellow for running, red for fault) and a buzzer provide additional feedback. A watchdog timer monitors for firmware crashes and forces a safe shutdown if the main loop stalls.

Key highlights

  • ·8-state finite state machine: INIT, DOOR_OPEN, READY, RUNNING, COOLDOWN, FAULT
  • ·Hardware interrupt on E-Stop for sub-millisecond motor shutdown with latching reset
  • ·Door interlock halts motor immediately on opening during any active state
  • ·Mandatory 5-second post-cycle safety delay before door access is permitted
  • ·TL071 Schmitt trigger buffers sensor signals to isolate Arduino from industrial noise
  • ·Watchdog timer forces safe shutdown on firmware crash or main loop stall

Technologies

Arduino
C++
Embedded Systems
TL071
LCD
Safety Systems

Gallery