Gentle edits of plotter post
This commit is contained in:
parent
bd274a6ba7
commit
eed134df58
@ -11,12 +11,12 @@ I finally decided to give in to FOMO on
|
||||
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](https://github.com/wildconceits) into
|
||||
collaberating with me. All of the work below is done with him.
|
||||
collaborating with me. All of the work below is done with him.
|
||||
|
||||
## What is a plotter anyway?
|
||||
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",
|
||||
Plotters are graphics devices that can transfer vector images onto a physical
|
||||
medium. The core mechanism of a plotter is an arm that can move a pen in 2
|
||||
axes (w.r.t the medium) and ability to pick up or place down the pen to draw.
|
||||
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.
|
||||
|
||||
@ -27,11 +27,6 @@ made working with raster images hard, and plotters didn't need much operating
|
||||
memory.
|
||||
|
||||
## HP7440A
|
||||
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 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
|
||||
@ -44,9 +39,9 @@ easy it is to open, take that 2018 tech!
|
||||
|
||||
![7440A Top cover open](/images/7440a_open.jpg){ width=600px }
|
||||
|
||||
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 switch pen down and up.
|
||||
The internal mechanism is pretty simple, There are two servos. One for
|
||||
moving the paper back and forward, and the other for moving the pen left and
|
||||
right. There is also a solenoid based lever to switch pen down and up.
|
||||
|
||||
## Talk To Me
|
||||
|
||||
@ -65,30 +60,40 @@ 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.
|
||||
|
||||
The final step was writing in the only language the plotter can
|
||||
understand, [`HP-GL`](https://en.wikipedia.org/wiki/HP-GL) or
|
||||
`HP Graphics Langauge`. Lucky for us, HP was on top of the plotter game when
|
||||
plotters were popular, so `HP-GL` has become a de facto standard
|
||||
for talking to plotters.
|
||||
|
||||
.. and finally our plotter moves!
|
||||
|
||||
<video width="600" height="450" controls>
|
||||
<source src="/images/7440a_printing.mp4" type="video/mp4">
|
||||
</video>
|
||||
|
||||
## Gooo faster.
|
||||
## Goooooooo 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 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
|
||||
the paper when the plotter is waiting for the next command.
|
||||
commands, however this made drawings really slow and added artifacts from
|
||||
ink bleeding while the plotter is waiting for the next command.
|
||||
|
||||
Another recurser Francis pointed us at the wait [function in
|
||||
hpgl.js](https://djipco.github.io/hpgl/hpgl.js.html#line1535).
|
||||
Another recurser Francis pointed us to a clever hack in the [wait function]
|
||||
in [hpgl.js]. This function uses the HPGL command `OA;` to block execution
|
||||
until the plotter is finished with the current instruction. When the plotter
|
||||
executes `OA;` it sends the current pen position, but it first needs to
|
||||
wait until the pen has stopped moving. Thus we can batch a bunch of commands
|
||||
and append it with `OA;`. As soon as we see the position over the serial,
|
||||
we know that the previous batch is consumed and we can send the next batch of commands.
|
||||
|
||||
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, 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.
|
||||
[wait function]: https://djipco.github.io/hpgl/hpgl.js.html#line1535
|
||||
[hpgl.js]: https://github.com/djipco/hpgl
|
||||
|
||||
The code for it looks like this:
|
||||
|
||||
The code for it looks like this
|
||||
```python
|
||||
import serial
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user