martedì 13 ottobre 2009

Re: building some LEGO pin-plotter

Hi Michael.

The pin-plotter software is already available on the same web page (search for "NXC source"). Anyways, software acts like this:

a) decode the bitmap, creating a matrix of data like this:
0 1 0 0 0 0 0 1 0
0 0 1 0 0 0 1 0 0
0 0 0 1 0 1 0 0 0
0 0 0 0 1 0 0 0 0
That is, every row contains "1" for "colored pixels" and "0" for "no color / no hole" pixel (the example above contains a "V" graphic sign).

b) align the plotter head to first row, first column (first printable pixel)

c1) for every row of the matrix: align to next row of the plotting area, and:
c2) for every column of the matrix: advance to next plotter position and:
c3) make a hole if there was a "1" in the corresponding position of the matrix
-repeat to c2 until the end of the row
-repeat to c1 until all rows are completed

While conceptually simple, the software listing is somewhat large because:

- it has parametrized borders (XOFFSET, XUNITS, XPOWER etc) so that if I change the tracks or the slider structure or the gears on the motors, I only have to change those values instead of the entire program;

- it has some pauses (XPAUSE, etc) to let the moving tool "stabilize" from vibrations (one cannot expect that starting-moving-braking suddenly and sturdily stops the moving tool); it also selects "coasting" instead of "braking" in some other cases (to reduce stress on motors and vibrations)

- it has some battery control (if voltage drops below a certain amount, do not continue, because you may find yourself halted in a hole, and it will be hard to restart without damaging the already plotted area)

- the "bitmap processing" is somewhat complex (decode a ".PBM" graphics file into an array of 0/1 values, read from a file, check errors, etc); I did not use JPEG/GIF/PNG formats because it is not needed to have such beasts for a less than 10,000 pixels drawing). Also, the common xpaint program (known on Linux/Unix environments since decades) allows to draw them on a large "grid" and save directly in PPM/PBM format

- finally, it shows some status output on the screen while processing (something like "1737 pixels, 83.2% done, row 103, 1 minute 08 seconds..."

I think it's easier to rewrite it from scratch, having in mind the exact characteristics of the machine you will create.

Building such a machine made me learn a number of things about achieving precision, demultiplication in gears, transmission, taking advantage of gravity (this is why I placed the heavy NXT unit on the moving tool), reducing small oscillations, friction problems, etc, which I already described in the project page (its name is "pin-plotter III" because it was the third time I fully rebuilt it from scratch, learning from my own errors; the second time I tried to print out a larger area, but I had to fight too much with elasticity and strength of the paper sheets...!

Note: I built it using parts from different Technic sets (for example, I had to use three touch-sensors, but in an NXT box you only find one).

Also note that a similar design could be used for other plotting styles: using a pen/pencil instead of a needle, using a different material instead of ink/needle (such as sand/wheat/etc).

I have some plans for a CNC-mill machine, but it will require more than three motors (so I will have to use at least two NXT). The real problem is the material to use... :-)

Nessun commento:

Posta un commento