tinylabs / openfixture

Open Source Hardware Test/Programming Fixture
102 stars 23 forks source link

Documentation unclear/outdated #1

Open kasbah opened 7 years ago

kasbah commented 7 years ago

Hey, thanks very much for this. I am considering using it for a testing a small batch of assemblies.

I am a bit confused about the docs. Is http://tinylabs.io/openfixture-config/ outdated? How do I set my test-points now?

EDIT: It seems to be guessing from the PCB file, but not that well. :D Hacking on GetTestPoints now.

tinylabs commented 7 years ago

Hi kasbah,

Yes, that is out of date but still an option. The easiest way (if you're using kicad) is to use the GenFixture.py python wrapper that will extract the test points and the DXF outline. The README file has more information. genfixture.sh is an example of how to call GenFixture.py. Let me know if you get stuck.

tinylabs commented 7 years ago

If you find bugs (which I'm sure there may be many) please let me know or submit a patch.

kasbah commented 7 years ago

It actually works really well! I don't have SMD test-points, just through hole ones and I don't care about what layer they are on which was confusing it and me so I had to modify the function a bit.

OT: Just stumbled upon the Keysy. Looks really interesting! If I pre-order now what are the delivery estimates? Are you planning to open source any of it (firmware, hardware)?

tinylabs commented 7 years ago

The way it's currently setup you can edit any pad (in kicad) and add it to User.Eco2 layer. This will force a test point to get generated when running the script. If you have any SMD pads with no paste layer you can add them to User.Eco1 to force the script to ignore them and not generate a test point.

Thanks! Keysy is a little behind schedule. It's looking like it will be a couple months until we ship. I'd love to open source the firmware but I've spent the last couple years on the project without pay so quite frankly I can't afford to...

kasbah commented 7 years ago

Still trying to see if I can use this for our Kickstarter batch of the VRGO Chair. Not sure if this is me being stupid again but from the instructions it seems like these bits should have been generated as hex nut cut-outs?

image

tinylabs commented 7 years ago

They were but they didn't need to be so I changed it. Due to the length of the pogos the top doesn't sit flush so that wasn't necessary. These clearance holes prevent you from having to glue the nuts in.

On Mar 17, 2017 6:29 AM, "Kaspar Emanuel" notifications@github.com wrote:

Still trying to see if I can use this for our Kickstarter batch of the VRGO Chair http://vrgochair.com. Not sure if this is me being stupid again but from the instructions it seems like these bits should have been generated as hex nut cut-outs?

[image: image] https://cloud.githubusercontent.com/assets/206854/24045003/8923b846-0b15-11e7-934b-05a67dd1b713.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ebuller/openfixture/issues/1#issuecomment-287353652, or mute the thread https://github.com/notifications/unsubscribe-auth/ABPggXi6WEu3ubJMLz71T2af32vGuEsxks5rmoq8gaJpZM4MOiWo .

brainstorm commented 7 years ago

@ebuller I am a bit stuck myself with KiCad python scripting and your genfixture.sh. I've posted some details over an official kicad forum thread. If you could provide a bit more guidance over here in this github issue or there in the forum, it would be greatly appreciated.

I look forward to build my own board's fixture with your software, excellent work 👍

tinylabs commented 7 years ago

Hi Roman,

I just cloned the latest and tried on my system (Ubuntu 14.04.5 LTS). Can you try the same and let me know what the output is?

elliot@elliot-macmini:~/projects$ git clone https://github.com/ebuller/openfixture.git openfixture-staging Cloning into 'openfixture-staging'... remote: Counting objects: 132, done. remote: Total 132 (delta 0), reused 0 (delta 0), pack-reused 132 Receiving objects: 100% (132/132), 352.21 KiB | 0 bytes/s, done. Resolving deltas: 100% (63/63), done. Checking connectivity... done. elliot@elliot-macmini:~/projects$ cd openfixture-staging/ elliot@elliot-macmini:~/projects/openfixture-staging$ ./genfixture.sh ../keysy/hw/pcba/keyfob/kicad/keysy_keyfob.kicad_pcb 16:16:51: Debug: Skipping general section token 'links' 16:16:51: Debug: Skipping general section token 'area' 16:16:51: Debug: Skipping general section token 'drawings' 16:16:51: Debug: Skipping general section token 'tracks' 16:16:51: Debug: Skipping general section token 'zones' 16:16:51: Debug: Skipping general section token 'symbol' Generating Fixture... Fixture generated: /home/elliot/projects/openfixture-staging/fixture-v10/keysy_keyfob-fixture.dxf

Thanks, Elliot

On Thu, Aug 31, 2017 at 4:04 PM, Roman Valls Guimerà < notifications@github.com> wrote:

@ebuller https://github.com/ebuller I am a bit stuck myself with KiCad python scripting and your genfixture.sh. I've posted some details over an official kicad forum thread https://forum.kicad.info/t/make-python-lib-pcbnew-global-on-mac/4017/5. If you could provide some guidance over here or there in the forum, it would be greatly appreciated.

I look forward to build my own board's fixture with your software, excellent work 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ebuller/openfixture/issues/1#issuecomment-326443358, or mute the thread https://github.com/notifications/unsubscribe-auth/ABPggbvr-7X4HDEBeDfhGvPijwa0kU-Sks5sdzvogaJpZM4MOiWo .

-- Founder Tiny Labs - Small Space Big Ideas http://tinylabs.io

http://goo.gl/NDg6WB

brainstorm commented 7 years ago

Sure and thanks for the fast reply! Please keep in mind I'm running on OSX Sierra 10.12.6 with KiCAD nightly from 2017-08-21:

brainstorm:openfixture romanvg$ ls
GenFixture.py        README.md            glaser-stencil-d.ttf openfixture.scad     rfid_fob-outline.dxf
GenFixture.pyc       genfixture.sh        ohw_logo.svg         osh_logo.dxf
brainstorm:openfixture romanvg$ ./genfixture.sh
Traceback (most recent call last):
  File "GenFixture.py", line 26, in <module>
    from pcbnew import *
ImportError: No module named 'pcbnew'
brainstorm:openfixture romanvg$ ./genfixture.sh ~/dev/espDonut/hardware/esp_donut.kicad_pcb
Traceback (most recent call last):
  File "GenFixture.py", line 26, in <module>
    from pcbnew import *
ImportError: No module named 'pcbnew'

And more exactly with your same commands:

brainstorm:dev romanvg$ git clone https://github.com/ebuller/openfixture.git openfixture-staging
Cloning into 'openfixture-staging'...
remote: Counting objects: 132, done.
remote: Total 132 (delta 0), reused 0 (delta 0), pack-reused 132
Receiving objects: 100% (132/132), 352.21 KiB | 217.00 KiB/s, done.
Resolving deltas: 100% (63/63), done.
brainstorm:dev romanvg$ cd openfixture-staging/
brainstorm:openfixture-staging romanvg$ ./genfixture.sh ~/dev/espDonut/hardware/esp_donut.kicad_pcb
Traceback (most recent call last):
  File "GenFixture.py", line 23, in <module>
    from pcbnew import *
ImportError: No module named pcbnew
brainstorm:openfixture-staging romanvg$ which python
/usr/bin/python

It is basically a PYTHONPATH/environment issue, rather unrelated with your software per se, but I would like to see it fixed from the KiCAD side in a portable/easy way so that projects like yours can be run in any platform and OS.

tinylabs commented 7 years ago

Yeah unfortunately I don't have OSX to test on. It's definitely not finding the python scripting library... Try this:

  1. Open Pcbnew GUI from kicad normally.
  2. Click Tools->Scripting Console
  3. Type the following:

    import pcbnew print pcbnew.file /usr/lib/python2.7/dist-packages/pcbnew.py

Let me know the output. Thanks, Elliot

On Thu, Aug 31, 2017 at 4:33 PM, Roman Valls Guimerà < notifications@github.com> wrote:

Sure and thanks for the fast reply! Please keep in mind I'm running on OSX Sierra 10.12.6 with KiCAD nightly from 2017-08-21:

brainstorm:openfixture romanvg$ ls GenFixture.py README.md glaser-stencil-d.ttf openfixture.scad rfid_fob-outline.dxf GenFixture.pyc genfixture.sh ohw_logo.svg osh_logo.dxf brainstorm:openfixture romanvg$ ./genfixture.sh Traceback (most recent call last): File "GenFixture.py", line 26, in from pcbnew import ImportError: No module named 'pcbnew' brainstorm:openfixture romanvg$ ./genfixture.sh ~/dev/espDonut/hardware/esp_donut.kicad_pcb Traceback (most recent call last): File "GenFixture.py", line 26, in from pcbnew import ImportError: No module named 'pcbnew'

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ebuller/openfixture/issues/1#issuecomment-326447592, or mute the thread https://github.com/notifications/unsubscribe-auth/ABPggVIjJ0TbEif2WjFQkhYtvxddZgwlks5sd0LBgaJpZM4MOiWo .

-- Founder Tiny Labs - Small Space Big Ideas http://tinylabs.io

http://goo.gl/NDg6WB

brainstorm commented 7 years ago
Py 0.9.8
Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Startup script executed: /Users/romanvg/Library/Preferences/kicad/PyShell_pcbnew_startup.py
>>> import pcbnew
>>> print pcbnew.__file__
/Applications/Kicad/kicad.app/Contents/Frameworks/python/site-packages/pcbnew.pyc
>>>
brainstorm commented 7 years ago

After a bit of library hacks to resolve the Reason: image not found from dlopen-ing the _pcbnew.so shared lib:

$ cat fix_osx_pcbnew_kicad_libs.sh
#!/bin/bash
# Inspired on: https://www.bountysource.com/issues/31269729-libwx_osx_cocoau-3-1-dylib-not-found

KICAD_LIBS_TOFIX="libwx_osx_cocoau_gl-3.0.0 libwx_osx_cocoau_adv-3.0.0 libwx_osx_cocoau_aui-3.0.0 libwx_osx_cocoau_adv-3.0.0 libwx_osx_cocoau_html-3.0.0 libwx_osx_cocoau_core-3.0.0 libwx_osx_cocoau_stc-3.0.0 libkicad_3dsg.2.0.0 libGLEW.2.0.0 libcairo.2 libpixman-1.0 libwx_baseu_net-3.0.0 libwx_baseu-3.0.0 libwx_baseu_xml-3.0.0"

#KICAD_LIBS_TOFIX=`find /Applications/Kicad/kicad.app/Contents/Frameworks/ -iname *.dylib | xargs otool -L | grep executable_path | awk '{print $1}' | awk -F'/' '{print $4}'`

for kicadlib in $KICAD_LIBS_TOFIX;
do
    echo "Fixing ${kicadlib} broken path on pcbnew..."
    install_name_tool -change @executable_path/../Frameworks/${kicadlib}.dylib /Applications/Kicad/kicad.app/Contents/Frameworks/${kicadlib}.dylib /Applications/Kicad/pcbnew.app/Contents/Frameworks/python/site-packages/_pcbnew.so
done

echo "Done! All paths should be absolute now, no @executable_path in:"
otool -L /Applications/Kicad/kicad.app/Contents/Frameworks/python/site-packages/_pcbnew.so

# Brute force step
echo "Forcing absolute paths on all the dylibs and dependencies on KiCAD, this might take a while..."
for kicadlib in $KICAD_LIBS_TOFIX;
do
    for kicaddep in $KICAD_LIBS_TOFIX;
    do
        echo "Fixing ${kicadlib} referenced by ${kicaddep}..."
        install_name_tool -change @executable_path/../Frameworks/${kicadlib}.dylib /Applications/Kicad/kicad.app/Contents/Frameworks/${kicadlib}.dylib /Applications/Kicad/pcbnew.app/Contents/Frameworks/${kicaddep}.dylib
    done
done

I copied the system's Python interpreter and added #!/Applications/Kicad/pcbnew.app/Contents/MacOS/Python as a shell-bang (as suggested by John on the KiCAD forum) for GenFixture.py and managed to execute it, but not successfully yet:

$ ./GenFixture.py --board ~/dev/espDonut/hardware/esp_donut.kicad_pcb --layer B.Cu --rev 0 --mat_th 2.45 --pcb_th 1.6 --out ~/dev/espDonut/hardware/cad/openfixture
Traceback (most recent call last):
  File "./GenFixture.py", line 388, in <module>
    fixture.Generate (out_dir)
  File "./GenFixture.py", line 178, in Generate
    self.GetTestPoints ()
  File "./GenFixture.py", line 260, in GetTestPoints
    (p.GetAttribute () != PAD_SMD)):
NameError: global name 'PAD_SMD' is not defined

I'll keep digging, getting closer to a solution...

Note: Using the shellscript does not work:

$ ./genfixture.sh
Traceback (most recent call last):
  File "GenFixture.py", line 28, in <module>
    from pcbnew import *
  File "/Applications/Kicad/kicad.app/Contents/Frameworks/python/site-packages/pcbnew.py", line 42, in <module>
    import _pcbnew
ImportError: dynamic module does not define module export function (PyInit__pcbnew)
brainstorm commented 7 years ago

After a bit more fiddling I succeded!:

esp_donut-fixture

I'll put together the changes below a bit better in a proper pullrequest later on, but wanted to share this so that others can use it ;)

diff --git a/GenFixture.py b/GenFixture.py
index 670580c..f8296ff 100755
--- a/GenFixture.py
+++ b/GenFixture.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/Applications/Kicad/pcbnew.app/Contents/MacOS/Python
 #
 # Kicad OpenFixture Generator
 #
@@ -20,6 +20,9 @@
 import os
 import sys
 import argparse
+
+sys.path.insert(0, "/Applications/Kicad/kicad.app/Contents/Frameworks/python/site-packages")
+
 from pcbnew import *

 # Defaults
@@ -149,7 +152,7 @@ class GenFixture:
         popt.SetSubtractMaskFromSilk(False)

         # Do the BRD edges in black
-        popt.SetColor(BLACK)
+        popt.SetColor(COLOR4D.BLACK)

         # Open file
         pctl.SetLayer(Edge_Cuts)
@@ -181,7 +184,7 @@ class GenFixture:
             if self.rev == "":
                 self.rev = "rev.0"

-        # Call openscad to generate fixture
+        # Call /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD to generate fixture
         args = "-D\'test_points=%s\'" % self.GetTestPointStr ()
         args += " -D\'tp_min_y=%.02f\'" % self.min_y
         args += " -D\'mat_th=%.02f\'" % self.mat_th
@@ -214,19 +217,19 @@ class GenFixture:
         testout= path + "/" + self.prj_name + "-test.dxf"

         # This will take a while, print something
-        print "Generating Fixture..."
+        print("Generating Fixture...")

         # Create test part
-        os.system ("openscad %s -D\'mode=\"testcut\"\' -o %s openfixture.scad" % (args, testout))
+        os.system ("/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD %s -D\'mode=\"testcut\"\' -o %s openfixture.scad" % (args, testout))

         # Create rendering
-        os.system ("openscad %s -D\'mode=\"3dmodel\"\' --render -o %s openfixture.scad" % (args, pngout))
+        os.system ("/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD %s -D\'mode=\"3dmodel\"\' --render -o %s openfixture.scad" % (args, pngout))

         # Create laser cuttable fixture
-        os.system ("openscad %s -D\'mode=\"lasercut\"\' -o %s openfixture.scad" % (args, dxfout))
+        os.system ("/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD %s -D\'mode=\"lasercut\"\' -o %s openfixture.scad" % (args, dxfout))

         # Print output
-        print "Fixture generated: %s" % dxfout
+        print("Fixture generated: %s".format(dxfout))

     def GetTestPointStr (self):
         tps = "["
@@ -252,7 +255,7 @@ class GenFixture:
                     #else check ignore cases
                     elif ((p.IsOnLayer (self.ignore_layer) == True) or
                           (p.IsOnLayer (self.paste) == True) or
-                          (p.GetAttribute () != PAD_SMD)):
+                          (p.GetAttribute () != D_PAD_SMDMask())):
                         continue

                     # Print position
tinylabs commented 7 years ago

Awesome! Glad you figured it out. Some of the changes look specific to OSX but I'll try and pick up the portable changes. Good info though for anyone on OSX...

On Fri, Sep 1, 2017 at 9:11 AM, Roman Valls Guimerà < notifications@github.com> wrote:

After a bit more fiddling I succeded!:

[image: esp_donut-fixture] https://user-images.githubusercontent.com/175587/29978226-2b343ff6-8f38-11e7-923f-e078b4ad5a33.png

I'll put together the changes below a bit better in a proper pullrequest later on, but wanted to share this so that others can use it ;)

diff --git a/GenFixture.py b/GenFixture.py index 670580c..f8296ff 100755 --- a/GenFixture.py +++ b/GenFixture.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/Applications/Kicad/pcbnew.app/Contents/MacOS/Python #

Kicad OpenFixture Generator

# @@ -20,6 +20,9 @@ import os import sys import argparse + +sys.path.insert(0, "/Applications/Kicad/kicad.app/Contents/Frameworks/python/site-packages") + from pcbnew import *

Defaults

@@ -149,7 +152,7 @@ class GenFixture: popt.SetSubtractMaskFromSilk(False)

     # Do the BRD edges in black
  • popt.SetColor(BLACK)

  • popt.SetColor(COLOR4D.BLACK)

     # Open file
     pctl.SetLayer(Edge_Cuts)

    @@ -181,7 +184,7 @@ class GenFixture: if self.rev == "": self.rev = "rev.0"

  • Call openscad to generate fixture

  • Call /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD to generate fixture

     args = "-D\'test_points=%s\'" % self.GetTestPointStr ()
     args += " -D\'tp_min_y=%.02f\'" % self.min_y
     args += " -D\'mat_th=%.02f\'" % self.mat_th

    @@ -214,19 +217,19 @@ class GenFixture: testout= path + "/" + self.prj_name + "-test.dxf"

     # This will take a while, print something
  • print "Generating Fixture..."

  • print("Generating Fixture...")

     # Create test part
  • os.system ("openscad %s -D\'mode=\"testcut\"\' -o %s openfixture.scad" % (args, testout))

  • os.system ("/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD %s -D\'mode=\"testcut\"\' -o %s openfixture.scad" % (args, testout))

     # Create rendering
  • os.system ("openscad %s -D\'mode=\"3dmodel\"\' --render -o %s openfixture.scad" % (args, pngout))

  • os.system ("/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD %s -D\'mode=\"3dmodel\"\' --render -o %s openfixture.scad" % (args, pngout))

     # Create laser cuttable fixture
  • os.system ("openscad %s -D\'mode=\"lasercut\"\' -o %s openfixture.scad" % (args, dxfout))

  • os.system ("/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD %s -D\'mode=\"lasercut\"\' -o %s openfixture.scad" % (args, dxfout))

     # Print output
  • print "Fixture generated: %s" % dxfout

  • print("Fixture generated: %s".format(dxfout))

    def GetTestPointStr (self): tps = "[" @@ -252,7 +255,7 @@ class GenFixture:

    else check ignore cases

                 elif ((p.IsOnLayer (self.ignore_layer) == True) or
                       (p.IsOnLayer (self.paste) == True) or
  • (p.GetAttribute () != PAD_SMD)):

  • (p.GetAttribute () != D_PAD_SMDMask())): continue

                 # Print position

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ebuller/openfixture/issues/1#issuecomment-326621109, or mute the thread https://github.com/notifications/unsubscribe-auth/ABPggTPxwGuRbFS5tnyz_u7eII6OUEI3ks5seCykgaJpZM4MOiWo .

-- Founder Tiny Labs - Small Space Big Ideas http://tinylabs.io

http://goo.gl/NDg6WB