Final-year projects / Manufacturing

Two-axis CNC pen plotter with G-code

CNC machines and 3D printers all run on the same ideas: stepper motors, G-code and motion control. A pen plotter built from steppers and a GRBL controller is a safe, cheap way to learn them and draw any design.

Arduino UnoMini or Major projectMECH, EEE, ECE
UNOA4988Featured
Parts
₹6,250
Build
14 weeks
Board
Arduino Uno
Objectives
6

Block diagram

Inputs
  • CODE
    G-code from a PCDescribes the drawing
  • Limit switchesHome the axes
  • REFERE
    Reference sensorGives the values the others are checked against+
Controller
  • UNO
    Arduino Uno with GRBLPlans and times the steps
Power
  • PCB
    PCB and enclosureHolds the circuit as one solid unit+
Outputs
  • A4988
    CNC shield and A4988 driversDrive the steppers
  • Two NEMA 17 steppersMove X and Y
  • 59°
    Servo pen liftRaises and lowers the pen

Objectives

  1. To build an A4-size two-axis frame with belt drives.
  2. To calibrate steps per mm on each axis.
  3. To draw from G-code generated from an image or text, with pen up and down.
  4. To measure dimensional accuracy and repeatability on a test pattern.
  5. To design a PCB and enclosure that turn the prototype into a robust product.
  6. To calibrate two sensors against a reference and compare their accuracy and cost.

Parts and specifications

  • Arduino Uno R3 (CH340 clone)ATmega328P 16 MHz, 32 KB flash, 2 KB SRAM, 5 V logic, 6 analog inputs (10-bit), 6 PWM pins
    ₹450Buy
  • CNC shield V3 for UnoTakes up to four A4988/DRV8825 drivers, end-stop and spindle pins, for GRBL
    ₹180Buy
  • × 2
    A4988 stepper driver8 to 35 V, 1 A per phase without heatsink (2 A with cooling), up to 1/16 microstep, set current with Vref
    ₹240Buy
  • × 2
    NEMA 17 stepper motor1.8° per step (200 steps/rev), 1.5 to 1.7 A per phase, about 4 kg·cm holding
    ₹1,300Buy
  • SG90 micro servo1.8 kg·cm at 4.8 V, 0 to 180°, 50 Hz PWM 1 to 2 ms, stall about 650 mA
    ₹120Buy
  • × 2
    Limit switch with lever5 A micro switch, use as end-stop or helmet-worn switch
    ₹60Buy
  • 12 V 2 A DC adapterRegulated SMPS, 5.5 × 2.1 mm barrel
    ₹200Buy
  • GT2
    GT2 belt 2 m, 20-tooth pulleys and idlers
    ₹450
  • MM
    8 mm rods, linear bearings and frame
    ₹900
  • PCB
    PCB prototype (ElectroLark, 1 to 2 pieces)
    ₹1,500
  • 3D
    3D-printed enclosure (about 60 g at ₹10 a gram)
    ₹600
  • SECOND
    Second sensor of another type
    ₹250

Total about ₹6,250 at typical online prices. Tap a part for its pinout and datasheet notes.

Design calculations

Steps per mm

200 steps/rev × 16 microsteps / (20 teeth × 2 mm pitch) = 3200 / 40 = 80 steps/mm.

Driver current (A4988)

Imax = Vref / (8 × Rs). With Rs = 0.068 Ω and a 1.2 A target: Vref = 1.2 × 8 × 0.068 = 0.65 V. Set lower (about 70% of rated) to keep motors and drivers cool.

Maximum feed

GRBL on an Uno steps up to about 30 kHz: 30,000 / 80 = 375 mm/s, far above what the frame needs; use about 50 mm/s for clean lines.

Resolution

1 / 80 = 0.0125 mm per microstep; real accuracy is limited by belt stretch and backlash (about 0.1 to 0.2 mm).

Pin map

SignalPin or connection
X step / dirD2 / D5 (CNC shield)
Y step / dirD3 / D6
EnableD8
X / Y limit switchesD9 / D10
Pen servoZ+ end-stop pin D11 with servo-enabled GRBL build, or spindle PWM pin

Firmware outline

  1. Flash GRBL (servo-pen variant) to the Uno; set $100 = $101 = 80 steps/mm, max rates and acceleration.
  2. Home with $H using the limit switches.
  3. On the PC, convert an SVG or text to G-code (Inkscape extension) with M3/M5 for pen down/up.
  4. Stream G-code with Universal G-code Sender; GRBL plans acceleration across moves.
  5. Plot a 100 mm square and circle test pattern for calibration.

Test plan

TestExpected result
100 mm squareSides within ±0.5 mm
Circle of 80 mmRoundness checked
Same pattern 5 timesRepeatability
Long drawingNo missed steps (corners still line up)

These rows start your results table when you plan the project.

Viva practice

Say your answer out loud first, then check. The first 2 answers are free; Maker opens all 5.

1. What is G-code?
2. What does microstepping do?
3. Why acceleration planning?
4. How do steppers hold position without encoders?
5. What would turn this into a laser engraver?

Make it yours

One or two upgrades for a mini project, two to four for a major one.

Build these first

Datasheets and sources to cite

  • GRBL v1.1 wiki
  • Allegro A4988 datasheet
  • ISO 6983 (G-code programming format)

About this project

How much does the two-axis cnc pen plotter with g-code project cost?

About ₹3,900 for the parts in the base list: Arduino Uno R3 (CH340 clone), CNC shield V3 for Uno, A4988 stepper driver × 2, NEMA 17 stepper motor × 2, SG90 micro servo, Limit switch with lever × 2, 12 V 2 A DC adapter, GT2 belt 2 m, 20-tooth pulleys and idlers, 8 mm rods, linear bearings and frame.

How long does it take?

About 10 weeks for the base project, built on an Arduino Uno. Each upgrade adds time.

Which branches is it suitable for?

Mechanical / Mechatronics, Electrical and Electronics, Electronics and Communication, as a mini or major project.

Which pins and design calculations does it use?

X step / dir on D2 / D5 (CNC shield); Y step / dir on D3 / D6; Enable on D8. Worked calculations on this page: steps per mm, driver current (a4988), maximum feed, resolution.

How do I test it?

100 mm square: Sides within ±0.5 mm. Circle of 80 mm: Roundness checked. Same pattern 5 times: Repeatability. Long drawing: No missed steps (corners still line up).

What are the objectives?

To build an A4-size two-axis frame with belt drives. To calibrate steps per mm on each axis. To draw from G-code generated from an image or text, with pen up and down. To measure dimensional accuracy and repeatability on a test pattern.