For our midterm project in UC Berkeley’s Introduction to Prototyping & Fabrication course, my partner and I designed, built, and programmed a fully functional 2D plotter with a polar coordinate system.
To run the plotter, we developed a custom g-code interpreter that accepts standard CNC commands read from either our microcontroller’s flash memory or a USB serial connection. The latter allows toolpaths to be easily generated using off-the-shelf CAM applications and sent to the machine via our dashboard application.
Most of the code itself was pretty straightforward, but we initially had some issues with the quality of lines being drawn by our machine. This was largely a result of our naive motion control implementation, which didn’t compensate for the nonlinear relationship between our polar motor positions and our cartesian pen coordinates.
When given two coordinates to draw a straight line between, this would result in an arc instead. Our original solution of treating longer lines as series of smaller segments (one arc becomes a series of smaller, less visible arcs) worked alright, but this method of discrete linearization had issues when we tried to increase the resolution. We ultimately approached this problem with some simple calculus, by calculating polar velocity setpoints for our system as functions of our desired cartesian velocities:
All of the electronics work was done on perfboard, and included:
- an Arduino Nano microcontroller
- two DRV8825 stepper drivers (one for x, one for theta)
- an IRLB8721 logic-level N-fet (for actuating a solenoid that lifts the pen up and down)
- connectors broken out for external switches & LEDs
We constructed our plotter out of 1/4” plywood, and used standard NEMA17 steppers for both linear and angular movement. An SMT-1325S magnetic solenoid is attached to the pen holder for the lifting motion.