This document introduces how to use fcad_pcb to export copper layers and vias to Freecad and then output to 3d step file for FEM analysis.
Reference:
GitHub - realthunder/fcad_pcb: FreeCAD scripts for PCB CAD/CAM
Requirement FreeCAD >= v0.17
Download fcad_pcb from the github link fcad_pcb.rar (github.com).
Extract and put fcad_pcb folder into the FreeCAD macro folder. This folder can be opened in freecad macros setting shown below. (e.g.: D:\Users\...\Roaming\FreeCAD\Macro)
Enable python console.
Create a new macro:
and then type these codes:
from fcad_pcb import kicad
pcb = kicad.KicadFcad(r'your file location')
# e.g.: pcb = kicad.KicadFcad(r'D:\...\layout.kicad_pcb')
#pcb.makeCoppers()
# zone_inflate = 0.5*minimum trace width of the zones
pcb.add_feature = False
coppers = pcb.makeCoppers(shape_type='solid', holes=True, fuse=True)
# fuse means to make vias
Part.show(coppers)
Change 'your file location' to your model's location then click Run. The solid copper layers will be created including the Vias.
If Kicad cannot find fcad_pcb, consider mannually add path, see trouble shooting below.
In case pads are needed (for assigning source and sink), we can use the plugin KiCadStepUP. Kicad Stepup - A freecad plugin
It can read the tracks from the layout file, then unite the copper layers with the pads.
Blind vias and burried vias are supported. Minimal via hole 0.08mm.
the thickness of the vias is 35um ![[Pasted image 20230523122416.png]] section view ![[Pasted image 20230523122345.png]]
Reference: inconsistent shape of via after applying pcb.via_bound=1 · Issue #38 · realthunder/fcad_pcb · GitHub
Simplify vias · Issue #22 · realthunder/fcad_pcb · GitHub
For complex model, the vias need to be simplifed to speed up the simulation, if the dimension of the vias does not obviously affect the result, e.g. compared with skin depth.
The vias can be simplifed with these codes:
from fcad_pcb import kicad
pcb = kicad.KicadFcad(r'D:\...\test.kicad_pcb')
pcb.add_feature = False
pcb.via_bound = 0.7862
pcb.zone_inflate = -0.1
coppers = pcb.makeCoppers(shape_type='solid', fuse=True)
Part.show(coppers)
pcb.via_bound = Ratio Ratio means the ratio between the square via and circular via hole diameter.
For example: diameter = 130um, via thickness = 35um
pcb.zone_inflate: to minus the zone inflate from KiCaD, which may cause zone mistakenly intersect
Comparison between normal vias and simplified vias. (holes also removed from the copper layers) ![[Pasted image 20230524125939.png|500]] The amount of the mesh is reduced 20 times with the same mesh operations.
If possible, minimal width 0.0254mm, as small as possible
We can mannually add path into the macro file
import sys
sys.path.append(r'C:\users\...\Roaming\FreeCAD\Macro')
# To double check
print(sys.path)
It could be also possible that freecad cannot find module 'future'. We can also manually download it and put into the macro document.
(Not sure) It is related to the layout itself. Probably, the exported model cannot be transformed into a shape.
The size of the via is too small. 0.31,0.13 is acceptable
Another possible reason is ill-defined vias. E.g. a micro via is defined as a burried via can also cause this problem.
Could be a via issue. Could try change micro vias to through hole vias.
Could be no pads on the top and bottom layers. Leave some components at top and bottom layers with pads (not necessarily connected) could help to solve this issue.