I am working on a PCB that has a few pin headers. The PCB is made and assembled in JLCPCB however they do not offer soldering though-hole components or pin headers. The PCB looks like this when it arrives:
Sorry, new users can only put one image in a post.
so I had an idea, that as I have files for manufacturing and assembling the board, that I could 3D print a simple holder to make soldering of the headers easier. Something like this:
As I am using Openscad for 3D modeling and it is de facto programming your 3D model, it should be easy to convert manufacturing exports from KiCad to Openscad, for example like this:
kicad_module("LED_SMD","LED_0603_1608Metric","","",[9.5791,38.93566],180.00,"front");//D5 - Red
However it turned out that it is not that simple and I went down the rabbit hole of many formats, reference systems and it took me much more longer than I expected and it is still way far from something that could be published for general use…
First idea was to start with pick and place Pos file and convert it via some script to Openscad definition. However after some time I found out that:
- Pos file does not contain all modules, especially pin headers, even if I check the “include non smd …” checkbox.
- Pos file does not contain board edges or any other info about PCB dimensions (which is understandable).
- But it also uses different reference system than PCBNEW so it is not that easy to just open the PCB in PCBNEW and write down four numbers…
So I looked into different manufacturing exports available in KiCad and I found “report file” and it seemed to contain all information needed. Basically I need this information:
- board dimensions
- position, rotation, package type of all modules
- it would be great to have i.e. courtyard dimensions so I could automate the process more but it can be hardcoded in the openscad
So I made a simple parser and tried to read report file format. First thing I noticed is that it does not contain all information about package size, only pads. That is not so bad but I really would like to have some information about module boundary so that I could create a generic void for all packages and specific holes for a few known packages (pin headers).
The second thing I noticed is that the file uses localized names for pad definitions:
Shape Obdélník Layer both
The third thing I noticed is that the
upper_left_corner 20.291667 25.617116
lower_right_corner 129.437381 102.387857
are actually not board dimensions, but some arbitrary points…
And the last thing I noticed (and it did really made me almost crazy) is that the position specified in the report references the center for all the modules, except for pin headers, where it is referencing pin 1…
To make a long story short after a lot of fidgeting I did manage to produce working PCB holder but the process is not simple and automatic…
What would be the best way how to get the required information out of KiCad if I would like to create universal and easy to use tool to create a PCB soldering holder from a KiCad file? Should I learn how to parse gerbers? Should I try to parse KiCad pcb files directly? Create a plugin?