gp2rml/gp2rml.c (output_paths): use PA when possible; correct speed calculation

The mill uses the Z speed for the entire !ZZ movement, whether there
is a Z component or not. We now issue PA instead of !ZZ when moving
horizontally.

Also adapted the speed calculating accordingly.
This commit is contained in:
Werner Almesberger 2015-07-22 20:15:45 -03:00
parent d72d649c30
commit 4153e6b4e2
1 changed files with 12 additions and 6 deletions

View File

@ -133,7 +133,7 @@ static void output_paths(double z_clear, double xy_speed, double z_speed)
const struct segment *seg;
double x = 0, y = 0, z = 0;
double d, s = 0, t = 0;
double txy, tz;
double speed;
printf("IN;!MC1;PA\n");
printf("!ZO%d;!PZ0,%d;PU\n", units(z_max), units(z_clear));
@ -156,13 +156,19 @@ static void output_paths(double z_clear, double xy_speed, double z_speed)
z = seg->z;
seg = seg->next;
while (seg) {
printf("!ZZ%d,%d,%d\n", units(seg->x), units(seg->y),
units((seg->z - z_max) * z_scale));
if (path->segments->z == z && z == seg->z) {
printf("PA%d,%d\n",
units(seg->x), units(seg->y));
speed = xy_speed;
} else {
printf("!ZZ%d,%d,%d\n",
units(seg->x), units(seg->y),
units((seg->z - z_max) * z_scale));
speed = z_speed;
}
d = hypot(x - seg->x, y - seg->y);
txy = d / xy_speed;
tz = fabs(z - seg->z) / z_speed;
t += txy > tz ? txy : tz;
d = hypot(d, z - seg->z);
t += d / speed;
s += d;
x = seg->x;
y = seg->y;