Added copper_thickness option

- Now we get some defaults from KiCad 6 stackup
This commit is contained in:
Salvador E. Tropea 2022-01-17 18:50:21 -03:00
parent 1d1abf0ce4
commit 7a4c3468fa
10 changed files with 97 additions and 7 deletions

View File

@ -10,6 +10,7 @@ from .pre_filters import FiltersOptions
from .log import get_logger, set_filters
from .misc import W_MUSTBEINT
from .kicad.sexpdata import load, SExpData, sexp_iter, Symbol
from .kicad.v6_sch import PCBLayer
class Globals(FiltersOptions):
@ -55,6 +56,7 @@ class Globals(FiltersOptions):
Read `solder_mask_color` help """
self.silk_screen_color = 'white'
""" Color for the markings. Currently used for documentation and to choose default colors.
KiCad 6: you should set this in the Board Setup -> Physical Stackup.
Currently known are black and white """
self.silk_screen_color_top = ''
""" Color for the top silk screen. When not defined `silk_screen_color` is used.
@ -78,6 +80,9 @@ class Globals(FiltersOptions):
KiCad 6: you should set this in the Board Setup -> Board Finish -> Plated board edge """
self.copper_finish = None
""" {pcb_finish} """
self.copper_thickness = 35
""" Copper thickness in micrometers (1 Oz is 35 micrometers).
KiCad 6: you should set this in the Board Setup -> Physical Stackup """
self.set_doc('filters', " [list(dict)] KiBot warnings to be ignored ")
self._filter_what = 'KiBot warnings'
self._unkown_is_error = True
@ -111,6 +116,9 @@ class Globals(FiltersOptions):
if sp is None:
return
logger.debug("- Found stack-up information")
stackup = []
materials = set()
thicknesses = set()
for e in sp[1:]:
if isinstance(e, list) and isinstance(e[0], Symbol):
name = e[0].value()
@ -132,6 +140,45 @@ class Globals(FiltersOptions):
elif name == 'edge_plating':
self.edge_plating = value == 'yes'
logger.debug("- Edge plating: "+value)
elif name == 'layer':
ly = PCBLayer.parse(e)
stackup.append(ly)
if ly.name == "F.SilkS":
if ly.color:
self.silk_screen_color_top = ly.color.lower()
logger.debug("- F.SilkS color: "+ly.color)
elif ly.name == "B.SilkS":
if ly.color:
self.silk_screen_color_bottom = ly.color.lower()
logger.debug("- B.SilkS color: "+ly.color)
elif ly.name == "F.Mask":
if ly.color:
self.solder_mask_color_top = ly.color.lower()
logger.debug("- F.Mask color: "+ly.color)
elif ly.name == "B.Mask":
if ly.color:
self.solder_mask_color_bottom = ly.color.lower()
logger.debug("- B.Mask color: "+ly.color)
elif ly.material:
if not len(materials):
materials.add(ly.material)
self.pcb_material = ly.material
elif ly.material not in materials:
materials.add(ly.material)
self.pcb_material += ' / '+ly.material
elif ly.type == 'copper' and ly.thickness:
if not len(thicknesses):
thicknesses.add(ly.thickness)
self.copper_thickness = str(int(ly.thickness*1000))
elif ly.thickness not in thicknesses:
thicknesses.add(ly.thickness)
self.copper_thickness += ' / '+str(int(ly.thickness*1000))
if stackup:
GS.stackup = stackup
if len(materials):
logger.debug("- PCB Material/s: "+self.pcb_material)
if len(thicknesses):
logger.debug("- Copper thickness: "+self.copper_thickness)
def config(self, parent):
if GS.ki6() and GS.pcb_file and os.path.isfile(GS.pcb_file):

View File

@ -94,10 +94,12 @@ class GS(object):
global_silk_screen_color_top = None
global_silk_screen_color_bottom = None
global_pcb_finish = None
global_copper_thickness = None
global_edge_connector = None
global_castellated_pads = None
global_edge_plating = None
test_boolean = True
stackup = None
@staticmethod
def set_sch(name):

View File

@ -1386,6 +1386,43 @@ class SymbolInstance(object):
return _symbol('path', data)
# Here because we have al s-expr tools here
class PCBLayer(object):
def __init__(self):
super().__init__()
self.name = ''
self.type = ''
self.color = None
self.thickness = None
self.material = None
self.epsilon_r = None
self.loss_tangent = None
@staticmethod
def parse(items):
name = 'PCB stackup layer'
layer = PCBLayer()
layer.name = _check_str(items, 1, name)
for c, i in enumerate(items[2:]):
i_type = _check_is_symbol_list(i)
tname = name+' '+i_type
if i_type == 'type':
layer.type = _check_str(i, 1, tname)
elif i_type == 'color':
layer.color = _check_str(i, 1, tname)
elif i_type == 'thickness':
layer.thickness = _check_float(i, 1, tname)
elif i_type == 'material':
layer.material = _check_str(i, 1, tname)
elif i_type == 'epsilon_r':
layer.epsilon_r = _check_float(i, 1, tname)
elif i_type == 'loss_tangent':
layer.loss_tangent = _check_float(i, 1, tname)
else:
logger.warning('Unknown layer attribute `{}`'.format(i))
return layer
def _symbol(name, content):
return [Symbol(name)] + content

View File

@ -495,6 +495,7 @@ class ReportOptions(BaseOptions):
self.edge_connector = solve_edge_connector(GS.global_edge_connector)
self.castellated_pads = GS.global_castellated_pads
self.edge_plating = GS.global_edge_plating
self.copper_thickness = GS.global_copper_thickness
self.collect_data(GS.board)
self.do_template(self.template, fname)

View File

@ -6,6 +6,7 @@ Board size: ${bb_w_mm}x${bb_h_mm} mm (${bb_w_in}x${bb_h_in} inches)
- Material: ${pcb_material}
- Finish: ${pcb_finish}
- Layers: ${layers}
- Copper thickness: ${copper_thickness} µm
Solder mask: ${solder_mask}
- Color: ${solder_mask_color_text}
Silk screen: ${silk_screen}

View File

@ -22,7 +22,7 @@ Materials:
- ${pcb_material}, ${thickness_mm} mm
- ${pcb_finish}
- ${layers} layers
- 35 µm copper thickness
- ${copper_thickness} µm copper thickness
Solder mask:
- ${solder_mask}

View File

@ -37,9 +37,9 @@
(setup
(stackup
(layer "F.SilkS" (type "Top Silk Screen"))
(layer "F.SilkS" (type "Top Silk Screen") (color "White"))
(layer "F.Paste" (type "Top Solder Paste"))
(layer "F.Mask" (type "Top Solder Mask") (thickness 0.01))
(layer "F.Mask" (type "Top Solder Mask") (color "Blue") (thickness 0.01))
(layer "F.Cu" (type "copper") (thickness 0.035))
(layer "dielectric 1" (type "core") (thickness 0.48) (material "FR4") (epsilon_r 4.5) (loss_tangent 0.02))
(layer "In1.Cu" (type "copper") (thickness 0.035))
@ -47,9 +47,9 @@
(layer "In2.Cu" (type "copper") (thickness 0.035))
(layer "dielectric 3" (type "core") (thickness 0.48) (material "FR4") (epsilon_r 4.5) (loss_tangent 0.02))
(layer "B.Cu" (type "copper") (thickness 0.035))
(layer "B.Mask" (type "Bottom Solder Mask") (thickness 0.01))
(layer "B.Mask" (type "Bottom Solder Mask") (color "Red") (thickness 0.01))
(layer "B.Paste" (type "Bottom Solder Paste"))
(layer "B.SilkS" (type "Bottom Silk Screen"))
(layer "B.SilkS" (type "Bottom Silk Screen") (color "Black"))
(copper_finish "ENIG")
(dielectric_constraints no)
(edge_connector bevelled)

View File

@ -6,6 +6,7 @@ Board size: 59.69x48.26 mm (2.35x1.9 inches)
- Material: FR4
- Finish: ENIG
- Layers: 4
- Copper thickness: 35 µm
Solder mask: TOP / BOTTOM
- Color: Top: Blue / Bottom: Red
Silk screen: TOP / BOTTOM

View File

@ -6,10 +6,11 @@ Board size: 59.69x48.26 mm (2.35x1.9 inches)
- Material: FR4
- Finish: ENIG
- Layers: 4
- Copper thickness: 35 µm
Solder mask: TOP / BOTTOM
- Color: Top: Blue / Bottom: Red
Silk screen: TOP / BOTTOM
- Color: White
- Color: Top: White / Bottom: Black
Special features:
- Edge connector: yes, bevelled

View File

@ -26,7 +26,7 @@ Solder mask:
Marking:
- TOP / BOTTOM screen printing
- Silk: White
- Silk: Top: White / Bottom: Black
Other markings:
- ROHS / UL / Date - Yes if available