forked from Mr-What/DeltaUtil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gLace.pl
executable file
·116 lines (102 loc) · 3.43 KB
/
gLace.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/perl -w
# generate g-code to command a spiral
$outerRadius = 73; # mm, outer most spiral radius
$loopWidth = 10; # width of each loop, mm
$feedRate = 0.1; # mm of feed for each mm of travel
$stepDeg = 30; # degrees around circle for each line segment
print STDERR "
Usage: $0 [outerRadius=$outerRadius [loopWidth=$loopWidth [feedRate=$feedRate [stepDeg=$stepDeg]]]] > spiral.gcode
outerRadius -- mm, outer most spiral radius
loopWidth -- width of each loop, mm
feedRate -- mm of feed for each mm of travel
stepDeg -- degrees around circle for each line segment
";
$outerRadius = $ARGV[0] if ($#ARGV >= 0);
$loopWidth = $ARGV[1] if ($#ARGV >= 1);
$feedRate = $ARGV[2] if ($#ARGV >= 2);
$stepDeg = $ARGV[3] if ($#ARGV >= 3);
print "G21 ; set units to mm
G28 ; home
G90 ; use absolute coords
G1 F20000 ; go fast
G1 X0 Y0 Z14 ; move away from the probe retractor plate
G92 E0
;M82 ; use absolute distances for extrusion
M83 ; use relative distances for extrusion\n";
$pi = 3.14159264359;
print "G1 F4444 ; set print speed\n";
&printSpokes(0.1,$outerRadius-2,$stepDeg/4,$feedRate);
#&printRaster(0.2,$outerRadius-3, 3 ,$feedRate);
&printSpiral(0.3,$outerRadius ,$loopWidth,$feedRate*3,$stepDeg);
print "G1 X0 Y0 Z88
G28 ; home
M84 ; disable motors
;M104 S0 ; extruder heater off\n";
##############################################################
sub printSpiral() {
local ($z0,$ro,$lw,$fr,$sd) = @_; # height,radius,loopWidth,feedRate,step in degrees
local $r = $ro;
print "G1 X0 Y$r Z$z0 ; start spiral in\n";
local $n = int(360 * ($r / $lw) / $sd); # number of steps to trace
for(local $i=1; $i <= $n; $i++) {
local $r0 = $r;
$r -= $lw * $sd / 360;
local $dPath = ($r0+$r)*$pi*$sd/360; # aprox path len
local $e = $dPath * $fr;
local $a = $i*$sd * $pi / 180;
local $x = $r * sin($a);
local $y = $r * cos($a);
printf("G1 X%.3f Y%.3f E%.3f\n",$x,$y,$e);
}
print "G1 X0 Y0 E.1; spiral back out\n";
$r=$lw/4;
$n -= int(90/$sd);
for($i=1; $i <= $n; $i++) {
local $r0 = $r;
$r += $lw * $sd / 360;
local $dPath = ($r0+$r)*$pi*$sd/360; # aprox path len
local $e = $dPath * $fr;
local $a = -($i*$sd+180)* $pi / 180;
local $x = $r * sin($a);
local $y = $r * cos($a);
printf("G1 X%.3f Y%.3f E%.3f\n",$x,$y,$e);
}
print "G1 Z55 ; end of spiral\n";
}
sub printSpokes() {
local ($z0,$ro,$sd,$fr) = @_; # height, radius, step(deg), feedrate
print "G1 X$ro Y0 Z$z0 ; start spokes\n";
local $i=0;
local $ir = 2; # inner radius
local $e = $ro * $fr;
while ($i < 359) {
local $a = $i * $pi / 180;
printf("G1 X%.3f Y%.3f\n", $ro*cos($a), $ro*sin($a));
$i += $sd/2;
$a = $i * $pi / 180;
printf("G1 X%.3f Y%.3f E%.3f\n", $ir*cos($a), $ir*sin($a), $e);
$i += $sd/2;
$a = $i * $pi / 180;
printf("G1 X%.3f Y%.3f E%.3f\n", $ro*cos($a), $ro*sin($a), $e);
$i += $sd;
}
print "G1 Z15 ; spokes complete\n";
}
sub printRaster() {
local ($z0,$ro,$rw,$fr) = @_; # height, radius, rasterWidth, feedrate
print "G1 X0 Y$ro Z$z0 ; start raster\n";
local $y = $ro - $rw;
while ($y > -$ro + 1.1*$rw) {
local $x = sqrt($ro*$ro - $y*$y);
printf("G1 X-%.3f Y%.3f\n", $x, $y);
local $e = 2*$x * $fr;
printf("G1 X%.3f Y%.3f E%.3f\n", $x, $y, $e);
$y -= $rw;
$x = sqrt($ro*$ro - $y*$y);
printf("G1 X%.3f Y%.3f\n", $x, $y);
$e = 2*$x * $fr;
printf("G1 X-%.3f Y%.3f E%.3f\n", $x, $y, $e);
$y -= $rw;
}
print "G1 Z15 ; raster complete\n";
}