Skip to content

Instantly share code, notes, and snippets.

@bullestock
Created August 7, 2019 19:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bullestock/87ed51aaadaae8b8d2f085756652eb04 to your computer and use it in GitHub Desktop.
Save bullestock/87ed51aaadaae8b8d2f085756652eb04 to your computer and use it in GitHub Desktop.
Convert KiCad Gerber files to G-code for Bungard
#!/bin/sh
# Generate front+back mill + cut gcode
#
# offset 0.125 (for isolation) can be tuned if pcb has room
pcb2gcode \
--back *-B_Cu.gbr \
--front *-F_Cu.gbr \
--outline *-Edge_Cuts.gbr \
--drill *.drl \
--cut-feed=128 \
--cut-infeed=0.7 \
--cut-speed=2 \
--cut-vertfeed=128 \
--cutter-diameter=1.0 \
--milldrill \
--milldrill-diameter=1.0 \
--dpi=1000 \
--drill-feed=256 \
--drill-speed=0 \
--metric \
--metricoutput \
--mill-feed=500 \
--mill-speed=2 \
--mill-vertfeed=254 \
--offset=0.125 \
--zchange=10 \
--zcut=-1.4 \
--zdrill=-1.6 \
--zero-start \
--zsafe=3 \
--zwork=-0.1 \
--extra-passes=1 \
--onedrill \
--drill-side back
# Strip tool changes from drill file
#
# notooldrill.ngc is the drill file without tool changes
grep -v "^T" milldrill.ngc > notooldrill.ngc
# Remove unsupported irrelevant g-code
grep -v "^G64" front.ngc | grep -v "^M6" > fix-front.ngc
grep -v "^G64" back.ngc | grep -v "^M6" > fix-back.ngc
# Mirror outline
grep -v "^G64" outline.ngc | sed -e 's/X/X-/g' > fix-outline.ngc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment