TrotecHPGL

From ZB45 wiki

The Trotec Speedy 100 can speak HPGL:

19200 baud, 8bit, no parity, 1 stopbit, flowcontrol XON/XOFF

All parameters are integer values, no decimal point and no digits behind are allowed

To execute Commands “EC” command has to be used

AA x,y,α	Arc Absolute
		x,y = middelpunt 
		α = hoek in 1/100 graad, [-36000 tot 36000]
AI 		Analog Input List
		???????
AL		Analog Output List
AO		Automatic Power Correction Off
AP		Automatic Power Correction On
AR dx,dy,α	Arc Relative (zie AA)
AV n		Acceleration Vectors 
		n = 1 .. 9 Accelleratie waarde voor vectoren
CA α		Switch Improved Connect Criteria
		α = [0..4500] default 1500
CM		Connect Moves ON
		Connect linear movements
CO		Connect Moves OFF
DI		Get Digital Input List
DS		Set Analog Output
		number [0-3], value [0-10000]
EC		Execute Commands
ED n		External device ON
		n = 3: Exhaust 
		n = 4: Air Assist
EO n		External device OFF
GQ		returns free Command Queue Entries (max 10000)
GS		Get machine status
		0 = Idle
		1 = busy
		2 = pause
		3 = abort
		4 = standby
		5 = service
		6 = back_ref_pause
GX		Get current Position X
GY		Get current Position Y
GZ		Get current Position Z
LC n		Laser Minimum Correction Power
		n = [0..10000] percentage of actually selected laser power
		Maak vermogen lager aan de hand van de snelheid tov
		het ingestelde vermogen. LC is de treshold bij lage
		snelheid
LD n		Laser Test Power n = [0..10000]
		Set power for laser test pulse 
LF n		Laser frequency n = [1..10000]
		Sets laser pulse frequency
LP n		Laser Power n= [1..10000]
		Sets laser power
PA x,y		Plot Absolute
		Move to position x,y
PD		Pen Down  = Laser on
PE		Plot Absolute Offset Enable
		Set current position as offset for absolute positioning
PO		Plot Absolute Offset Disable
		Disable advanced relative positioning
PR dx,dy	Move relative dx,dy
PU		Pen Up = Laser off
RR n		Set Rotary Resolution in [nm]
RY		Test ready
		Returns OK on serial to signal that laser is idle after processing HPGL commands
SL n		Set Laser Source
		default = YAG, dus altijd beginnen met "SL 0"
		==> set source to CO2
TA n		Tickle Dead Time [1..1000] in microseconden
TB n		Tickle Frequency [1000..10000] in Hz
TC n		Tickle power [0..1000] = max 10%
VL n		Maximum vector speed
		Speedy: 1,0 m/s = VL200000
VS n		Velocity Select
		Speedy: 1,0 m/s = VL200000
		sets speed for succeeding PA or PR commands
WA n		Wait for n ms until the next hpgl command is executed
ZP z		Z-Axis Absolute Position [0..26667]
ZR dz		Z-Axis Relative Position [0..26667]
ZS n		Set z-axis speed [0..9000]
		3000 inc/sec = 135mm/min (default)

Speedy 100 specs

xy Resolution: 5 micrometer/increment (5080 Increments/Inch of 200 Increments / mm)
z Resolution: 0.167 micrometer/increment
Max X increments: 126600
Max Y increments: 62600
Max Z increments: 1017964
Max Velocity inc/s: 160000
Laser source (SL): 0 

Offset between machine area and working area
default X 13mm=2600 increments,
default Y 4mm= 800 inc
==> so you should move out of the corner first!


Perl script to send standard Inkscape HPGL file to the Trotec

#!/usr/bin/perl
use strict;
my @code;
open (IN, "drawing.hpgl");
foreach (<IN>) {
    foreach my $line (split(/;/)) {
        chomp($line);
        if (($line ne "") && ($line ne "SP1") && ($line ne "IN")) {
            push(@code, $line);
        }
    }
}
close IN;
print"ED3
ED4
AP
AR1
CA1500
CM
LC20
LF1000
LP10000
SL0
TA100
TB1000
TC100
VL160000
VS100000
EC
WA1000
EC
";
my $state = 0;
my $cnt = 0;
foreach my $line (@code) {
    if (($state == 0) && ($line =~ /^PD/)) {
        $state = 1;
        print "PD\n";
    }
    if (($state == 1) && ($line =~ /^PU/)) {
        $state = 0;
        print "PU\nEC\n";
        $cnt = 0;
    }
    if (($line =~ /^PU/) || ($line =~ /^PD/)) {
        $line =~ s/^P.//;
        (my $x, my$y) = split(/,/, $line);
        $x .= "0";
        $y .= "0";
        print "PA$x,$y\n";
    } else {
        print "$line\n";
    }
    $cnt++;
    if ($cnt > 1000) {
        print "EC\n";
        $cnt = 0;
    }
}
print "EC
PA0,0
EO4
EC
WA1000
EO3
EC
";