← All Projects
Mechatronics ★ Featured

SCARA-Style Robotic
Arm CNC

A precision SCARA-style robotic arm with full CNC capability — custom inverse kinematics solver, G-code interpreter, and microstepping motion control built from the ground up.

🦾
Add robot arm photo or CAD render here

01 Overview

SCARA (Selective Compliance Assembly Robot Arm) topology offers an ideal combination of high in-plane rigidity and compliance in the vertical axis — making it excellent for planar CNC tasks like drawing, PCB drilling, laser etching, and pick-and-place operations.

This project builds a complete SCARA CNC system from scratch — mechanical design in CAD, custom electronics, firmware with a full G-code interpreter, and an inverse kinematics engine that translates Cartesian tool paths into joint angles in real time.

02 Kinematics & Mechanical Design

SCARA inverse kinematics converts a target (X, Y) position into joint angles (θ₁, θ₂) for both links. The geometric solution requires handling two possible elbow configurations — elbow-up and elbow-down — and checking joint limit constraints before accepting a command.

Base
J1 · θ₁
L1 = 200mm
J2 · θ₂
End
Tool · Z-axis
// Inverse Kinematics — C++ bool inverseKinematics(float x, float y, float* theta1, float* theta2) { float d = sqrt(x*x + y*y); if (d > L1 + L2 || d < abs(L1 - L2)) return false; // unreachable float cosT2 = (d*d - L1*L1 - L2*L2) / (2 * L1 * L2); *theta2 = acos(cosT2); // elbow-down float k1 = L1 + L2 * cosT2; float k2 = L2 * sin(*theta2); *theta1 = atan2(y, x) - atan2(k2, k1); return checkLimits(*theta1, *theta2); }

03 G-Code Interpreter

The firmware implements a subset of standard G-code sufficient for 2.5D CNC operations — linear moves (G0/G1), arc moves (G2/G3), dwell (G4), absolute/incremental mode (G90/G91), and tool up/down (M3/M5).

G-code is fed via serial (USB or UART) and parsed line-by-line. Each motion command is decomposed into a Bresenham-interpolated step sequence and pushed to a circular step buffer consumed by the stepper ISR at a fixed rate, providing smooth motion with no CPU blocking.

# G-Code toolpath example (PCB drill pattern) G90 ; absolute mode G0 X0 Y0 ; rapid to home M3 ; tool down (drill) G1 X50 Y50 F800 ; move to first hole at 800mm/min G4 P500 ; dwell 500ms M5 ; tool up G0 X80 Y30 ; rapid to next position M3 ; tool down G4 P500 M5 G0 X0 Y0 ; return home

04 Motion Control

Microstepping: Both axes use NEMA 17 stepper motors driven by A4988 drivers at 1/16 microstepping — giving 3,200 steps/revolution and substantially reducing vibration at low speeds.

Acceleration profiles: Implemented trapezoidal velocity profiles with configurable acceleration and deceleration ramps. This prevents skipped steps at high speeds and reduces mechanical resonance that degrades positional accuracy.

Homing: Each axis homes against an endstop switch on power-up. The homing sequence uses a two-phase approach — fast approach to find the switch, retract, then slow approach for precision — establishing reliable zero reference.

05 Results

±0.3mm Positional Accuracy
400mm Work Envelope
Full G-code Support

Achieved ±0.3mm positional repeatability across the 400mm working envelope. Successfully ran test programs including PCB trace drawing, coordinate drilling patterns, and geometric art — validating both the kinematics solver and G-code interpreter.

06 Tech Stack

C / C++ Arduino / AVR G-code NEMA 17 Steppers A4988 Drivers Fusion 360 (CAD) KiCad (Controller PCB) Inverse Kinematics Trapezoidal Profiling