fcad_pcb icon indicating copy to clipboard operation
fcad_pcb copied to clipboard

Trouble with minimum width parameter of polygons

Open TheRealTobiwan opened this issue 2 years ago • 7 comments

Hi, I am using your code to extract the copper traces from my pcb's for FEM simulations and so far this works well. But I think I recently found an issue while I was working on a comparatively small pcb. I extracted the copper using:

`from fcad_pcb import kicad

pcb = kicad.KicadFcad(<full_path_to_your_kicad_pcb_file>)

pcb.make(copper_thickness=0.035, board_thickness=1.53, combo=False, fuseCoppers=True )`

but it seems like all my polygons are a little to big. Here is my example pcb in Kicad. The distance between the highlighted polygons is 0.2mm: Kicad And here is what I get in FreeCAD using the commands above: 0_2_mm_minimum As you can see the distance is 0. I tried some things and I found that the "Minimum Width" Parameter in the polygons settings seems to impact this behaviour (see next picture for the setting). kicad_polygon_menu For the test above it was set to 0.2mm. If I reduce it to 0.0254mm for both polygons I get the following result: 0_0254_mm_minimum The change of "Minimum Width" from 0.2mm to 0.0254mm (which seems to be the minimum in Kicad) meens a difference of approx. 0.17mm, which seems to correlate with the new distance (see picture above). For me it seems like the parameter "minimum width" is interpreted as some kind of "line thickness" of the polygons outline, which is than "added" to the original polygon.

My Toolchain: Kicad 6.06 FreeCAD 0.20 latest version of your code

Last but not least: Big thanks for your effort, your code is really useful!

TheRealTobiwan avatar Jul 20 '22 06:07 TheRealTobiwan

There is an interesting read about this minimum width issue. Maybe they finally decide to change the behavior some how. But looks like it will break backward compatibility. Can you by any chance try your file in older version KiCAD? Also please confirm it is not just a display thing. I mean just to be sure, check the KiCAD 3D view and see the zone shape. Maybe you can also send me a simplified pcb showing this problem.

realthunder avatar Jul 20 '22 07:07 realthunder

Hi realthunder, I made a small example for you which consists of only two copper planes: example The distance between this two planes is exactly 0.2mm and the "Minimum Width"-Parameter of both polygons is set to 0.2mm as well. The KiCAD 3D-Viewer shows the following: a1 This looks quite similar. When changing the "Minimum Width"-Parameter of the polygons to the minimum of 0.0254mm the look of the pcb does not change (especially not the distance between them), neither in pcbnew nor in the 3D-Viewer, except some little changes on the edges: a2 b2 When using your tool to extract the copper layers I get the following (using the same commands like I did above) with "Minimum Width" = 0.2mm: a And with "Minimum Width" = 0.0254mm: b It seems like KiCAD (and it's 3D-Viewer) itself ignores this parameter (except the "edge-effect" shown above), since it does not have an effect on the dimensions of the planes. But your tool seems to behave a bit different. It is more like polygons in Eagle for example, where the outline of polygons is defined by a line with a specified thickness. If I assume the "Minimum Width"-Parameter is used as thickness of this line it makes sense to me, because:

  • The distance between the polygons is 0.2mm
  • my specified "Minimum Width" is 0.2mm, so the "line" would exceed the "original" outline of the polygon by 0.1mm on each side, causing the perfect "matching" of both outlines shown above
  • reducing the line thickness to "Minimum Width" = 0.0254mm reduces the exceed to only 0.0127mm per side, which leads to a 0.2mm - 2 * 0.0127mm = 0.1746mm gap, which can be seen in the second FreeCAD picture above

Do you want me to send you the example pcb-file via mail?

TheRealTobiwan avatar Jul 20 '22 08:07 TheRealTobiwan

I am using your code to extract the copper traces from my pcb's for FEM simulations

@TheRealTobiwan do you use FreeCAD for your FEM simulations?

easyw avatar Jul 20 '22 10:07 easyw

@easyw No, I am just using realthunder's tool to extract the copper from my pcb's and then convert it with FreeCAD to a format that my other tools can use (I am using HFSS, Q3D and other tools for the analysis).

TheRealTobiwan avatar Jul 20 '22 10:07 TheRealTobiwan

@TheRealTobiwan thanks for your info... I was hoping to get some tips to do FEM in FC

easyw avatar Jul 20 '22 10:07 easyw

Yes, please send me a sample file. I am pretty sure KiCAD used to use Minimum width to inflate the zone for reasons discussed in the thread I quoted last time. I even have a code comment for this quite confusing behavior. We need to find out when did KiCAD changed meaning of this option, and if there is any other attribute ensuring backward compatibility.

BTW, as a temporary fix, you can pass a zone_inflate parameter when creating pcb to counter the minimum width inflation, like below assuming your minimum width setting is 0.2,

pcb = kicad.KicadFcad(<full_path_to_your_kicad_pcb_file>, zone_inflate=-0.1)

You can change zone_inflate any time. It basically let you manually shrink or expand the zone.

pcb.zone_inflate = -0.2

realthunder avatar Jul 20 '22 14:07 realthunder

Hi realthunder,

I'm joining the "party" because I have the same problem and like to share my findings: in <kicad.py> line 1869 you add a "thickness*0.5" to the offset (in the version before it was "z.min_thickness"). IMHO this is erroneous and can be deleted. Eg: In KiCAD my copper zone aligns exactly with the pad (what I wand): kiCAD

When importing the pcb in FreeCAD the copper zone is slightly to big (exactly 0.025mm or "thickness*0.5"). freecad

from what I read in your older version of <kicad.py>, I think there was a misunderstanding of what the purpose of "minimum with" (which fills the variable z.min_thickness) in the copper zone properties is.

If you have compatibility concerns, couldn't you use the version date saved in the first line of *.kicad_pcb to make an "if..else" decision: compatibility mode or not?

juddidier avatar Oct 17 '22 12:10 juddidier