Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8051

Other projects • Re: Plotter drawing

$
0
0
You have a very nice friend!

If you're lucky, the direct USB connection will create a serial port when you connect the plotter. Look at the output of dmesg to see what kind of tty it has created. Some of them use a parallel device, or emulate one via USB connection.

Inkscape can write HP-GL directly to a plotter. It can sometimes take a little work to get the parameters just right. If you get lots of dropped lines on your plot, it's probably something to do with serial flow control.

I've been using plotters for years. Roland plotters like this tend to use HP-GL, a very simple text-based drawing language. The command your plotter supports might include clever things like curves and filled shapes, but at the most basic, all you really need are:
  • IN — initialize. Typically used at the start of a plot
  • SPn — select pen, n = 1..8 (typically). SP0 unloads the pen, useful at the end of the plot
  • PUx,y — move pen to x,y. If no arguments given, lifts the pen. Also known as Pen Up
  • PDx,y — draw to x,y. If no arguments given, lowers the pen. Also known as Pen Down. You can add many x,y pairs separated by commas to draw a line string.
Default units are 1/40 mm (which are also exactly 1/1016 inches). Commands are usually terminated by ;

Example (boring, sorry): 10 x 10 cm square, offset (1, 1) cm from page corner, using pen #1:

Code:

IN;SP1;PU400,400;PD4400,400;PD4400,4400;PD400,4400;PD400,400;PU;SP0;
While the plotter will support more clever commands, you can get by with knowing these.

I tend to think in BASIC, so this next one is written in that language:

Code:

100 REM draws rotated triangles - scruss, 2025-04110 PRINT "IN;SP1;";120 r=80 : REM plot radius, mm130 REM page centre (for A4), mm140 cx=210/2150 cy=297/2160 FOR i=0 TO 360 STEP 5170 REM move to triangle corner at angle i180 PRINT "PU";int(40*(cx+r*cos(rad(i))));",";int(40*(cy+r*sin(rad(i))));";"190 REM draw lines to triangle corners at angles i+120, i+240 and i200 PRINT "PD";int(40*(cx+r*cos(rad(120+i))));",";int(40*(cy+r*sin(rad(120+i))));",";int(40*(cx+r*cos(rad(240+i))));",";int(40*(cy+r*sin(rad(240+i))));",";int(40*(cx+r*cos(rad(i))));",";int(40*(cy+r*sin(rad(i))));";"210 r=r/1.05 : REM make triangle smaller by 5%220 NEXT i230 PRINT "PU;SP0;"240 END
It draws something that looks like this:
rotatey.png
I've uploaded the plot file to my own host if you want to try plotting it: rotatey.zip

Statistics: Posted by scruss — Fri Apr 25, 2025 6:42 pm



Viewing all articles
Browse latest Browse all 8051

Trending Articles