Build pathIntermediateA weekend

Build a Pen Plotter: Two Stepper Axes That Arrive

A plotter that homes itself, draws a 100 mm square that closes within a few tenths of a millimetre, and repeats it.

Build a Pen Plotter: Two Stepper Axes That Arrive technical schematicFIELDROTORCARRIAGE80 STEPS/MM · 1.8° · 1/16LAG ANGLE DECIDES WHETHER IT ARRIVES

What you are building

A Cartesian pen plotter: two belt-driven axes at right angles, a pen that lifts, and a controller that knows where the pen is because it homed against a switch on startup and has counted every pulse since.

It is worth being clear about why this is a good first precision machine, because it is not the flashiest project on this site. Everything else here — line followers, obstacle avoiders, balancers — has feedback. A sensor sees the world, the code reacts, errors get corrected continuously. This machine has none of that. Nothing on it measures where the pen is. The only reason a line drawn on paper ends up in the right place is that every assumption you built in was true.

That makes it an unusually honest teacher. A line follower that drifts still follows the line. A plotter that drifts draws a square that does not close, and the gap is right there in pen on paper, in millimetres, telling you exactly how wrong you were.

The number that runs the project

Draw a 100 mm square and measure the gap where the last corner should meet the first.

That single measurement is the project’s whole scoreboard, and its value is that the shape of the error tells you the cause:

What the square does Cause Where it is dealt with
Consistently a few percent too big or small Wrong steps/mm Calibration
Open by the same amount at any size Backlash Belt tension and grub screws
Open by a different amount every time Losing steps Current, speed, acceleration
Closes but is a parallelogram Axes not square The frame
Closes cold, opens when run fast Past the pull-in rate or the corner speed Acceleration, or 24 V

Four of those five are settings. One is a frame problem. Knowing which you have before you start changing things is most of the skill.

Bill of materials

Part Qty Cost Notes
NEMA 17 stepper, 1.5–1.8 A 2 £18–28 40 mm body. Avoid the 20 mm pancakes.
A4988 driver 2 (+1 spare) £6–12 Or DRV8825 — check the different Vref formula
Arduino Uno 1 £4–20 A Nano works and is smaller
CNC shield v3 1 £5 Optional but recommended — includes the bulk cap
SG90 servo 1 £2 The pen lift
Lever microswitch 2 £1 One per axis, at the minimum end
GT2 belt, 6 mm 2 m £5 Fibreglass-cored. Rubber-only stretches.
GT2 20-tooth pulley, 5 mm bore 2 £4 This is where 80 steps/mm comes from
GT2 idler pulley 4 £5 Smooth bore, not toothed, for the return runs
8 mm smooth rod, 400 mm 4 £10 Or 2020 extrusion with wheels
LM8UU linear bearings 8 £6 Two per rod end
12–24 V supply, 2 A+ 1 £8–15 24 V if you want speed
100 µF electrolytic, 35 V+ 1 £0.20 Not optional; skip the shield and you need this
Multimeter 1 £10–25 Required for Vref. There is no substitute.
M3 hardware, printed brackets £5 Or laser-cut ply

Roughly £90–130. The multimeter and the supply are reusable; the motion parts are around £60.

Two false economies worth naming. Rubber-only GT2 belt stretches enough to show up as backlash, and the fibreglass-cored kind costs a pound more. And buying exactly two drivers rather than three means that the first one you kill by forgetting the capacitor stops the project for a week.

How it all connects

                12–24 V  ──┬── 100 µF ──┬── VMOT (X driver)
                           │            └── VMOT (Y driver)
                           └── GND ─────┬── Arduino GND
                                        │
  Arduino Uno                           │
    D2 ── X STEP        D5 ── Y STEP    │      X driver ── coil A ── motor X
    D3 ── X DIR         D6 ── Y DIR     │                └ coil B
    D8 ── ENABLE (both, active low)     │      Y driver ── coil A ── motor Y
    D9 ── X endstop  (INPUT_PULLUP)     │                └ coil B
    D10 ── Y endstop (INPUT_PULLUP)     │
    D11 ── pen servo signal ────────────┴── servo 5 V from the Arduino

The one non-obvious rule: route the endstop leads away from the motor cables. A stepper cable is a chopping current source and an endstop lead running alongside it for 300 mm is an antenna. A machine that homes correctly with the motors disabled and fails with them running has this problem and nothing else.

Build it in milestones

Each milestone ends in a test. Do not skip them — every one catches a fault that is much harder to find later, once three other things are also wrong.

1. One motor on the bench. Driver wired, Vref set, ENABLE low, 3200 pulses commanded. → Pass: the shaft turns exactly one revolution and a mark on it comes back to the same place, ten times running.

2. Vref on both drivers. Calculate from your motor’s rating and your board’s sense resistors — check the marking, R100 or R050. → Pass: both meters read within 0.02 V of target, and after ten minutes of holding, the motors are warm but you can keep a finger on them.

3. The frame, both axes moving. Belts fitted and tensioned — firm, not guitar-string tight. → Pass: pushed by hand with the motors off, each axis moves smoothly end to end with no tight spots. Fix binding now; it will masquerade as lost steps forever otherwise.

4. Steps per millimetre. Command 100 mm on each axis, measure with a rule, correct by the ratio, re-measure. → Pass: commanded 100 mm gives 99.5–100.5 mm on both axes, twice.

5. Backlash. Approach a mark from the left, note it; approach from the right, note it. → Pass: under 0.2 mm. Over that, tighten belts and check the pulley grub screws are on the shaft flat.

6. Find the limit, then back off. Raise speed and acceleration until an axis skips, then set both to 50–60% of that. → Pass: twenty out-and-back cycles at your chosen settings return to the same mark within 0.1 mm.

7. Homing. Endstops fitted, three-phase seek implemented, ten homing cycles with a mark made each time. → Pass: all ten marks inside 0.05 mm. And: unplug an endstop, home, and confirm it gives up with an error instead of grinding.

8. The pen lift. Servo mounted, up and down angles found by trial. → Pass: the pen contacts the paper with light, even pressure across the whole bed. A pen mounted rigidly will dig in on one side of an unlevel bed — sprung or gravity-hung is much more forgiving.

9. The square. Home, then draw 100 mm on paper. → Pass: the last corner meets the first within 0.3 mm, and drawing it three times gives three squares in the same place.

What good looks like

Measure First working build After calibration The limit
Square closure at 100 mm 1–3 mm 0.2–0.3 mm Frame squareness
Homing repeatability 0.3 mm 0.02–0.05 mm Switch repeatability
Backlash 0.5 mm 0.05–0.15 mm Belt and pulley fit
Drawing speed 20 mm/s 100–200 mm/s Pull-in rate, then corner speed
Microstep size 0.0125 mm Far finer than anything else

The last two rows together are the lesson of the whole project. The motor’s resolution — 0.0125 mm — is roughly twenty times finer than the error you will actually achieve. Not one part of the final accuracy is limited by the stepper. It is all belt, frame and squareness.

That is worth internalising before buying a better motor to fix a plotting problem, and it is why the stepper simulator is on the path: it shows you that under a realistic load the rotor already sits three or four microsteps behind where the driver thinks it is, whatever microstepping you choose.

Hardware notes that matter

24 V over 12 V, if you have the choice. Both work. The difference is where torque starts falling away: about 280 rpm at 12 V against 600 rpm at 24 V for the same motor and current limit. On a 20-tooth GT2 pulley that is roughly 190 mm/s against 400 mm/s before the machine starts struggling. If the plotter will only ever crawl, 12 V is fine.

Jumper MS1–MS3 high. Sixteenth stepping does not make the machine more accurate, but it stops the motors ringing at every step, which on a light frame is the difference between a machine that sounds like a machine and one that sounds like an angry wasp. The cost is 8 000 pulses per second at 100 mm/s, which an Uno handles.

Tension the belts to firm, not tight. Over-tensioned belts load the motor bearings and add friction that eats torque margin. Under-tensioned belts add backlash. Firm enough to twang dully is right.

Both grub screws on the pulley flat. A 20-tooth pulley that creeps on a shaft produces an error that looks exactly like lost steps and responds to none of the fixes for lost steps. Loctite is not excessive here.

When it goes wrong

Symptom Cause Fix
Motor buzzes, does not turn Coil pairs crossed, or no acceleration ramp Re-pair with a meter; add a ramp
One axis drifts a bit further each pass Losing steps on ramps Lower acceleration, raise Vref, or slow down
Fine slowly, skips when fast Past the corner speed Go to 24 V — more current will not help
Square consistently 2% oversize steps/mm wrong Calibrate against a rule and correct the ratio
Square open by a constant amount Backlash Tighten belts; check grub screws
Homes to a different spot each time No slow second pass Add the re-seek at 1–3 mm/s
Homes fine alone, fails while drawing Endstop lead picking up driver noise Re-route it; add 100 nF to ground at the pin
Driver dies on power-up No bulk capacitor on VMOT 100 µF, close to the board
Drivers cut out mid-drawing Thermal shutdown Lower Vref; add heatsinks and airflow
Pen drags on one side of the page Bed not level, or pen mounted rigidly Level it; hang the pen sprung, not fixed
Lines wobble at one particular speed Mid-band resonance Change speed slightly, or add mass to the gantry
Everything correct, shapes still skewed Axes not at right angles Square the frame — no setting fixes this

Where to take it next

Swap in GRBL. Once the machine is proven, flashing GRBL gets you a real G-code interpreter with homing, soft limits, coordinate systems and acceleration already written. Configure $100 and $101 with your calibrated steps/mm and you can drive it from any CAM tool.

CoreXY. The same two motors, both fixed to the frame, with belts routed so that X and Y are combinations of the two motors rather than one each. Less moving mass, so faster and more accurate — at the cost of a kinematic mixing layer between the coordinates and the motors.

A laser instead of a pen. Mechanically it is the same machine with a different tool, but a diode laser adds real eye-safety requirements, an enclosure and interlocks. Treat it as a separate project rather than a swap.

A lead-screw Z axis. If you want to plot on something with height, or move to light engraving, a T8 screw gives 400 steps/mm and holds position with the power off.

Closed-loop steppers. The one upgrade that removes this project’s sharpest failure mode entirely. An encoder on the back of each motor turns a silent lost step into a correction or an alarm. Three or four times the cost, and genuinely unnecessary if the milestones above all passed.

Project roadmap

The build path

Follow the tech tree from parts to a robot that follows a taped line. Each node unlocks when its prerequisites are done, and your progress saves on this device.

0 / 20 done

100%
Goal

A plotter that draws a square that closes

The whole project

Learning path

Precision motion with steppers

Learning path

Open path
Build

Assemble, calibrate, draw

A weekend

Components

Tutorials in this path

Practise before you wire

Tune it in the live simulator

The build path routes through a browser lab. Find gains that follow the track cleanly here, then transfer them to the real robot.

Frequently asked questions

How accurate can a hobby pen plotter be?

A carefully built belt-driven plotter will repeat to about 0.1 to 0.2 mm and close a 100 mm square within a few tenths. The limits are not the motor: at 1/16 stepping on a 20-tooth GT2 pulley a microstep is 0.0125 mm, which is far finer than anything else in the machine. What actually sets the error is belt tension, frame stiffness, backlash at the pulleys and how square the two axes are to each other. If you are getting worse than half a millimetre, measure those four before touching any firmware setting.

Do I need a CNC shield or can I breadboard it?

Either works. A CNC shield is about five pounds, gives you sockets for the drivers, brings out the endstop and spindle pins, and includes the bulk capacitor — which removes the single most common way to kill a driver. Breadboarding is fine for two axes if you add your own 100 µF across VMOT and keep the motor wiring away from the step signals, but the shield costs less than the second driver you would otherwise destroy.

Why a servo for the pen instead of a third stepper?

Because the pen only needs two positions, up and down, and needs no precision in either. A hobby servo does that with one signal pin and no driver at all, which is exactly the job it is good at. A stepper Z axis would need a third driver, a third set of pins, a lead screw and a homing switch, all to reproduce something a two-pound servo does in one line of code.

Belt or lead screw for the X and Y axes?

Belt, without much hesitation. A GT2 belt gives 80 steps/mm and will happily run at 200 mm/s or more; a T8 lead screw gives 400 steps/mm but needs five times as many pulses for the same distance, which on an Arduino Uno caps you around 30 mm/s. A plotter carries almost nothing and needs to move quickly over a page, which is exactly the case belts are good at. Screws earn their place on a Z axis that must hold weight up.

Why does my square not close?

Four causes, and they are distinguishable. If the error is a fixed percentage of the distance, your steps per millimetre is wrong — calibrate against a rule. If it is a constant amount regardless of size, it is backlash, so tighten the belts and check the pulley grub screws. If it is different every time, you are losing steps, so lower the acceleration or raise the current. And if the square is a parallelogram rather than open, the two axes are not at right angles to each other, which is a frame problem no setting will fix.

Can I run GRBL on this instead of writing firmware?

Yes, and it is the sensible route once the machine works. GRBL turns the Uno into a G-code interpreter with homing, soft limits, acceleration and coordinate systems already implemented, and you configure steps per millimetre with $100 and $101. The reason to write the simple version first is that debugging a machine and debugging a firmware configuration at the same time is much harder than doing them one after the other.