Mechanical Design and Machine Design

The EECS section built a multi-color CoreXY pancake printer. I was one of the two software team people, and I built the path from an SVG drawing to a list of print moves during my travel.

Initial Machine Design

In this week, our EECS section chose to work on an automatic pancake printer. The machine design was inspired by the DIY Pancake Printer project from earlier years. The idea is that it would be a coreXY machine that can draw 2D arts on a griddle through extrusion of pancake batter.

Unfortunately this week also overlapped with my conference travel to DC, so I chose to be on the software team and worked on the initial part of the design-to-toolpath pipeline remotely. The frame, the carriages, and the syringe head were built by the mechanical (CoreXY) and extrusion side of the section. We are also working with the firmware team during integration to implement the motion planning and the syringe control. In the code I attached here, Tudor Mocioi wrote the firmware wrappers. Andrin Schmid wrote the GUI. The shared write-up is on the EECS machine week page where you can also find my contributions.

Group photo of the EECS section
Me and the team on our first meeting.

I start with the idea of software after our initial group discussion. Later on, I decided to narrow down my job to the design-to-toolpath pipeline. The goal is that it reads an SVG, assigns each color to a syringe, compensates for nozzle offsets, fits the drawing where every nozzle in use can reach, orders the strokes, and hands back an abstract list of print events plus a preview and some statistics. I also wrote the first end-to-end hardware layer (CoreXY motion, a UFP board driver, and a command-line printer) and the interface spec, so the whole chain could be tested in simulation early on before the gantry existed. As specified in the readme, I worked with both copilot and Claude to produce the package, but code generation followed my planned outline. I also reviewed and verified line by line to make sure quality.

In the last few days Tudor rebuilt that hardware layer on his own wrappers, which added homing and a real syringe cycle. Andrin's app calls my pipeline for every print. The files from the SVG through the event list stayed as I wrote them. Tudor set the job to start from the homed gantry.

The section CoreXY pancake printer
The final machine, with Anthony holding a printed "pancake".
Video of the machine at work.

SVG conversion and toolpath planning

First I laid down the parameters. Every hardware parameter lives in config/machine.example.yaml, so the team could change units, the homing offset, and the syringe values without touching the planner. And the planner stops at an event list (SelectNozzle, Move, ExtrudeOn, ExtrudeOff, Dwell). When we dropped G-code for the UFP boards, and again when Tudor moved the last stage onto the firmware wrappers, everything up to those events stayed the same.

photo or drawing
    -> Andrin's app (image_to_pancake, GUI)
SVG -> svg_input -> colors -> geometry -> toolpath
                                         |-> preview
                                         |-> motion -> ufp_driver -> firmware wrappers -> UFP boards
        my pipeline

The app calls three of my functions: svg_to_job() in pipeline.py, trace() in preview.py for its own drawing, and plan_motor_moves() once it wants motor steps. Photos, hand drawings, and test squares all need to become SVGs first, so every print goes through this function.

SVG to a job

def svg_to_job(svg_source, cfg: MachineConfig) -> Job:
    paths = load_svg(svg_source)
    color_map = assign_nozzles(paths, cfg)
    area = cfg.reachable_area(set(color_map.values()))
    d = cfg.design
    paths = place_in_area(paths, area, d.margin, d.fit_to_print_area, d.max_size)
    paths = simplify(paths, cfg.print.curve_tolerance)
    events = plan(paths, cfg)
    return Job(paths, events, stats(events, cfg), color_map)

SVG is evil to parse manually, so svg_input.py uses svgelements. Each M starts a new stroke. Curves are sampled about every 2 px, pixels become millimeters at 96 dpi. Note that Y is flipped because SVG's Y points down.

Pixel to millimeter, Y flipped

pl.points = pl.points * [PX_TO_MM, -PX_TO_MM]   # px -> mm, flip Y (SVG Y points down)

geometry.py then scales the drawing by one factor, min(avail_w / w, avail_h / h), so the aspect ratio stays to preserve the original drawing, and centers it in the print area minus a margin. Douglas–Peucker simplification (shapely) runs after that scale, so the tolerance is in real millimeters. On the smiley demo that is 774 points down to 119 at 0.2 mm. The app turns fitting off for photos, which already have a physical size, and uses 0.3 mm so the gantry stops less often (from Andrin's config).

Toolpath preview of a smiley face centered in the print area
smiley.svg, one nozzle. Dashed lines are travel with the syringe off. The red numbers are the stroke order the greedy planner picked. Footer time is the constant-speed estimate, about 0.7 min.
Toolpath preview of the letters HI, eight separate strokes
hi.svg. The letters are plain strokes, eight of them, so travel jumps to 247 mm. The H alone consists of three strokes.

Each stroke is the same sequence: travel to the start, extrude on, an optional dwell, the printing moves, extrude off. Open strokes may be reversed, and a closed loop starts at the closest point. Ordering is through the greedy nearest-neighbour.

One stroke

events.append(_move(cfg, nozzle, pts[0], pr.travel_speed, False))
events.append(ExtrudeOn(nozzle))
if pr.extrude_start_delay > 0:
    events.append(Dwell(pr.extrude_start_delay))
events.extend(_move(cfg, nozzle, pt, pr.print_speed, True) for pt in pts[1:])
events.append(ExtrudeOff(nozzle))

Color and nozzle offsets

colors.py sends each SVG color to the syringe whose configured batter color is closest. The distance is redmean, a cheap perceptual RGB distance, so a designer does not have to hit the hex value exactly. The app's photo converter writes the three nozzle colors into its SVG, and this step sends each one to its own syringe. Nozzles print in color_order. First printed cooks longest, so that slot is the darkest batter.

The nozzles are fixed on the carriage, each with an offset from the gantry reference. A bed point (x, y) needs the gantry at (x, y) - offset. reachable_area() in config.py intersects the print area with what every nozzle in use can actually reach, and the drawing is placed in that intersection.

Two-color smiley preview, dark features on nozzle 0 and a light outline on nozzle 2
two_color.svg. The dark features map to nozzle 0 (180 mm of line) and the light outline to nozzle 2 (753 mm).
Same two-color smiley pulled into the area both nozzles can reach
Nozzle 2 offset to −80 mm. The green dashed box is the area both nozzles can reach, and it stops at x = 220 mm. The drawing is recentered into that box. Note that print length stays 933 mm because the height of the area is still what limits the scale.

Hardware and Integration

The first hardware layer was mine, written so the pipeline had somewhere to go and test before the firmware existed. The README said the firmware team could replace motion.py and ufp_driver.py. And Tudor did that on 16 November. CoreXY math now lives in his xy_geometry.py, and the software plans in millimeters. Each stroke is prime, then one extrude timed over the stroke, then a retract, through his SyringeBank. In my first version the plunger was a third motor locked to the XY move. The gantry homes on limit switches, and home_offset says where that homed point sits in machine coordinates.

Andrin's pancake_machine app is the part a person actually drives: find boards by MOTOR_ID, connect, home, jog, run the syringes, print, and stop. Photo to a 3-color SVG is also the app (image_to_pancake.py). Below I also list some miscellaneous issues that were fixed by other people after my initial version.

Tests

We also prepared some tests that millimeter scaling, aspect ratio, the Y flip, travel versus print, nozzle offset, and the reachable area. The below table details some planned motion. The actual number may be somewhat different.

Design Strokes Print (mm) Travel (mm) XY moves Time (min) Syringe steps
smiley 4 589 92 123 0.9 e0 589
hi 8 526 247 32 0.8 e0 526
two_color 5 933 96 188 1.3 e0 180, e2 753

Remaining issues and future improvements

Code

Download the pancake printer software (.zip)

Team copies, for the version everyone integrated against: software README, group page, Tudor's week 10, Andrin, Fern, Hector.