[ERC][KiCad 7] Added option to specify the grid size

- `erc_grid` to specify the grid size for KiCad 7 ERC tests

See https://gitlab.com/kicad/code/kicad/-/issues/14110
This commit is contained in:
Salvador E. Tropea 2023-02-28 06:17:20 -03:00
parent b16bb533ea
commit 4da38de4a8
9 changed files with 140 additions and 9 deletions

View File

@ -7,10 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [1.6.1] - UNRELEASED ## [1.6.1] - UNRELEASED
### Added ### Added
- Global options: - Global options:
- allow_blind_buried_vias and allow_microvias for KiCad 7 (no longer in KiCad) - `allow_blind_buried_vias` and `allow_microvias` for KiCad 7 (no longer in KiCad)
- `erc_grid` to specify the grid size for KiCad 7 ERC tests
- Report: - Report:
- Counters for total vias and by via type (vias_count, thru_vias_count, - Counters for total vias and by via type (`vias_count`, `thru_vias_count`,
blind_vias_count and micro_vias_count) `blind_vias_count` and `micro_vias_count`)
- Warnings when micro and/or blind vias aren't allowed, but we found them. - Warnings when micro and/or blind vias aren't allowed, but we found them.
### Fixed ### Fixed

View File

@ -136,7 +136,7 @@ Notes:
[**Requests**](https://pypi.org/project/Requests/) [![Python module](https://raw.githubusercontent.com/INTI-CMNB/KiBot/master/docs/images/Python-logo-notext-22x22.png)](https://pypi.org/project/Requests/) [![PyPi dependency](https://raw.githubusercontent.com/INTI-CMNB/KiBot/master/docs/images/PyPI_logo_simplified-22x22.png)](https://pypi.org/project/Requests/) [![Debian](https://raw.githubusercontent.com/INTI-CMNB/KiBot/master/docs/images/debian-openlogo-22x22.png)](https://packages.debian.org/bullseye/python3-requests) [**Requests**](https://pypi.org/project/Requests/) [![Python module](https://raw.githubusercontent.com/INTI-CMNB/KiBot/master/docs/images/Python-logo-notext-22x22.png)](https://pypi.org/project/Requests/) [![PyPi dependency](https://raw.githubusercontent.com/INTI-CMNB/KiBot/master/docs/images/PyPI_logo_simplified-22x22.png)](https://pypi.org/project/Requests/) [![Debian](https://raw.githubusercontent.com/INTI-CMNB/KiBot/master/docs/images/debian-openlogo-22x22.png)](https://packages.debian.org/bullseye/python3-requests)
- Mandatory - Mandatory
[**KiCad Automation tools**](https://github.com/INTI-CMNB/KiAuto) v2.2.0 [![Tool](https://raw.githubusercontent.com/INTI-CMNB/KiBot/master/docs/images/llave-inglesa-22x22.png)](https://github.com/INTI-CMNB/KiAuto)![PyPi dependency](https://raw.githubusercontent.com/INTI-CMNB/KiBot/master/docs/images/PyPI_logo_simplified-22x22.png) ![Auto-download](https://raw.githubusercontent.com/INTI-CMNB/KiBot/master/docs/images/auto_download-22x22.png) [**KiCad Automation tools**](https://github.com/INTI-CMNB/KiAuto) v2.2.1 [![Tool](https://raw.githubusercontent.com/INTI-CMNB/KiBot/master/docs/images/llave-inglesa-22x22.png)](https://github.com/INTI-CMNB/KiAuto)![PyPi dependency](https://raw.githubusercontent.com/INTI-CMNB/KiBot/master/docs/images/PyPI_logo_simplified-22x22.png) ![Auto-download](https://raw.githubusercontent.com/INTI-CMNB/KiBot/master/docs/images/auto_download-22x22.png)
- Mandatory for: `dxf_sch_print`, `gencad`, `hpgl_sch_print`, `netlist`, `pdf_pcb_print`, `pdf_sch_print`, `ps_sch_print`, `render_3d`, `run_drc`, `run_erc`, `step`, `svg_pcb_print`, `svg_sch_print`, `update_xml`, `vrml` - Mandatory for: `dxf_sch_print`, `gencad`, `hpgl_sch_print`, `netlist`, `pdf_pcb_print`, `pdf_sch_print`, `ps_sch_print`, `render_3d`, `run_drc`, `run_erc`, `step`, `svg_pcb_print`, `svg_sch_print`, `update_xml`, `vrml`
- Optional to: - Optional to:
- Compare schematics for `diff` (v2.2.0) - Compare schematics for `diff` (v2.2.0)
@ -785,6 +785,10 @@ global:
- `templates`: [string=''] System level templates dir. KiCad 5: KICAD_TEMPLATE_DIR. KiCad 6: KICAD6_TEMPLATE_DIR. - `templates`: [string=''] System level templates dir. KiCad 5: KICAD_TEMPLATE_DIR. KiCad 6: KICAD6_TEMPLATE_DIR.
- `third_party`: [string=''] 3rd party dir. KiCad 6: KICAD6_3RD_PARTY. - `third_party`: [string=''] 3rd party dir. KiCad 6: KICAD6_3RD_PARTY.
- `user_templates`: [string=''] User level templates dir. KiCad 5/6: KICAD_USER_TEMPLATE_DIR. - `user_templates`: [string=''] User level templates dir. KiCad 5/6: KICAD_USER_TEMPLATE_DIR.
- `erc_grid`: [number=50] Grid size used for the ERC. This value must be in mils.
This is needed for KiCad 7 in order to run the off grid check.
Shouldn't be needed in KiCad 8.
https://gitlab.com/kicad/code/kicad/-/issues/14110.
- `extra_pth_drill`: [number=0.1] How many millimeters the manufacturer will add to plated holes. - `extra_pth_drill`: [number=0.1] How many millimeters the manufacturer will add to plated holes.
This is because the plating reduces the hole, so you need to use a bigger drill. This is because the plating reduces the hole, so you need to use a bigger drill.
For more information consult: https://www.eurocircuits.com/pcb-design-guidelines/drilled-holes/. For more information consult: https://www.eurocircuits.com/pcb-design-guidelines/drilled-holes/.

View File

@ -251,6 +251,11 @@ class Globals(FiltersOptions):
self.allow_microvias = True self.allow_microvias = True
""" Allow the use of micro vias. This value is only used for KiCad 7+. """ Allow the use of micro vias. This value is only used for KiCad 7+.
For KiCad 5 and 6 use the design rules settings, stored in the project """ For KiCad 5 and 6 use the design rules settings, stored in the project """
self.erc_grid = 50
""" Grid size used for the ERC. This value must be in mils.
This is needed for KiCad 7 in order to run the off grid check.
Shouldn't be needed in KiCad 8.
https://gitlab.com/kicad/code/kicad/-/issues/14110 """
self.set_doc('filters', " [list(dict)] KiBot warnings to be ignored ") self.set_doc('filters', " [list(dict)] KiBot warnings to be ignored ")
self._filter_what = 'KiBot warnings' self._filter_what = 'KiBot warnings'
self.filters = FilterOptionsKiBot self.filters = FilterOptionsKiBot

View File

@ -166,6 +166,7 @@ class GS(object):
# Only for v7+ # Only for v7+
global_allow_blind_buried_vias = None global_allow_blind_buried_vias = None
global_allow_microvias = None global_allow_microvias = None
global_erc_grid = None
@staticmethod @staticmethod
def set_sch(name): def set_sch(name):

View File

@ -8,7 +8,7 @@ Dependencies:
- from: KiAuto - from: KiAuto
role: mandatory role: mandatory
command: eeschema_do command: eeschema_do
version: 1.5.4 version: 2.2.1
""" """
import os import os
from sys import exit from sys import exit
@ -53,7 +53,7 @@ class Run_ERC(BasePreFlight): # noqa: F821
output = self.get_targets()[0] output = self.get_targets()[0]
os.makedirs(os.path.dirname(output), exist_ok=True) os.makedirs(os.path.dirname(output), exist_ok=True)
logger.debug('ERC report: '+output) logger.debug('ERC report: '+output)
cmd = [command, 'run_erc', '-o', output] cmd = [command, 'run_erc', '-o', output, '-g', str(GS.global_erc_grid)]
if BasePreFlight.get_option('erc_warnings'): # noqa: F821 if BasePreFlight.get_option('erc_warnings'): # noqa: F821
cmd.append('-w') cmd.append('-w')
if GS.filter_file: if GS.filter_file:

View File

@ -584,9 +584,9 @@ deps = '{\
"max_version": null,\ "max_version": null,\
"output": "run_erc",\ "output": "run_erc",\
"version": [\ "version": [\
1,\ 2,\
5,\ 2,\
4\ 1\
]\ ]\
},\ },\
{\ {\

View File

@ -0,0 +1,93 @@
(kicad_sch (version 20230121) (generator eeschema)
(uuid 6f532429-0896-42e9-8f7d-55f1e3ab1171)
(paper "A4")
(lib_symbols
(symbol "Device:R" (pin_numbers hide) (pin_names (offset 0)) (in_bom yes) (on_board yes)
(property "Reference" "R" (at 2.032 0 90)
(effects (font (size 1.27 1.27)))
)
(property "Value" "R" (at 0 0 90)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "" (at -1.778 0 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_keywords" "R res resistor" (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_description" "Resistor" (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_fp_filters" "R_*" (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(symbol "R_0_1"
(rectangle (start -1.016 -2.54) (end 1.016 2.54)
(stroke (width 0.254) (type default))
(fill (type none))
)
)
(symbol "R_1_1"
(pin passive line (at 0 3.81 270) (length 1.27)
(name "~" (effects (font (size 1.27 1.27))))
(number "1" (effects (font (size 1.27 1.27))))
)
(pin passive line (at 0 -3.81 90) (length 1.27)
(name "~" (effects (font (size 1.27 1.27))))
(number "2" (effects (font (size 1.27 1.27))))
)
)
)
)
(wire (pts (xy 161.925 38.1) (xy 161.925 45.72))
(stroke (width 0) (type default))
(uuid 511cb90c-9c72-4b77-aff9-f6affb9d333a)
)
(wire (pts (xy 165.735 38.1) (xy 161.925 38.1))
(stroke (width 0) (type default))
(uuid 659e802d-922c-460c-9d90-71ca26b9b1b0)
)
(wire (pts (xy 161.925 45.72) (xy 165.735 45.72))
(stroke (width 0) (type default))
(uuid b365109d-87cc-4f98-affd-eaffb73c3dba)
)
(symbol (lib_id "Device:R") (at 165.735 41.91 0) (unit 1)
(in_bom yes) (on_board yes) (dnp no) (fields_autoplaced)
(uuid 08cbd42b-5f2a-4de7-b48e-3bd4b6c520d0)
(property "Reference" "R1" (at 168.275 41.275 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Value" "R" (at 168.275 43.815 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Footprint" "" (at 163.957 41.91 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (at 165.735 41.91 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid 42622943-c02d-4a96-9a8b-08cf61caa6e6))
(pin "2" (uuid 5a1dcc55-9ffd-4afd-aeaa-50f889f94480))
(instances
(project "pp"
(path "/6f532429-0896-42e9-8f7d-55f1e3ab1171"
(reference "R1") (unit 1)
)
)
)
)
(sheet_instances
(path "/" (page "1"))
)
)

View File

@ -80,6 +80,19 @@ def test_erc_warning_2(test_dir):
ctx.clean_up() ctx.clean_up()
@pytest.mark.slow
@pytest.mark.eeschema
@pytest.mark.skipif(not context.ki7(), reason="KiCad 7 off grid check")
def test_erc_off_grid_1(test_dir):
""" ERC using 25 mils grid """
prj = 'off-grid'
ctx = context.TestContextSCH(test_dir, prj, 'erc_grid_25')
ctx.run()
# Check all outputs are there
ctx.expect_out_file(prj+'-erc.txt', sub=True)
ctx.clean_up()
def test_drc_1(test_dir): def test_drc_1(test_dir):
prj = name = 'bom' prj = name = 'bom'
if context.ki7(): if context.ki7():

View File

@ -0,0 +1,14 @@
# Example KiBot config file
kibot:
version: 1
global:
erc_grid: 25
preflight:
run_erc: true
erc_warnings: true
filters:
- filter: 'Ignore KiCad 6 lib_symbol_issues'
error: lib_symbol_issues
regex: ''