jeudi 21 juillet 2011

All downloads together

Update for Lion: PL2303 lib:
http://reg88.blogspot.com/2011/07/how-to-get-pl2303-usb-to-serial-driver.html

For convenience, all the important downloads in a list:

CNC plotter script
http://www.larsby.com/johan/?p=761

Here is our extended version of the cnc plotter script (with our simple plotter lib functions added):



Adobe Illustrator script

http://www.ricardmarxer.com/geomerative/


Edwin Jakobs plotter lib:

http://www.contrechoc.com/blogPics/plotter/HPGL-0.1.0.zip


5x7 font sketching:

basicDrawing_Plotter_5x7.pde


basic drawing for a plotter script:

basicDrawing_Plotter.pde


loading letter files for drawing "mama" (for instance)

plottingletters_loadFile.pde


Bezier plotting, single curve:

bezier curve,


You can download a sketch with the plotterlib of "BEAM" here: (also included in other examples)

plotterLibExample.pde


The schema for the connections:




and we need a driver:

http://sourceforge.net/projects/osx-pl2303/

Extending the "cnc" plotter script

We worked with a CNC script, making lines of an image.
Since the plotter can only plot lines, the script scans an image for instance horizontally, and depending on a value you can chose of brightness, starts a vertical line where the brightness is under this value and ends it where the brightness becomes above this value.
The script found on the internet uses only one direction, which is enough for milling. We extended the script for two directions, horizontal and vertical, and you can also make variable spacing between the lines.
The fun thing with plotters is that you can add several images on the paper, using different pens, so different colors. You can plot over other images.





Here you see how this plotter script makes it own version of drawings.





An image of several drawings combined together:



The Processing cnc plotter script:
http://www.contrechoc.com/blogPics/plot/cnc_plotter.zip


photo = loadImage("walkers.jpg");
drawLinesH(photo, 2, 55, 550, 50); //horizontal lines
drawLinesV(photo, 2, 65, 500, 90); //vertical lines


You have to load the image form the "data" folder of the Processing sketch
drawLinesH makes horizontal lines,
drawLinesV, vertical lines,
the second parameter is the spacing.
the third parameter is the valua at which a line starts being drawn.
The last two parameters is where the image will be positioned.

Here is the start of the function:


void drawLinesH(PImage photo, int spacing, float offsetDL, int setX, int setY)


In an extra TAB in the script are the plotter functions of our simple plotter lib.

what is important is the scaling (and rotating) of the totality of lines plotted. Every plotter has its own size and coordinates. In the function plotterLine these are visible and can be modified:


void plotterLine(float x1, float y1, float x2, float y2) {
if ( portAvailable == 1 ){
myPort.write("PU");
myPort.write("PA" + str( 10000 - x1) + "," + str(1000 + y1) +";");
myPort.write("PD");
myPort.write("PA" + str( 10000 - x2) + "," + str(1000 + y2) +";");
myPort.write("PU");
}
}

The str( 10000 - x1) means the x coordinate is mirrored and starts from 10000. This is a A3 plot format. For other plots A4, or A0 you have to change the 10000 value.

Of course you have to experiment...