The manatee watches...

Jul 23, 2011

GPGL Reference, Courtesy of Graphtec

I recently purchased as cutting plotter for myself as a fun toy to play with. In particular, I picked up Graphtec's Silhouette machine from US Cutter for a very reasonable price.

Now, being the computer nerd that I am, one of my first inclinations, after seeing the device in action, was wondering how I could control the device directly myself. That is to say, I didn't want to have to import my files into the Silhouette Studio software for every drawing I wanted to make; in particular because I run Linux on my personal desktop, and there is no Linux version of the software available.

After a short bit of research, I discovered that the device communicates via Graphtec's proprietary "GPGL" language, (it stands for Graphtec Plotter Graphics Language, I believe). This is in contrast with the more common HPGL specification found in many other plotters. I did a significant amount of searching on the matter, but came up empty handed when it came to GPGL references. I read some sites that suggested that the Silhouette also communicated via HPGL, but my tests with that came up largely empty.

So, I sent a kindly worded email to Graphtec support asking if they could provide a reference directly. I didn't expect a response back and had resigned myself to the tribulations of USB sniffing. I spent the day, in between work, investigating how to perform USB packet logging on both OS X and Windows (hint: use Windows).

And then, just when I was about to really dive in and start doing it the hard way, Graphtec came through for me. A wonderful gentleman named Neil emailed me back:

Hi Dave, Thank you for your interest in Graphtec products. I have attached the HPGL and GPGL command sets found in Graphtec cutters for your reference. The reference documents are provided "as is" and we cannot provide additional assistance. I wish you good luck with your endeavor. Best regards, Neil

Here are the documents he sent:

Just like that, I had what I needed! I may or may not have responded back to Neil with professions of love and adulation. I also asked for some quick clarification on one, undocumented point: how does one switch the plotter between GPGL and HPGL mode? He promptly responded back:

My understanding is that the newer Graphtec FC8000 have the capability to autoswitch when they receive either GPGL or HPGL commands, but previous cutters such as the CE5000-40 (Craft Robo Pro) require the user to change the command language from the front panel to match incoming data.

The Silhouette does not have an option to manually switch between the two specifications, and in my testing, it does not seem as though the Silhouette automatically switches into HPGL mode either (perhaps someone can correct me on this). That being said, it does seem to be responding to GPGL commands.

I am still feeling my way around the spec a bit — the Silhouette is not responding to every command documented in the pdf, and some combinations of commands seem to cause the Silhouette to stop responding. I suspect part of this may be due to my naivety when it comes to USB programming in general, something I am new at.

To help confirm this, I installed a USB sniffer on my wife's Windows computer, along with with Silhouette Studio software. I had the plotter draw out two simple lines, each about the length of the page. Here is the primary data payload that I saw sent back and forth (in hex):

03 21 31 30 2c 30 03 54 54 03 48 03 54 42 35 30 2c 31 03 54 42 35 30 2c 30 03 46 43 30 03 54 42 39 39 03 46 4d 31 03 54 42 35 30 2c 31 03 46 4f 35 35 38 37 03 26 31 30 30 2c 31 30 30 2c 31 30 30 03 5c 33 30 2c 33 30 03 5a 34 31 32 30 2c 35 35 35 38 03 46 58 31 30 2c 30 03 4c 30 03 4d 35 30 38 2c 35 39 35 03 44 39 33 33 2c 34 31 36 39 03 4d 32 38 35 31 2c 34 35 30 34 03 44 33 38 35 36 2c 34 39 36 03 26 31 2c 31 2c 31 03 54 42 35 30 2c 30 03 46 4f 30 03 48 03 03

This can be converted into ASCII as:

\x03!10,0\x03TT\x03H\x03TB50\x031\x03TB50,0\x03FC0\x03TB99\x03FM1\x03TB50,1\x03FO5587\x03&100,100,100\x03\\30,30\x03Z4120,5558\x03FX10,0\x03L0\x03M508,595\x03D933,4169\x03M2851,4504\x03D3856,496\x03&1,1,1\x03TB50,0\x03FO0\x03H\x03\x03

The first thing I noticed was that the software was sending ASCII character 3, (end of text) instead of semicolons. Then, I looked for the commands that would have drawn the two lines. They are buried in there as "M508,595;D933,4169;M2851,4504;D3856,496;" (semicolons substituted for EOT). Everything else is setup and teardown for the process. I am still working to decipher the exact meaning of some of the commands: things like "TT;", "TB50,0;", "FM1;", "\\30,30;", and "FO0;" are not listed in the provided documentation, and other commands, such as "Z4120,5588;"and "&100,100,100;" do not convey their meaning well to me (I think Z specifies the overall page size).

So, I still have some more tinkering to do, but at least I have an awesome starting point! I thought I should share what I have so that others can find it in the future. Here is a table of all the GPGL commands for quick searching and reference:

Command Description Format
D Draw Dx1,y1,x2,y2,...xn,yn[t]
E Relative Draw Ex1,y1,x2,y2,...xn,yn[t]
M Move Mx,y
O Relative Move Ox,y
MP Move Polar MPr,θ[t]
DP Draw Polar DPr1,θ1,r2,θ2,...rn,θn[t]
EP Relative Draw Polar EPr1,θ1t
OP Relative Move Polar MPr1,θ1t
RP Radius Plot RPθ,l1,l2
L Line Type Lp
B Line Scale Bl
$ Font $n,(m)
S Alpha Scale Sn,(m)
Q Alpha Space Ql(k)
R Alpha Rotate
I Alpha Italic Ip
LP Label Position LPn[t]
A Alpha Reset A
RC Replot Character RCc,x1,y1,[P,]x2,y2,[P1,]...xn,yn[t]
H Home H
^ Offset ^x,y
^P Offset Polar ^Px,y[,θdegrees[f][t]]
J New Pen Jn,(m)
! Speed !l[,n][t]
* Pen Acceleration & Force *a,f[,n][t]
FC Cutter Offset FCp,q[,n][t]
FD Blade Rotation Control FDθ[t]
\ Write Lower Left \x,y
Z Write Upper Right Zx,y
/ Rotate /x,y,θ
> Clipping >x1,y1,x2,y2,...xn,yn[t]
& Factor &p,q,r
SO Set Origin SOn
T Buzzer Tn
F Chart Feed Fl[t]
G Gin G
C Call Gin C
? Read Offset ?
[ Read Lower Left [
U Read Upper Right U
V Read Status Word1 V
@ Read Status Word2 @
# Read Status Word3 #
= Term =t1,t2
" Error Mask "m
: Clear :
; Interface Clear ;
BS Buffer Size BSs1,s2,s3,s4
X Axis Xp,q,r[,t1,t2][t]
% Hatching %n,x,y,d,θ[t]
(n=1...3)
%n,r1,r2,θ1,θ2,d,θ[t]
(n=11...13)
%n,d,θ,x1,y1,...xn,yn[t]
(n=21..23)
comments powered by Disqus

Projects

Tags