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.
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.
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.
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.
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.
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.