From 4da38de4a8ad05a1b18b3d37ddfbe11fe1b755a8 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Tue, 28 Feb 2023 06:17:20 -0300 Subject: [PATCH] [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 --- CHANGELOG.md | 7 +- README.md | 6 +- kibot/globals.py | 5 + kibot/gs.py | 1 + kibot/pre_run_erc.py | 4 +- src/kibot-check | 6 +- .../board_samples/kicad_7/off-grid.kicad_sch | 93 +++++++++++++++++++ tests/test_plot/test_preflight.py | 13 +++ tests/yaml_samples/erc_grid_25.kibot.yaml | 14 +++ 9 files changed, 140 insertions(+), 9 deletions(-) create mode 100644 tests/board_samples/kicad_7/off-grid.kicad_sch create mode 100644 tests/yaml_samples/erc_grid_25.kibot.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d3d8bc3..5074a3eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.6.1] - UNRELEASED ### Added - 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: - - Counters for total vias and by via type (vias_count, thru_vias_count, - blind_vias_count and micro_vias_count) + - Counters for total vias and by via type (`vias_count`, `thru_vias_count`, + `blind_vias_count` and `micro_vias_count`) - Warnings when micro and/or blind vias aren't allowed, but we found them. ### Fixed diff --git a/README.md b/README.md index 001e3b86..d7cf1257 100644 --- a/README.md +++ b/README.md @@ -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) - 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` - Optional to: - 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. - `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. + - `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. 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/. diff --git a/kibot/globals.py b/kibot/globals.py index d83f6120..72b697a6 100644 --- a/kibot/globals.py +++ b/kibot/globals.py @@ -251,6 +251,11 @@ class Globals(FiltersOptions): self.allow_microvias = True """ 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 """ + 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._filter_what = 'KiBot warnings' self.filters = FilterOptionsKiBot diff --git a/kibot/gs.py b/kibot/gs.py index 555ddf53..ca6f6934 100644 --- a/kibot/gs.py +++ b/kibot/gs.py @@ -166,6 +166,7 @@ class GS(object): # Only for v7+ global_allow_blind_buried_vias = None global_allow_microvias = None + global_erc_grid = None @staticmethod def set_sch(name): diff --git a/kibot/pre_run_erc.py b/kibot/pre_run_erc.py index 6fdc33e6..032da240 100644 --- a/kibot/pre_run_erc.py +++ b/kibot/pre_run_erc.py @@ -8,7 +8,7 @@ Dependencies: - from: KiAuto role: mandatory command: eeschema_do - version: 1.5.4 + version: 2.2.1 """ import os from sys import exit @@ -53,7 +53,7 @@ class Run_ERC(BasePreFlight): # noqa: F821 output = self.get_targets()[0] os.makedirs(os.path.dirname(output), exist_ok=True) 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 cmd.append('-w') if GS.filter_file: diff --git a/src/kibot-check b/src/kibot-check index 3e732393..8f932bf7 100755 --- a/src/kibot-check +++ b/src/kibot-check @@ -584,9 +584,9 @@ deps = '{\ "max_version": null,\ "output": "run_erc",\ "version": [\ - 1,\ - 5,\ - 4\ + 2,\ + 2,\ + 1\ ]\ },\ {\ diff --git a/tests/board_samples/kicad_7/off-grid.kicad_sch b/tests/board_samples/kicad_7/off-grid.kicad_sch new file mode 100644 index 00000000..3e8fcec2 --- /dev/null +++ b/tests/board_samples/kicad_7/off-grid.kicad_sch @@ -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")) + ) +) diff --git a/tests/test_plot/test_preflight.py b/tests/test_plot/test_preflight.py index fc6b2344..b34d5f55 100644 --- a/tests/test_plot/test_preflight.py +++ b/tests/test_plot/test_preflight.py @@ -80,6 +80,19 @@ def test_erc_warning_2(test_dir): 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): prj = name = 'bom' if context.ki7(): diff --git a/tests/yaml_samples/erc_grid_25.kibot.yaml b/tests/yaml_samples/erc_grid_25.kibot.yaml new file mode 100644 index 00000000..13c58c6b --- /dev/null +++ b/tests/yaml_samples/erc_grid_25.kibot.yaml @@ -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: ''