diff --git a/README b/README deleted file mode 100644 index d3aafea..0000000 --- a/README +++ /dev/null @@ -1,74 +0,0 @@ -Tool for cutting accurate SMT stencils on a Graphtec cutter (e.g. Silhouette Cameo or Portrait) from gerber files. Techniques include separately drawn line segments (no complex paths), antibacklash, drag-knife-angle "training", and multiple passes. This produces stencils usable down to approximately 0.5 mm pitch (QFP/QFN) and 0201 discrete components, or perhaps even slightly better; but it is slower than normal cutting. - - -Usage: - -A solderpaste gerber file, paste.gbr, and default settings: - - gerber2graphtec paste.gbr >/dev/usb/lp0 - -A more elaborate command line with linear map (to correct spatial miscalibration) and multiple passes with different speeds and forces: - - gerber2graphtec --offset 3,4 --matrix 1.001,0,-0.0005,0.9985 --speed 2,1 --force 5,25 paste.gbr >/dev/usb/lp0 - -You may want to have your CAM tool shrink the paste features by about 2 mils before exporting to gerber. The craft-cutter knife, when cutting thin mylar, seems to spread out the geometry by about this amount. I'd suggest using mylar with thickness between about 3 and 5 mils; the IPC-recommended thicknesses for fine-pitch stencils are approximately in this range. (Typical inexpensive laser-transparency sheets happen to be just right, being somewhere between 3.5 and 4.3 mils.) You may have to experiment with the cutting speeds and forces for best quality with your materials. - -With Mac OS X or Windows, the file2graphtec script can take the place of /dev/usb/lp0. Write gerber2graphtec's output to a temporary file (gerber2graphtec ... >foo), then send it to the cutter (file2graphtec foo). I've tested file2graphtec on Mac OS X but not on Windows. For Mac OS X, install XCode and macports, then install the dependencies with - -port install gerbv -port install pstoedit -port install libusb - -These will take some time to build. - -To run file2graphtec, you will also need the Python bindings for libusb-1.0. Download and install this package: - -http://pypi.python.org/pypi/libusb1 - -with the usual "python setup.py install" installation method (as the root user). If you don't need file2graphtec (perhaps you're on Linux and can just use the device node directly), this Python package isn't needed. - -Ubuntu users may need to check their version of gerbv. Several users have reported that versions prior to 2.6.0 (such as 2.5.0) apparently have a bug related to omitting small apertures/pads. If your Linux distribution still has the old gerbv-2.5.0, please delete the package and instead build from source for the latest stable version: - -http://gerbv.geda-project.org/ - -Fedora 17 has gerbv-2.6.0 in its supplied package list, so no issue there. For Fedora-like systems, "yum install gerbv pstoedit tkinter". - -On some Linux distributions, permissions on /dev/usb/lp0 are restricted by default. To fix this, add yourself to the lp group and then log out and log back in: - -sudo usermod -a --group lp your_userid - - -Links: - -These pages have hints on usage (e.g. on Windows), materials, performance, calibration, etc: - -http://pmonta.com/blog/2012/12/25/smt-stencil-cutting/ -http://dangerousprototypes.com/forum/viewtopic.php?f=68&t=5341 -http://hackeda.com/blog/start-printing-pcb-stencils-for-about-200/ -http://hackaday.com/2012/12/27/diy-smd-stencils-made-with-a-craft-cutter/ - - -GUI: - -An optional GUI has been provided by jesuscf (see the dangerousprototypes.com thread linked above). It allows interactive selection of the input Gerber file, parameters, and cutting operations. To use it, run the file g2g_gui.py. - - -Dependencies: - -gerbv (>= 2.6.0) -pstoedit -Tkinter (when using g2g_gui) - -Credits: - -Thanks to the authors of robocut and graphtecprint for protocol documentation: - -http://gitorious.org/robocut -http://vidar.botfu.org/graphtecprint -https://github.com/jnweiger/graphtecprint - -Also thanks to this web page (Cathy Sexton) for inspiration: - -http://www.idleloop.com/robotics/cutter/index.php - -Her cutter seems to be quite a bit better than mine was out of the box. With Silhouette's default software my 0.5 mm pitch pads were distorted to the point of unusability. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9f8e928 --- /dev/null +++ b/README.md @@ -0,0 +1,144 @@ +

+ +

cut SMT stencils from Gerber files

+

+

+ +[![GPL](https://img.shields.io/badge/license-GPL-blue)](https://github.com/pmonta/gerber2graphtec/blob/master/LICENSE) +[![Python](https://img.shields.io/badge/language-Python3-orange)](https://www.python.org) +[![GitHub Release](https://img.shields.io/badge/release-v0.2-brightgreen)](https://github.com/pmonta/gerber2graphtec/releases) + +## About + +SMTCut, previously called **gerber2graphtec**, is a tool for cutting accurate SMT stencils on a **Graphtec** or **Silhouette** vinyl cutter from Gerber files.
+ +Techniques include separately drawn line segments (no complex paths), antibacklash, drag-knife-angle "training", and multiple passes.
+ +This produces stencils usable down to approximately **0.5 mm pitch** (QFP/QFN) and **0201** discrete components, or perhaps even slightly better; but it is slower than normal cutting. + + +## Getting Started + +To be able to run this software, make sure that you have installed the following dependencies: + +- [gerbv](http://gerbv.geda-project.org) +- [pstoedit](http://www.calvina.de/pstoedit/) +- [libusb](https://libusb.info) + +#### Install on Mac OSX: +Make sure you already have installed [Homebrew](https://brew.sh/) and simply run the following commands: + +``` +brew install gerbv +``` +``` +brew install pstoedit +``` +``` +brew install libusb +``` +Also make sure that you've installed the libusb1 python package or install it via +``` +pip3 install libusb1 +``` + +## Usage + +In general there are two different cases to distinguish depending on your operating system. Please note that this process can take a few minutes before the cutter starts to cut! + +### Linux +E.g. a solderpaste gerber file (paste.gbr), and default settings: + +``` +gerber2graphtec paste.gbr >/dev/usb/lp0 +``` + +Or a more elaborate command line with linear map (to correct spatial miscalibration) and multiple passes with different speeds and forces: + +``` +gerber2graphtec --offset 3,4 --matrix 1.001,0,-0.0005,0.9985 --speed 2,1 --force 5,25 paste.gbr >/dev/usb/lp0 +``` + +### Mac OSX and Windows +With Mac OS X or Windows, the file2graphtec script can take the place of /dev/usb/lp0. But keep in mind that the software is tested on Mac OS X but not on Windows! + +E.g. a solderpaste gerber file (paste.gbr), and default settings: + +``` +python3 gerber2graphtec paste.gbr > tmpfile +python3 file2graphtec tmpfile +``` + +Or a more elaborate command line with linear map (to correct spatial miscalibration) and multiple passes with different speeds and forces: + +``` +python3 gerber2graphtec --offset 3,4 --matrix 1.001,0,-0.0005,0.9985 --speed 2,1 --force 5,25 paste.gbr > tmpfile +python3 file2graphtec tmpfile +``` + +## Known issues +Due to a bug inside ghostscript, you may need to downgrade to version < 9.26 or you might encounter repeating output --> [Issue17](https://github.com/pmonta/gerber2graphtec/issues/17) + +On Mac OSX this can be done by uninstalling ghostscript with: + +``` +brew uninstall --ignore-dependencies ghostscript +``` + +and reinstalling the version 9.25 + +``` +brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/b0b6b9495113b0ac5325e07d5427dc89170f690f/Formula/ghostscript.rb +``` + +## Calibration +To achieve the best results, one should run different calibrations, which can be found in the test folder after the blade is set. The following example shows how to calibrate the cutter on Mac OSX but the commands are also applicable to other operating systems (make sure you run these files from the main folder). + +``` +python3 tests/test_forces.py > tmpfile +python3 file2graphtec python3 file2graphtec tmpfile +``` + +## GUI + +An optional GUI has been provided by [jesuscf](https://github.com/jesuscfv). It allows interactive selection of the input Gerber file, parameters, and cutting operations. + +To use it, run the following command: + +``` +python3 g2g_gui.py +``` + +## Tips & Tricks +You may want to have your CAM tool shrink the paste features by about 2 mils before exporting to gerber. The craft-cutter knife, when cutting thin mylar, seems to spread out the geometry by about this amount. I'd suggest using mylar with thickness between about 3 and 5 mils; the IPC-recommended thicknesses for fine-pitch stencils are approximately in this range. (Typical inexpensive laser-transparency sheets happen to be just right, being somewhere between 3.5 and 4.3 mils.) You may have to experiment with the cutting speeds and forces for best quality with your materials. + +Fedora 17 has gerbv-2.6.0 in its supplied package list, so no issue there. For Fedora-like systems, "yum install gerbv pstoedit tkinter". + +On some Linux distributions, permissions on /dev/usb/lp0 are restricted by default. To fix this, add yourself to the lp group and then log out and log back in: + +``` +sudo usermod -a --group lp your_userid +``` + +## Additional Information + +These pages have hints on usage (e.g. on Windows), materials, performance, calibration, etc: + +- [pmonta.com](http://pmonta.com/blog/2012/12/25/smt-stencil-cutting/) +- [dangerousprototypes.com](http://dangerousprototypes.com/forum/viewtopic.php?f=68&t=5341) +- [hackaday.com](http://hackaday.com/2012/12/27/diy-smd-stencils-made-with-a-craft-cutter/) + +## Credits + +Thanks to the authors of robocut and graphtecprint for protocol documentation: + +- [robocut](http://gitorious.org/robocut) +- [graphtecprint](http://vidar.botfu.org/graphtecprint) +- [graphtecprint](https://github.com/jnweiger/graphtecprint) + +Also thanks to this web page (Cathy Sexton) for inspiration: + +- [idleloop.com](http://www.idleloop.com/robotics/cutter/index.php) + +Her cutter seems to be quite a bit better than mine was out of the box. +With Silhouette's default software my 0.5 mm pitch pads were distorted to the point of unusability. diff --git a/file2graphtec b/file2graphtec index a1d3be1..027d37e 100755 --- a/file2graphtec +++ b/file2graphtec @@ -37,7 +37,7 @@ if len(sys.argv)==2: elif len(sys.argv)==1: f = sys.stdin else: - print 'usage: file2graphtec [filename]' + print('usage: file2graphtec [filename]') sys.exit(1) endpoint = 1 diff --git a/g2g_gui.py b/g2g_gui.py index 482fa00..cfb0b9d 100755 --- a/g2g_gui.py +++ b/g2g_gui.py @@ -1,15 +1,13 @@ #!/usr/bin/env python -import Tkinter -import tkMessageBox -import tkFileDialog +import tkinter import sys import os import string -from Tkinter import * +from tkinter import * from os import path, access, R_OK, W_OK -top = Tkinter.Tk() +top = tkinter.Tk() top.title("Gerber to Graphtec") Gerber_name = StringVar() @@ -234,44 +232,44 @@ def default_cut_mode_str(): Label(top, text="Gerber File ").grid(row=1, column=0, sticky=W) Entry(top, bd =1, width=60, textvariable=Gerber_name).grid(row=1, column=1) -Tkinter.Button(top, width=9, text = "Browse", command = get_input_filename).grid(row=1, column=2) +tkinter.Button(top, width=9, text = "Browse", command = get_input_filename).grid(row=1, column=2) Label(top, text="Output File ").grid(row=2, column=0, sticky=W) Entry(top, bd =1, width=60, textvariable=Output_name).grid(row=2, column=1) -Tkinter.Button(top, width=9, text = "Browse", command = get_output_filename).grid(row=2, column=2) +tkinter.Button(top, width=9, text = "Browse", command = get_output_filename).grid(row=2, column=2) if os.name=='nt': Label(top, text="gerbv path ").grid(row=3, column=0, sticky=W) Entry(top, bd =1, width=60, textvariable=gerbv_path).grid(row=3, column=1) - Tkinter.Button(top, width=9, text = "Browse", command = get_gerbv_path).grid(row=3, column=2) + tkinter.Button(top, width=9, text = "Browse", command = get_gerbv_path).grid(row=3, column=2) Label(top, text="pstoedit path ").grid(row=4, column=0, sticky=W) Entry(top, bd =1, width=60, textvariable=pstoedit_path).grid(row=4, column=1) - Tkinter.Button(top, width=9, text = "Browse", command = get_pstoedit_path).grid(row=4, column=2) + tkinter.Button(top, width=9, text = "Browse", command = get_pstoedit_path).grid(row=4, column=2) Label(top, text="Offset ").grid(row=5, column=0, sticky=W) Entry(top, bd =1, width=60, textvariable=offset_str).grid(row=5, column=1) -Tkinter.Button(top, width=9, text = "Default", command = default_offset_str).grid(row=5, column=2) +tkinter.Button(top, width=9, text = "Default", command = default_offset_str).grid(row=5, column=2) Label(top, text="Border ").grid(row=6, column=0, sticky=W) Entry(top, bd =1, width=60, textvariable=border_str).grid(row=6, column=1) -Tkinter.Button(top, width=9, text = "Default", command = default_border_str).grid(row=6, column=2) +tkinter.Button(top, width=9, text = "Default", command = default_border_str).grid(row=6, column=2) Label(top, text="Matrix ").grid(row=7, column=0, sticky=W) Entry(top, bd =1, width=60, textvariable=matrix_str).grid(row=7, column=1) -Tkinter.Button(top, width=9, text = "Default", command = default_matrix_str).grid(row=7, column=2) +tkinter.Button(top, width=9, text = "Default", command = default_matrix_str).grid(row=7, column=2) Label(top, text="Speed ").grid(row=8, column=0, sticky=W) Entry(top, bd =1, width=60, textvariable=speed_str).grid(row=8, column=1) -Tkinter.Button(top, width=9, text = "Default", command = default_speed_str).grid(row=8, column=2) +tkinter.Button(top, width=9, text = "Default", command = default_speed_str).grid(row=8, column=2) Label(top, text="Force ").grid(row=9, column=0, sticky=W) Entry(top, bd =1, width=60, textvariable=force_str).grid(row=9, column=1) -Tkinter.Button(top, width=9, text = "Default", command = default_force_str).grid(row=9, column=2) +tkinter.Button(top, width=9, text = "Default", command = default_force_str).grid(row=9, column=2) Label(top, text="Cut Mode ").grid(row=10, column=0, sticky=W) Entry(top, bd =1, width=60, textvariable=cut_mode_str).grid(row=10, column=1) -Tkinter.Button(top, width=9, text = "Default", command = default_cut_mode_str).grid(row=10, column=2) +tkinter.Button(top, width=9, text = "Default", command = default_cut_mode_str).grid(row=10, column=2) if os.name=='nt': Label(top, text="Cutter Shared Name").grid(row=11, column=0, sticky=W) @@ -279,10 +277,10 @@ def default_cut_mode_str(): Label(top, text="Cutter Device Name").grid(row=11, column=0, sticky=W) Entry(top, bd =1, width=60, textvariable=cutter_shared_name_str).grid(row=11, column=1, sticky=E) -Tkinter.Button(top, width=40, text = "Create Graphtec File", command = main_program).grid(row=12, column=1) -Tkinter.Button(top, width=40, text = "Send Graphtec File to Silhouette Cutter", command = Send_to_Cutter).grid(row=13, column=1) -Tkinter.Button(top, width=40, text = "Save Configuration", command = Save_Configuration).grid(row=14, column=1) -Tkinter.Button(top, width=40, text = "Exit", command = Just_Exit).grid(row=15, column=1) +tkinter.Button(top, width=40, text = "Create Graphtec File", command = main_program).grid(row=12, column=1) +tkinter.Button(top, width=40, text = "Send Graphtec File to Silhouette Cutter", command = Send_to_Cutter).grid(row=13, column=1) +tkinter.Button(top, width=40, text = "Save Configuration", command = Save_Configuration).grid(row=14, column=1) +tkinter.Button(top, width=40, text = "Exit", command = Just_Exit).grid(row=15, column=1) if path.isfile(CONFPATH) and access(CONFPATH, R_OK): f = open(CONFPATH,'r') diff --git a/gerber2graphtec b/gerber2graphtec index c20be48..5f17f14 100755 --- a/gerber2graphtec +++ b/gerber2graphtec @@ -27,7 +27,7 @@ media_size = (12,11) theta = 0 def floats(s): - return map(float,string.split(s,',')) + return list(map(float,str.split(s,','))) argc = 1 while argc/dev/usb/lp0' - print '' - print 'options:' - print ' --offset x,y translate to device coordinates x,y (inches)' - print ' --border bx,by cut a border around the bounding box of the gerber file; 0,0 to disable' - print ' --matrix a,b,c,d transform coordinates by [a b;c d]' - print ' --speed s[,s2[,s3]] use speed s in device units; s2,s3 for multiple passes' - print ' --force f[,f2[,f3]] use force f in device units; f2,f3 for multiple passes' - print ' --cut_mode [0|1] 0 for highest accuracy (fine pitch), 1 for highest speed' - print ' --media_size x,y size of media' - print ' --rotate theta rotate counterclockwise by theta degrees' - print '' - print 'defaults:' - print ' --offset 4.0,0.5 suitable for letter size (portrait) on the Cameo, fed as "media" not "mat"' - print ' --border 1,1 1-inch border in x and y around gerber bounding box' - print ' --matrix 1,0,0,1 identity linear transform for scale and skew calibration' - print ' --speed 2,2 use two passes, speed 2 in each pass' - print ' --force 8,30 use force 8 for first pass, force 30 for second pass' - print ' --cut_mode 0 highest accuracy' - print ' --media_size 12,11 use a media size of 12 inches in x, 11 inches in y' - print ' --rotate 0 no rotation' - print '' + print('usage: gerber2graphtec [options] paste.gbr >/dev/usb/lp0') + print('') + print('options:') + print(' --offset x,y translate to device coordinates x,y (inches)') + print(' --border bx,by cut a border around the bounding box of the gerber file; 0,0 to disable') + print(' --matrix a,b,c,d transform coordinates by [a b;c d]') + print(' --speed s[,s2[,s3]] use speed s in device units; s2,s3 for multiple passes') + print(' --force f[,f2[,f3]] use force f in device units; f2,f3 for multiple passes') + print(' --cut_mode [0|1] 0 for highest accuracy (fine pitch), 1 for highest speed') + print(' --media_size x,y size of media') + print(' --rotate theta rotate counterclockwise by theta degrees') + print('') + print('defaults:') + print(' --offset 4.0,0.5 suitable for letter size (portrait) on the Cameo, fed as "media" not "mat"') + print(' --border 1,1 1-inch border in x and y around gerber bounding box') + print(' --matrix 1,0,0,1 identity linear transform for scale and skew calibration') + print(' --speed 2,2 use two passes, speed 2 in each pass') + print(' --force 8,30 use force 8 for first pass, force 30 for second pass') + print(' --cut_mode 0 highest accuracy') + print(' --media_size 12,11 use a media size of 12 inches in x, 11 inches in y') + print(' --rotate 0 no rotation') + print('') sys.exit(1) # @@ -92,7 +92,7 @@ if not input_filename: temp_pdf = "_tmp_gerber.pdf" temp_pic = "_tmp_gerber.pic" -if string.lower(input_filename[-3:])=='pdf': +if str.lower(input_filename[-3:])=='pdf': os.system("pstoedit -f pic %s %s 2>/dev/null" % (input_filename,temp_pic)) else: os.system("gerbv --export=pdf --output=%s --border=20 %s" % (temp_pdf,input_filename)) diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..fc1d803 Binary files /dev/null and b/logo.png differ diff --git a/tests/test_array.py b/tests/test_array.py index a93b007..42cebe1 100644 --- a/tests/test_array.py +++ b/tests/test_array.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +import sys +sys.path.insert(0, '') import random import graphtec diff --git a/tests/test_array_antibacklash.py b/tests/test_array_antibacklash.py index 82e9022..95a0d8b 100644 --- a/tests/test_array_antibacklash.py +++ b/tests/test_array_antibacklash.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +import sys +sys.path.insert(0, '') import random import graphtec diff --git a/tests/test_calibrate.py b/tests/test_calibrate.py index 4c2446d..e825860 100644 --- a/tests/test_calibrate.py +++ b/tests/test_calibrate.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +import sys +sys.path.insert(0, '') import graphtec import math diff --git a/tests/test_forces.py b/tests/test_forces.py index 8918959..985dd78 100644 --- a/tests/test_forces.py +++ b/tests/test_forces.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +import sys +sys.path.insert(0, '') import graphtec offset = (5,1)