The finished machine

Ready to carve!

I decided it would be a fun and festive project to build a CNC pumpkin carving robot this year, the only problem was I made this decision only 3 weeks before Halloween. In addition, I tried to use mostly parts I had hanging around the shop to keep the cost down. Fortunately, I had a lot of CNC electronics, stepper motors and T/V-slot aluminum extrusions left over from another project which came in very handy. Given the time constraint and lack of proper tools, the design was certainly not perfect and made a lot of sacrifices in the name of feasibility. For example, a significant portion of the machine was PLA 3D printed parts. Since PLA is not known for being particularly rigid, something kind of important for CNC machines, the machine did flex a little but not so much that it wouldn’t cut.

Cutting

Cutting out the eyes

The machine is designed to work in cylindrical coordinates, it has a vertical axis, a depth axis and a rotational axis. I originally wanted to design a machine that worked in spherical coordinates to the tool head would always be perpendicular to the pumpkin but it would require a lot more hardware and would drive up the cost of the machine. The design I went with uses two lead screws with rollers to drive the linear axes and a turntable made of internal spur gears to drive the rotational axis. My friend Chris Dalke helped design the turntable and the frame for the machine. For the electronics, I went with a cheap CNC shield running GRBL. This gave us the ability to send g-code commands instead of writing custom protocol to send the target motor commands. Since GRBL doesn’t support rotational axes, I had to do a little configuration magic to trick it into receiving angle commands from 0-360deg. It messes up the feedrates but we were able to experimentally find values that work for cutting pumpkins.

Toolpath

Generated toolpath, visualized in UGS

The general workflow for cutting a pumpkin is to start by drawing out the design you want to cut on a 720x360px canvas. The canvas represents an unwrapped cylinder which is mapped to the cuttable region of the pumpkin and used to generate the toolpaths. The machine then runs a calibration routine which probes the pumpkin with a time of flight sensor and creates a map of the surface. This data was supposed to be used to optimize the cut depth for each section of the pumpkin but I ran out of time an ended up just using it to determine the max radius. I would have preferred to do this probing with a physical switch but there was no easy way to get GRBL to do this since it’s not really set up for it. there is probing support but that’s more for calibrating your tool offset than mapping the entire surface of the part. Once the calibration has completed, you run the toolpath generation script which used OpenCV to detect the contours of the cut area and generate the toolpaths using the depth data from the calibration. The output is a g-code file which can be loaded into your favorite console and streamed right to the machine!

Cutting

The first pumpkin, on Halloween

The outcome of the first run was comically bad but it only took a couple adjustments to make some decent looking pumpkins. The biggest problem we encountered was the stepper in the turntable would heat up during long jobs causing the 3D printed spur gear connected to it to deform. This introduced a lot of backlash in the rotation axis and was the main reason the first pumpkin looks so bad. There was also no ventilation designed into the turntable so we couldn’t even add a fan or a heatsink. In a perfect world, we would make the gears out of metal but since we don’t have real metal working tools we swapped out the PLA part for a PETG replacement. While not a perfect fix, the slightly higher temperature resistance was enough to clean up our cuts.

A Better Result

A much better result!

In a v2, I would want to convert the vertical axis to a dual motor setup with a second lead screw and rail to improve rigidity. I would also re-design the turntable with better cooling, more sturdy gears (maybe a planetary set instead of an internal spur) and a better bearing. Updates to the calibration software and toolpath optimizations could also go a long way. Hopefully I get revisit this project and fix up these issues, it’s not perfect but certainly a good start!

Source Code and CAD: https://github.com/chrisdalke/pumpkin-carving-robot