header photo

Polargraph Server


An Arduino board with the polarshield, which is called Server, is the heart of the system which controls the stepper motor movements by processing a series of simple commands. Usually this commands are generated by a program called Controller which is running on a PC (a Mac OS X 10.8 in our case). These commands are either send directly over the serial port or a re autonomous processed from a SD card which sits in the polar shield. The SD card is specially a useful feature because drawing can go for hours.

The firmware need to be uploaded to the Arduino board. For Linux or Windows PC are Hex-loader available, for the Mac we have not found an easy solution. For those who just want to upload the .hex file from Sandy there is a good description in Julio Terra's blog how to do that.

Preparing Arduino

We made our very first software tests with an Arduino Duemilanove w/ ATmega328  (but no motor driver yet attached) since we had this Arduino laying on the desk, loaded polargraph_server_a1 source code (V  1.2.5) into Arduino (1.0.2) and programmed the board straight forward.

To check if the server is alive, in Arduino we opened the Tools > Serial Monitor and got:

Loaded machine width:650
Loaded machine height:650
Loaded mm per rev:65535.00
Loaded motor steps per rev:400
Loaded machine name:ÿÿÿÿÿÿÿÿ
Loaded motor step multiplier:1
Recalculated mmPerStep (163.84) and stepsPerMM (0.01)
Recalculated pageWidth in steps (3)
Recalculated pageHeight in steps (3)

That is a good start. Now you can send a few commands. Next we launched the polargraphcontroller.app, and under SETUP > SERIAL PORT... choose the right serial port (in our case /dev/tty.usbserial-A700ewvG). On the top line of the screen we get a Polargraph READY! (Uno).

In the meantime we got the Arduino ATmega2560, flashed it the same way with the polargraph_server_polarshield (V 1.2.5), connected the polarshield and had immediately everything running.

That was straight forward, KUDOS to Sandy. Next step is to finally connect the motors.

The Pitfalls

Now, as it turned out, to have a running hardware does not mean we can actually draw anything yet. We had issues with the hardware, but Sandy is quick in helping and at last we learn a lot.

First we got a mysterious bug which turned down the speed of the vector drawing to a ridiculous low speed. But somehow that bug mysteriously disappeared, and if a error is not reproducible, once can not fix it.

Second we run into problems with oscillating stepper motors. For the moment we use a variable power supply which we keep at about 8 Volt. And since we measure up to 50 °C temperature on the stepper, we still keep an eye on it.

That said, now after playing for a while we get more and more confident with this machine and enjoy it.

The Polarshield

The Polarshield allows to read data from a SD card, so no running computer is needed. Which is very handy since the drawing can last hours or days. So you can switch off your computer and significantly reduce the carbon footprint of your graphic. Here is how to do it:

  1. In the controller programm, first CLEAR QUEUE, then make sure that the first command is a SET HOME.
  2. Now you have to have the CommandQueue paused or the server disconnected because you do not want to send the commands directly to the server. Then generate the command sequence with RENDER PIXELS... or DRAW VECTORS and EXPORT QUEUE to a file. Arduino can only read those short 8.3 file names as we had it in the good old DOS times.
  3. Additionally on OS X I run a small bash script which cleans my SD card from all those "dot" files which OS X sparkles all over your storage media.
  4. Insert the SD card into the server and reset it, because only after reset the server reads the cards directory.
  5. Move the gondola to the home position, then press MOTORS ON to lock them. In case you do not have the SET HOME command in your command file, you have to issue this command now manually, therwise the server has no idea where the gondola actually stays.
  6. Finally choose the file on the SC card and press DRAW FROM SD to get it going.

Here is the schematic of the Polarshield.

Here we add some more technical background information as we dig deeper into the Arduino code. Just to operate the Polargraph this information is not needed. The setup we are using here is our Arduino Duemilanove w/ ATmega328 and a Adafruit Motor/Stepper/Servo Shield for Arduino kit - v1.2 with some arbitrary stepper bipolar motor with a step angle of 1.8°. A short introduction into stepper motors is here.

The Arduino code

When we first started to try to compile the Arduio polargraph_server_polarshield it not clear to me which libraries for the stepper motor and the touch screen are used. Now, with the version 1.2.5 the following libraries are included:

a) The libraries for the stepper are:

  • AFMotor
  • AccelStepper, should generate more then 4Ksteps/s.

b) The libraries for the touch screen are:

  • UTFT
  • UTouch (Sandy: I have moved to using the new UTouch libraries instead of the ITDB02_Touch ones (more or less the same)).