~dbalan/blogng unlisted

bd274a6ba70723f1e4ae503f24f7e8d5dd5a992d — Dhananjay Balan 1 year, 10 months ago 5a4058c
Draft 1.
1 files changed, 39 insertions(+), 36 deletions(-)

M blog/2019-02-23-resurracting-an-hp-7440a-plotter.markdown
M blog/2019-02-23-resurracting-an-hp-7440a-plotter.markdown => blog/2019-02-23-resurracting-an-hp-7440a-plotter.markdown +39 -36
@@ 6,61 6,64 @@ comments: true
tags: plotter, art, python, hardware, recurse
---

I finally decided to give in to the FOMO of
I finally decided to give in to FOMO on
[#plottertwitter](https://twitter.com/hashtag/plottertwitter?lang=en) and bought
an old plotter off ebay. Me being in batch at [Recurse
Center](https://recurse.com) helped a lot, from the decision to get one to
[nerdsnipe](https://xkcd.com/356/) Alex into collaberating with me. All of this
work below is done with him.
[nerdsnipe](https://xkcd.com/356/) [Alex](https://github.com/wildconceits) into
collaberating with me. All of the work below is done with him.

## What is a plotter anyway?
Plotters are devices that can transfer vector graphics onto to a physical
medium. Core of a plotter is the arm that can move in 2 axes around the medium,
and ability to put the pen "Down" (draw) and "Up", to position before starting
to draw. Versions of plotters exist where paper is replaced with other flat
materials like vinyl and pen with a knife to cut rather than to draw.
Plotters are graphics devices that can transfer vectors onto to a physical
medium. Core mechanism of a plotter consists of an arm that can move pen in 2
axes (w.r.t the medium) and ability to put the pen "Down" (draw) and "Up",
Versions of plotters exist where paper is replaced with other flat materials
like vinyl or pen with a knife to make it a cutting plotter.

I like to think plotters as the naive solution to the problem that computers
should be able to draw. Smaller, expensive memory chips (or [magnetic
cores](https://en.wikipedia.org/wiki/Magnetic-core_memory)) in earlier computers
made working with raster images hard.
made working with raster images hard, and plotters didn't need much operating
memory.

## HP7440A 
HP was on top of the plotter game when they were popular, so much
HP was on top of the plotter game when plotters were popular, so much
that other manufacturers started to support
[`HP-GL`](https://en.wikipedia.org/wiki/HP-GL) (short for `HP Graphics
Langauge`) as the way to talk to their plotters as well.

HP7440A _"ColorPro"_ was an affordable plotter produced by HP, it can hold 8
pens at the same time and switch between them automatically and draw on surfaces
as large as A4. [HP Museum has a longer post about this
HP7440A _"ColorPro"_ was an affordable plotter manufactured by HP, it can hold
and switch between 8 pens simultaneously and draw on surfaces as large as A4.
[HP Museum has a longer post about this
plotter](http://hpmuseum.net/display_item.php?hw=80)

Ours came pretty unscathed, with the original manuals!
Ours came pretty unscathed, with original manuals!

First thing we did was to open it and clean it. I was quite surprised by how
First thing we did was to open and clean it. I was quite surprised by how
easy it is to open, take that 2018 tech!

![7440 open](/images/7440a_open.jpg){ width=600px }
![7440A Top cover open](/images/7440a_open.jpg){ width=600px }

Internal mechanism is pretty simple, There is two servos. One for moving paper
Internal mechanism is pretty simple, There are two servos. One for moving paper
back and forward, and one for moving the pen left and right. There is also a
solenoid based lever to put the pen down and up. 
solenoid based lever to switch pen down and up. 

## Talk To Me

![7440 interface](/images/7440a_interface.jpg){ width=600px }
![7440A Interfaces](/images/7440a_interface.jpg){ width=600px }

However, our plotter didn't come with any cables to either power it or to send
commands. Power was the biggest mystery <power picture>
commands. 

After digging through the manuals, and the [hand drawn schematics from HP
Museum](http://hpmuseum.net/exhibit.php?hwdoc=80), we managed to identify power
supply to be a `10-0-10` AC to AC. Luckily someone was selling one in ebay, but
we couldve built one ourselves if not.
Power supply was the biggest mystery. After digging through the manuals, and the
[hand drawn schematics from HP
Museum](http://hpmuseum.net/exhibit.php?hwdoc=80), we managed to identify it to
be a `10-0-10` AC to AC. Luckily someone was selling one in ebay, but we could've
built one ourselves if not.

Communication turns out be standard serial, however our plotter has a `DB-22`
adaptor, so we had to use a `DB-22` to `DB-9` and `DB-9` to `usb` adaptor.
Communication turned out be just standard serial, however our plotter has a
`DB-22` adaptor, so we had to use a `DB-22` to `DB-9` adpator and then `DB-9` to
`usb` adaptor.

.. and finally our plotter moves!



@@ 70,9 73,8 @@ adaptor, so we had to use a `DB-22` to `DB-9` and `DB-9` to `usb` adaptor.

## Gooo faster.

HP7440A has a limited amount of buffer space (about 60 bytes), so if we send a
longer command list to the interface, it will just drop the overflow bits and
stop to respond.
HP7440A has a limited amount of buffer space (about `60 bytes`), so if we send a
longer command list to the interface, it will just drop bits after 60 and crash.

Our first naive solution was to add `1s` sleep between sending subsequent
commands, however this made drawings really slow and there was ink bleeding on


@@ 83,7 85,7 @@ hpgl.js](https://djipco.github.io/hpgl/hpgl.js.html#line1535).

It is a clever hack, the idea is to send the HPGL command `OA` as a marker, `OA`
sends the current pen position back from plotter, so we batch a bunch of
commands, suffix it with `OA`, and as soon as we see the position on the line,
commands, append it with `OA;`, and as soon as we see the position on the line,
we know that the current set is consumed and we can send the next batch again.

The code for it looks like this


@@ 146,7 148,7 @@ A re-reading of the manual made us realize HP sold these functionality as an
[hardware adaptor board that plugs in the
bottom](https://support.hp.com/us-en/document/bpp01354), which we don't have.

But everything in computer graphics is a line anyway right? With some [root of
But everything in computer graphics is a line anyway, right? With some [root of
unity](http://mathworld.wolfram.com/RootofUnity.html) math, we came up with a circle
drawing routine.



@@ 156,15 158,16 @@ drawing routine.

## This is only the beginning

Hardware wise, the only thing remaining to fix is our pens, which expired in
Hardware wise, only thing remaining to fix is our pens, which expired in
1996! We are yet to come up with a strategy to refill/replace them.

![Plotter Pen](/images/7440a_pens.jpg){ width=600px }

I am also going to leave this plotter at RC, so that other recursers continue
hacking on it, and get another one for me and actually to some generative art.
:-)
I am also going to leave this plotter at RC, so that other recursers can
continue hacking on it, and get another one for me and actually do some
generative art. :-)

## Notes
1. Big thanks for Amy and Francis and Alex S for their help at various points.
1. Big thanks to Amy and Francis and Alex S for their help at various points.
2. All of our python code is here: [https://github.com/dbalan/plotter-scripts](https://github.com/dbalan/plotter-scripts)
3. Thanks Tom for proof reading this post!