Skip to content

Commit

Permalink
Lift mill between steps to zsafe if path is not a closed loop
Browse files Browse the repository at this point in the history
If path is not a closed loop moving to the beginning of the path at any milling depth might move across copper areas.

Proposed fix for #477.
  • Loading branch information
hannesweisbach authored and eyal0 committed Oct 11, 2020
1 parent 1c2422a commit d2dd0f4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ngc_exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "ngc_exporter.hpp"
#include "options.hpp"
#include <boost/algorithm/string.hpp>
#include "bg_operators.hpp"
#include <iostream>
using std::cerr;
using std::flush;
Expand Down Expand Up @@ -147,6 +148,14 @@ void NGC_Exporter::cutter_milling(std::ofstream& of, shared_ptr<Cutter> cutter,
for (unsigned int i = 0; i < steps_num; i++) {
const double z = cutter->zwork / steps_num * (i + 1);

/* Lift between steps if this is not the first pass and the path
is not a closed loop. */
if (i > 0 && path.front() != path.back()) {
of << "G00 Z" << cutter->zsafe * cfactor << " ( retract )\n";
of << "G00 X" << ( path.begin()->x() - xoffsetTot ) * cfactor << " Y"
<< ( path.begin()->y() - yoffsetTot ) * cfactor << " ( rapid move to begin. )\n";
}

of << "G01 Z" << z * cfactor << " F" << cutter->vertfeed * cfactor << " ( plunge. )\n";
of << "G04 P0 ( dwell for no time -- G64 should not smooth over this point )\n";
of << "G01 F" << cutter->feed * cfactor << "\n";
Expand All @@ -172,7 +181,7 @@ void NGC_Exporter::cutter_milling(std::ofstream& of, shared_ptr<Cutter> cutter,
of << "G01 F" << cutter->feed * cfactor << '\n';
in_bridge = false;
}

// Now cut horizontally.
of << "G01 X" << (path.at(current).x() - xoffsetTot) * cfactor
<< " Y" << (path.at(current).y() - yoffsetTot) * cfactor << '\n';
Expand All @@ -196,6 +205,15 @@ void NGC_Exporter::isolation_milling(std::ofstream& of, shared_ptr<RoutingMill>
const double z = mill->zwork / steps_num * (i + 1);
linestring_type_fp::const_iterator iter = path.cbegin();
of << "( Mill infeed pass " << i+1 << "/" << steps_num << " )\n";

/* Lift between steps if this is not the first pass and the path
is not a closed loop. */
if (i > 0 && path.front() != path.back()) {
of << "G00 Z" << mill->zsafe * cfactor << " ( retract )\n";
of << "G00 X" << ( path.begin()->x() - xoffsetTot ) * cfactor << " Y"
<< ( path.begin()->y() - yoffsetTot ) * cfactor << " ( rapid move to begin. )\n";
}

if (leveller) {
leveller->setLastChainPoint(point_type_fp((path.begin()->x() - xoffsetTot) * cfactor,
(path.begin()->y() - yoffsetTot) * cfactor));
Expand Down
12 changes: 12 additions & 0 deletions testing/gerbv_example/am-test-millinfeed/expected/back.ngc
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,8 @@ G01 X-6.00239 Y4.84342
G01 X-5.98995 Y4.85858
G01 X-5.97905 Y4.86948
( Mill infeed pass 2/3 )
G00 Z0.08000 ( retract )
G00 X-5.87775 Y4.96385 ( rapid move to begin. )
G01 Z-0.00533
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F6.00000
Expand Down Expand Up @@ -1369,6 +1371,8 @@ G01 X-6.00239 Y4.84342
G01 X-5.98995 Y4.85858
G01 X-5.97905 Y4.86948
( Mill infeed pass 3/3 )
G00 Z0.08000 ( retract )
G00 X-5.87775 Y4.96385 ( rapid move to begin. )
G01 Z-0.00800
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F6.00000
Expand Down Expand Up @@ -2485,6 +2489,8 @@ G01 X-8.40082 Y6.22091
G01 X-8.41295 Y6.31967
G01 X-8.41625 Y6.33476
( Mill infeed pass 2/3 )
G00 Z0.08000 ( retract )
G00 X-8.86575 Y5.61847 ( rapid move to begin. )
G01 Z-0.00533
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F6.00000
Expand Down Expand Up @@ -2663,6 +2669,8 @@ G01 X-8.40082 Y6.22091
G01 X-8.41295 Y6.31967
G01 X-8.41625 Y6.33476
( Mill infeed pass 3/3 )
G00 Z0.08000 ( retract )
G00 X-8.86575 Y5.61847 ( rapid move to begin. )
G01 Z-0.00800
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F6.00000
Expand Down Expand Up @@ -2868,6 +2876,8 @@ G01 X-9.08987 Y6.18713
G01 X-9.08875 Y6.17951
G01 X-9.58375 Y6.06524
( Mill infeed pass 2/3 )
G00 Z0.08000 ( retract )
G00 X-9.13425 Y6.78153 ( rapid move to begin. )
G01 Z-0.00533
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F6.00000
Expand All @@ -2890,6 +2900,8 @@ G01 X-9.08987 Y6.18713
G01 X-9.08875 Y6.17951
G01 X-9.58375 Y6.06524
( Mill infeed pass 3/3 )
G00 Z0.08000 ( retract )
G00 X-9.13425 Y6.78153 ( rapid move to begin. )
G01 Z-0.00800
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F6.00000
Expand Down
12 changes: 12 additions & 0 deletions testing/gerbv_example/lift-mill/expected/front.ngc
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ G01 X48.25997 Y-13.93878
G01 X48.26000 Y-13.33500
G01 X45.28711 Y-13.33500
( Mill infeed pass 2/2 )
G00 Z1.00000 ( retract )
G00 X36.84527 Y-13.33500 ( rapid move to begin. )
G01 Z-0.06000
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F80.00000
Expand Down Expand Up @@ -593,6 +595,8 @@ G01 X47.93529 Y-20.22130
G01 X48.09762 Y-20.14901
G01 X48.25997 Y-20.06628
( Mill infeed pass 2/2 )
G00 Z1.00000 ( retract )
G00 X39.51498 Y-17.61998 ( rapid move to begin. )
G01 Z-0.06000
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F80.00000
Expand Down Expand Up @@ -696,6 +700,8 @@ G01 X41.38999 Y-15.94244
G01 X41.38999 Y-15.90998
G01 X41.35338 Y-15.87337
( Mill infeed pass 2/2 )
G00 Z1.00000 ( retract )
G00 X41.35338 Y-16.98658 ( rapid move to begin. )
G01 Z-0.06000
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F80.00000
Expand Down Expand Up @@ -728,6 +734,8 @@ G01 X45.93628 Y-14.29690
G01 X45.82546 Y-14.42596
G01 X45.84408 Y-14.44518
( Mill infeed pass 2/2 )
G00 Z1.00000 ( retract )
G00 X45.58916 Y-14.53497 ( rapid move to begin. )
G01 Z-0.06000
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F80.00000
Expand Down Expand Up @@ -801,6 +809,8 @@ G01 X46.27926 Y-16.46959
G01 X46.05061 Y-16.13405
G01 X47.74222 Y-16.13499
( Mill infeed pass 2/2 )
G00 Z1.00000 ( retract )
G00 X45.84408 Y-15.87477 ( rapid move to begin. )
G01 Z-0.06000
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F80.00000
Expand Down Expand Up @@ -872,6 +882,8 @@ G01 X46.04159 Y-18.32498
G01 X46.16701 Y-18.32498
G01 X46.23567 Y-18.40126
( Mill infeed pass 2/2 )
G00 Z1.00000 ( retract )
G00 X46.04159 Y-18.32498 ( rapid move to begin. )
G01 Z-0.06000
G04 P0 ( dwell for no time -- G64 should not smooth over this point )
G01 F80.00000
Expand Down

0 comments on commit d2dd0f4

Please sign in to comment.