Introduction: AutoFrost CNC Cake Decorator

About: An engineer, seamstress, cook, coder, and overall maker. Spent a summer at Instructables; got a degree in E: Neural Engineering at Olin College; made a microcontroller (; now thinking about climate c…

Inspired by a misconception of a "Cupcake CNC", this 1-semester mechatronics project takes input from a Paint-like GUI, sends commands through Arduino, and runs via stepper motors on threaded rods.

The software is all in Python, using TKinter. It allows for the selection of size (up to 11x13" rectangular), shape (rectangle or circle), and cake color, then opens an appropriate canvas with a pallette of tips and colors. The Python records points in a path and, at the press of a button, sends the design over serial to two Arduinos.

One of the two Arduinos controls the stepper motors (controlling threaded rods in X and Y) to move at a constant speed between points in the path. The other Arduino runs a servo in the Z axis, which uses a rack-and-pin plunger system to dispense frosting. The servo stops to pick up between points or pauses for color/nozzle change.

The acrylic plate which holds the cake is affixed to a nut which rides on the x-axis threaded rod; the dispensing mechanism moves in the y axis. These two axes are also controlled with limit switches, which comprise the zeroing mechanism. There is also a manual z axis which moves the dispensing mechanism to adjust for the height of the cake.

This product is all the original work of five students in a class at Franklin W. Olin College of Engineering. It was featured in Wired magazine, Gizmodo, and elsewhere. We were all just learning Python, had been introduced to microcontrollers a few weeks earlier, and had only a little experience in the machine shop. We made it from SolidWorks design and whiteboard sketches to finished project!

You can also view our website, though as of 8/2012, most of the content has been migrated here!

The Mechanical System

The mechanical system was designed in SolidWorks, with assistance from the machine shop supervisors at Olin College.

The system features motion in 3 axes, with CNC control of both the X and Y axes, as well as two independent motions in the z axis. The acrylic table shown above holds the cake, which is moved back and forth along the x axis, while the frosting nozzle head moves in the y axis. We chose to make each component move in one axis to simplify the design and use less material. We then have a rotating handle which allows the user to adjust the machine for heights ranging from .5” to 4”. We have a total travel distance of 13” in the x axis and 11” in the y axis.

X axis
We chose to move the cake along the x axis instead of the nozzle head because we determined that it would be easier to change out the frosting if the nozzle head only moved in one axis. We decided to use drawer sliders as guides, and a stepper motor coupled to a lead screw as a means of moving the cake linearly along the axis. As the motor output shaft turns, it turns the threaded rod, which causes the control nut (which is mounted on the fixture of the cake table) to move back and forth.

Y axis
While having the frosting nozzle stationary would make it even easier to change the frosting or nozzle tips, we realized that moving the cake in both axes wouldresult in our needing a base size of four times the area of the cake (because we would need to move the cake in such a way that allowed us to draw on every part of it). We decided to save material and go with moving the nozzle head in the y. The entire nozzle head assembly moves in the y axis, with the same general motion as the x. The total travel for this axis is 11”. This allows us to draw along the entire height of the cake, and keeps the size of the machine down.

Z axis
The nozzle head features the height adjustment, which allows the user to adjust for different cake sizes. The nozzle head also features the frosting dispensing mechanism which involves a servo driving a piston, which is mounted onto a rack. The rack is then driven by the pinion, which is mounted onto the servo. As the servo turns, it drives the piston down, which in turn dispenses the frosting. The servo dispenses frosting at a set rate while the machine is drawing, and stops to allow it to make separate lines. When we run out of frosting or the color needs to be changed, frosting stops dispensing in order to allow the user to change it. Once the frosting is changed, the user can press a button to continue frosting.

While we bought a few parts, such as the handle, the frosting dispenser, and the threaded rod, the vast majority of the parts in our project were machined in house. This kept our costs down, and allowed us to make modifications to the design as we saw fit. The design is lightweight, despite its size, because we used thin aluminum for most of our structure. While the frame of the base is TIG welded, the rest of the project can be disassembled for cleaning or transportation.

The Electrical System

The electrical part of our project focused on controlling our stepper motors. We chose to use a Toshiba TB6560HQ controller to drive each motor. These controllers can source up to 3 amps which was definitely high enough to power our motors. We had to bend and solder the pins of the controller in order to properly connect them to the breadboard. Heat-sinks were also attached to the controller to prevent the controllers from blowing out. We used 2 controllers, driven by a 5 volt powered supply. Both stepper motors combined sourced 4 volts, with a total output of 12 V.


The two Arduinos (breadboardable iduinos) operated in unison for different functions. Arduino 1 interpreted PySerial, sent from Python, and sent commands over two logic pins and two pulse pins to two stepper motors according to those commands. The logic pins determined the direction of the steppers; the pulse pins, their frequency of rotation. It also output on a third logic pin, which output to an LED and also to Arduino 2. Arduino 2 controlled the motion of the servo which dispensed the frosting. It was coded to slowly dispense, then retract and pause for reload until a button on the circuit (an input pin to the Arduino) was pressed. The input pin on Arduino 2, from Arduino 1's output, was intended to allow interpretations recieved over PySerial to send through Arduino 1 to Arduino 2, such that the frosting dispensation could be programmatically paused. This functionality, however, never came to fruition.

One Arduino parses distances and logic variables sent by the Python GUI over Serial. It translates these signals into pulses which operate the x and y stepper motor. The second Arduino runs the servo which dispenses frosting at a steady rate onto the cake. This second ardino is controlled by a logic pin on the first arduino (dispensing or not dispensing) and by its own monitoring of the plunger's state. Once the frosting plunger has been emptied, the servo pulls up and waits for a button press which signifies that the frosting has been reloaded.

The Arduino code can be found here.

Python GUI

Users design cakes on a Paint-style graphical user interface (GUI), and AutoFrost turns them into reality. We have written our GUI using Python and Tkinter. Aspiring cake decorators can control frosting colors and nozzle shapes while drafting their dream cake. As users draw, we collect points at evenly spaced intervals and store their location, color, and shape. We then parse by color and nozzle shape (prompting the user each time a change is required) and send x-distance, y-distance, and frosting-or-not commands to our three motors.

Python code is downloadable here.

-Karan, Tim, Kelsey, Tara, and Ilana

I Made It Photo Contest

Participated in the
I Made It Photo Contest