Gocupi

Polargraph (vertical plotter / drawing machine) written in Go

Download as .zip Download as .tar.gz View on GitHub

Polargraph (vertical plotter / drawing machine) written in Go. Inspired by Polargraph and drawbot projects, designed with the help of the Dallas Makerspace

Gocupi is different from existing systems in that it uses a Raspberry Pi to do most of the processing instead of relying on a microcontroller to parse commands. This gives it the ability to render complex svg files and patterns that would not fit in memory on a microcontroller.

Get your own Gocupi

A kickstarter campaign will be starting soon to allow you to get a prebuilt Gocupi. More information will be available at gocupi.com

What is a polargraph?

Two stepper motors move a pen hanging from threads to draw stuff out on a whiteboard or any vertical surface. A program written in Go runs on the Pi, it sends movement commands over serial to an arduino, which then pulses the step pin on the stepper drivers to make the stepper motors move.

This project is different from most other Polargraphs in that there is no step generation code on the arduino, everything is calculated in Go and then the arduino just receives a stream of step deltas that it stores in a memory buffer and then executes. Since all logic is written in Go running on the Pi it allows using more advanced interpolation models for smooth drawing, not needing to use fixed point or single precision floats for calculations, not needing to reflash the arduino often when making code changes, etc.

Design description

In the Go program, there are several channels that form a pipeline where separate functions execute the different pipeline stages. All of the stages are run in different goroutines so that they execute concurrently.

In order to generate single line art drawings(like the raspberry pi & gopher logo shown above) I followed the makerbot and eggbot tutorials which show how to convert a grayscale image to a stippled image to a path to an svg file.

Interpolation

The system uses simple trapezoid based velocity to move the gondola smoothly. During interpolation there are three phases, acceleration at a constant rate, cruising at a constant speed, and decelerating at a constant rate. It handles the edge cases where you don't have enough distance to accelerate or decelerate fully.

For each line segment it is about to draw it calculates the angle turn at the end of the segment to the next line segment to determine the target exit speed. Ie if it has to make a 90 degree turn, then it wants to come to a stop at the end of the current line segment, if it isn't turning and just going straight then it doesn't need to slow down at all.

In that chart you can see the constant acceleration phase as velocity is increasing, and then the velocity of the pen in the cartesian coordinate system is constant. The reason for the steps in velocity is because of the instantaneous changes in direction between line segments. Even though it does slow down to make a turn it does not stop completly for every turn.

In this chart there is not enough distance to reach the target velocity, so there is only an acceleration and then deceleration phase. It is making 90 degree turns, that is why the velocity goes to 0 between each line segment. The thickness of the velocity lines is due to the limited resolution of the stepper motors, which are running at 1/8 microsteps, and the arduino interpolates to a precision of 1/32 of a microstep.