For our most recent office hackday Taylan, Yiğit and I decided to build a wall drawing robot.

We independently came across wall drawing robots in San Francisco and Istanbul and immediately thought "We have to build one of those... someday!". Given that our office has a huge blackboard wall on the entrance level we figured it was a perfect office hack day project.

# Background

So what is a wall drawing robot? Quite literally it is a robot that draws on a wall or other flat vertical surface. Usually this consists of a pen suspended from two strings, each connected to a motor that winds it up and down. Sometimes they are referred to as drawbots, vertical plotters or V-plotters in reference to both the vertical surface and the V shape made by the strings. In reality it is no more a robot than a normal printer but it appears to have a mind of its own when in action so robot seems quite fitting. Given that our machine would draw on a blackboard surface using chalk we named it ChalkBot.

Although I first came across the idea at the 2012 Istanbul Design Biennial with a bot meticulously 'hand' writing and editing an Open Source Architecture Manifesto, the idea has been around for quite a while with the first documented version in a SIGGRAPH video from 1988. Most recent versions however credit Jurg Lehni’s Hektor for their inspiration.

# Theory

The basic operation of a drawbot is quite simple. Then pen is moved across the surface by adjusting the lengths of string. To move upwards towards the left we wind up the left string. To move upwards to the right we wind the right string. Drawing a picture is simply a case of moving the pen along the path of a set of coordinates.

To know how much and which direction to wind the strings we need to know where the pen is and where we want to move it to. This involves a little bit of trigonometry. We need to define two operations; one to tell us the pen position given the two string lengths and one to tell us the required string lengths for a given pen position.

There are a number of ways we can calculate these using basic geometry and trigonometry. If we imagine our pen hanging from two motors at the top corners of a wall we can see that it creates a triangle. The height of this triangle is our $y$ (vertical) coordinate. We use Heron's Formula to get the area of this triangle using the three side lengths we know:
$$s = \frac{(a + b + c)}{2}$$ $$x = \sqrt{s1^2 - y^2}$$

Then we find the height of the triangle, knowing that $area = \frac{base \times height}{2}$. $$y = \frac{area}{width \times 0.5}$$

If we draw an imaginary horizontal line at the pen we see that we create two right angled triangles on either side. The length of the bottom side of the left triangle is our $x$ coordinate. Using Pythagoras we can calculate this side because we know the length of the hypotenuse (the length of the left string) and the vertical side (the same as our $y$ coordinate). Therefore $x = \sqrt{s1^2 - y^2}$.

Now we have a method to find our pen position given the length of the two strings. To find the string lengths for a given pen position is even simpler. Again we consider the two imaginary triangles formed by the string and frame. The $x$ and $y$ coordinates give us the opposite and adjacent sides so we can use Pythagoras again to find the hypotenuse which is the length of the string.

To actually draw something we convert the drawing to a list of coordinates and move the pen from one coordinate to the next. To move the pen to the next position we calculate the new coordinates using the function we just defined to find the string lengths. Then we calculate the number of steps each motor needs to turn to reach the new string lengths. Finally we command the motors to turn the required number of steps. In order to get smooth lines we want both motors to step at the same time. Unfortunately this complicates things a bit so we compromise by turning each motor a small amount in turn until they have both turned the required amount.

# The Software

Once we understood the theory of how all this should work it was time to actually build something. However, being a software engineer, of course I built the software and a simulator first instead of diving into the electronics and hardware. For the software I split it into three separate parts; a program to convert a SVG image into a list of coordinates, a program to output a set of motor commands from the coordinate list and a program to simulate the motor operations and render the strings, pen and drawing as a sequence of images. The simulator allowed us to experiment and debug the system before we even bought the hardware.

The main program consists of the two functions we defined above and a memory of the string lengths and pen position. The output is a text file of motor commands like ML+1 which means "turn the left motor 1 step forward". The simulator reads this file and updates its own virtual strings and pen position using the same functions defined earlier. To simulate the drawing it adds a straight line between the previous and current position on its virtual canvas. After each command a new frame is rendered using the Python Imaging Library.

Below is an animation of the simulation our Hipo Logo.

# The Hardware

As mentioned above the basic components of a drawbot are stepper motors, string and a pen. Additionally spools are required to attach to the motors to wind the string around, and a holder of some sort to attach the strings to the pen. Finally a controller is needed for the motors.

## Component List

• Controller: We decided to use an Arduino Uno as the controller

• Stepper Motors: 2 NEMA 14 stepper motors, each with its own driver board and power supply.

• Spools: For spools we searched far and wide online and offline to find something compatible with the motors but eventually had to settle for some toy car wheels which we Dremeled to them make fit the motor shafts snugly.

• String: The string needs to be both lightweight and non-stretching so we choose some fine fishing line.

• Ballast: Some fishing weights to use as ballast to hold the pen steady.

• Pen: As we wanted to draw on a blackboard we needed to use chalk but to make things easier we went with a liquid chalk pen which requires little pressure to draw nice smooth lines and doesn't break like a normal chalk stick.

• Pen holder: For our pen holder we used a large binder clip.

• Drawing Surface: Finally for our drawing surface we planned to use our huge blackboard wall but for the hackday we decided to build on a smaller scale rather than have to climb a ladder every time we needed to fiddle with a motor so we asked a local carpenter to build a free-standing board for us to use as a prototype.

After putting it all together we had our ChalkBot physically complete, ready for its first masterpiece. The only task left was to write the code for the Arduino to step the motors in response to the commands output by our main program, just like the simulator.

# The Controller

A stepper motor is driven by turning on and off its electrical coils in specific pattern. Thankfully the driver circuit takes care of the complicated switching for us. We just need to send electrical signals to the driver pins to control the motor. One pin enables/disables the motor, one sets the direction and the other turns the motor step by step in response to an electrical pulse. The frequency of the pulses determines the speed that the motor will turn. On the Arduino we can create such a pulse with a loop that sets the pin output to High, waits for a few microseconds, sets it to Low, waits again and repeats:

for (int i=0; i< 200; i++){
digitalWrite(motorPin, HIGH);
delayMicroseconds(300);
digitalWrite(motorPin, LOW);
delayMicroseconds(300);
}


The rest of our controller code just reads commands from the serial port and decides which pin to write to and which direction to set. One neat trick we used is writing the command back to the serial port after it has been executed. This acts as an acknowledgement useful for debugging and also signals to the other program that it is ready to receive another command.

# Demo Time

For our first test, we of course wanted to draw our Hipo logo. After setting up the program for the dimensions of our board and distance between motor center points we input our logo coordinates to get our commands file to send over serial to the Arduino. First we ran it through the simulator just to make sure everything looked OK. Pff, of course it did.

Then we started sending commands over serial to the Arduino, expecting to see our beautiful hippo slowly emerge in chalk. Unsurprisingly, it didn't! It indeed drew some lines in one direction, then another, and then proceeded to draw towards the edge of the board, stretching the strings to their limits until we killed the power. Well, that was to be expected after all. We tried a few more times but time was running out. By the end of the hackday we did manage to make a demo of a spiral drawing by hacking some loops together.

While we were disappointed not to reach our goal of drawing our hippo by the end of the day we were still quite satisfied to actually get anything drawn after starting the day with some parts and an idea!

A few days later I gave it another try and realised we had our left and right mixed up and also that the direction of one motor needed to be reversed. Once I made these fixes we got something much more closely resembling our hippo and finally after adjusting the step size and timings we got a near perfect rendition.

# Next Steps

Now that we have all the components working together and responding correctly to our commands we plan to rebuild it in the originally intended location on our entrance floor. We also plan to integrate a solenoid to allow the pen/chalk to automatically lift off the board. This would allow us to do more complicated drawings with multiple independent lines. Ideally we would like to find a way to erase our drawings too so that the robot could continuously draw and erase all day long. You can keep an eye on our progress through the ChalkBot GitHub repo.