INTI-CMNB / KiBot

KiCad automation utility
GNU Affero General Public License v3.0
534 stars 64 forks source link

[FEATURE] Add Testpoint report output #638

Open CraigBurden opened 3 weeks ago

CraigBurden commented 3 weeks ago

There is a great tool by @snhobbs, that generates a testpoint report, cataloging all testpoints and a few useful bit of information about each.

https://github.com/snhobbs/kicad-testpoints

Test points are typically marked as "exclude_from_bom" and so do not appear on a BOM, as they typically should not. But when designing a test fixture for a board this information is needed.

Adding the test report generator to the available outputs so that it can be generated along with all other outputs when a PCB release is made

snhobbs commented 3 weeks ago

Thanks for the shoutout! Looks like the links screwed up above, this is it: https://github.com/snhobbs/kicad-testpoints.

There's a PCM plugin up in the plugin repo also, here's that link https://github.com/snhobbs/kicad-testpoints-pcm.

CraigBurden commented 3 weeks ago

@snhobbs Good catch and its an absolute pleasure! I love the plug-in!

FYI, I have edited the original post too, just in case :)

set-soft commented 3 weeks ago

Hi @CraigBurden and @snhobbs !

The idea is interesting, currently you can ask KiBot to generate a BoM with component coordinates, so I think most of the information is already available.

I found that the link to JigsApp at the beginning of the kicad-testpoints is wrong, should be https://www.thejigsapp.com/ Missing http:// and a typo, is ok in the links section.

CraigBurden commented 3 weeks ago

@set-soft Thanks for the feedback, I haven't tried that within KiBot yet, but my experience of all the other BOM tools out there like KiBOM and the integrated BOM tools in KiCAD is that they do not do what we need.

The reason is that test points typically have the "exclude_from_bom" and/or dnp attributes set. This means that they are removed from the BOM outputs. The former exclusion is impossible to bypass in those tools.

set-soft commented 3 weeks ago

The reason is that test points typically have the "exclude_from_bom"

In KiBot you can use exclude_marked_in_sch: false to avoid it.

and/or dnp attributes set.

In KiBot you can use ignore_dnf: false to avoid it.

This means that they are removed from the BOM outputs. The former exclusion is impossible to bypass in those tools.

But in KiBot you can ;-) You can also change the default filters, that will remove test points just because they use TP* as reference, or its name matches 'test.*point

In addition you can get center coordinates of the component, here is an example:

kibot:
  version: 1

filters:
  - name: only_testpoints
    comment: "Select only testpoints"
    type: generic
    include_only:
      - column: Value
        regex: "^TestPoint"

outputs:
  - name: testpoints
    comment: "Testpoint report"
    type: bom
    options:
      pre_transform: ['_kicost_rename', '_rot_footprint']
      exclude_filter: 'only_testpoints'
      dnf_filter: '_none'
      exclude_marked_in_sch: false
      group_fields: []
      sort_style: ref
      use_aux_axis_as_origin: true
      ignore_dnf: false
      format: CSV
      columns:
        - field: References
          name: Designator
        - field: Footprint X
          name: X-Loc
        - field: Footprint Y
          name: Y-Loc
        - field: Footprint Side
          name: Side
        - field: Footprint Type
          name: Type
        - field: Value
        - field: Footprint

Here is an example: example_testpoints.zip

And you get:

Designator,X-Loc,Y-Loc,Side,Type,Value,Footprint
TP1,105.0000,-65.0000,top,THT,TestPoint,TestPoint_Loop_D1.80mm_Drill1.0mm_Beaded
TP2,120.0000,-65.0000,top,SMD,TestPoint_Alt,TestPoint_Pad_1.0x1.0mm
TP3,132.0000,-65.0000,top,THT,TestPoint_Flag,TestPoint_Plated_Hole_D2.0mm
TP4,142.0000,-71.0000,top,SMD,TestPoint_Probe,TestPoint_Pad_D2.0mm
Wrong_Reference1,140.0000,-87.0000,top,SMD,TestPoint_Small,TestPoint_Pad_D1.0mm

Project info:
Schematic:,test_points
Variant:,default
Revision:,
Date:,2024-07-04_11-15-47
KiCad Version:,8.0.3+1
Statistics:
Component Groups:,5
Component Count:,5
Fitted Components:,4
Number of PCBs:,1
Total Components:,4
snhobbs commented 3 weeks ago

Oh that's interesting, can it do pads as well as footprints or does it need to be an actual standalone footprint?

CraigBurden commented 3 weeks ago

@set-soft, @snhobbs asks a good question. Often we want to land spring pins on pads of footprints with more than one pad. Your suggestion assumes the footpoint centre is the same as the pad centre and that there is only a single pad?

For example: image This footprint has 8 pads, none of which are on the centre of the footprint itself

To be clear, the way that @snhobbs's plug-in decides on what pads to add to the report has nothing to do with the name/value/reference of the footprint, its driven by fabrication attributes on pads. So I can add this attribute to any pad on any footprint. Hence I can land pins on the THT pins below a RJ45 connector if I want to as well as all the dedicated test points

set-soft commented 3 weeks ago

@set-soft, @snhobbs asks a good question. Often we want to land spring pins on pads of footprints with more than one pad. Your suggestion assumes the footpoint centre is the same as the pad centre and that there is only a single pad?

Yes, this is what a testpoint is ;-)

To be clear, the way that @snhobbs's plug-in decides on what pads to add to the report has nothing to do with the name/value/reference of the footprint, its driven by fabrication attributes on pads. So I can add this attribute to any pad on any footprint. Hence I can land pins on the THT pins below a RJ45 connector if I want to as well as all the dedicated test points

This looks like the job for a transformation filter.

set-soft commented 3 weeks ago

An important note: the attribute used for "nail of beds" seems to be quite orthogonal in KiCad. None of the library testpoints has this attribute.

snhobbs commented 3 weeks ago

Yeah, I've found using only testpoint parts to be too restricting. They're still the first line of attack for sure but the idea is to implement the same feature other EDA suite have (see altium's https://www.altium.com/documentation/altium-designer/adding-testpoints-pcb). Doing this with the fabrication option is a bit cheeky but I can't find a good reason against using it. The command line tool can use either the fabrication setting of the pad or a config file with the ref des & pad number.

CraigBurden commented 2 weeks ago

Yeah, I've found using only testpoint parts to be too restricting. They're still the first line of attack for sure but the idea is to implement the same feature other EDA suite have (see altium's https://www.altium.com/documentation/altium-designer/adding-testpoints-pcb). Doing this with the fabrication option is a bit cheeky but I can't find a good reason against using it. The command line tool can use either the fabrication setting of the pad or a config file with the ref des & pad number.

Agreed, the only alternative that I have explored in the past is to select the centroid of all mask openings on a top or bottom layer. That works okay when you have a side that only has openings that you want to land on, but when there you have assembly and test lands mixed it gets very messy.

@set-soft The fabrication attribute is not set by default on the build-in libraries, but since I started using @snhobbs's library I have just set the attributes in my personal library. The complexity is that you often what to land test pins on points that aren't "officially" test points. For example I regularly use convex tipped test pins to connect to the THT pins under a connector similar to what I showed above. This is very common. So the solution of how to designate what co-ordinates are added to the report needs to be flexible to allow that. I feel like despite the fact that the build-in libraries don't set the attribute by default, this is still the best option that is available to us. The "correct" solution in my mind is an interactive selection tool within the KiCAD UI, but that would likely never happen

set-soft commented 2 weeks ago

I feel like despite the fact that the build-in libraries don't set the attribute by default, this is still the best option that is available to us.

I agree

set-soft commented 1 week ago

Hi @snhobbs !

The command line tool can use either the fabrication setting of the pad or a config file with the ref des & pad number.

How about the side for THT components? You only know the footprint side ...

snhobbs commented 1 week ago

The tool pulls out the pad locations as well as the pad side, pad type (THT vs SMT), and the component side. This tool doesn't mess with the sides at all but the tools we use to generate jigs by default chooses the opposite side of the THT part as the probing side. I could imagine a few times where there would be some ambiguity there but it would be very rare.

set-soft commented 1 week ago

Ok, the above patch adds a suitable filter, running src/kibot -c tests/yaml_samples/test_points_2.kibot.yaml -b tests/board_samples/kicad_8/test_points.kicad_pcb I'm getting:

image

Which is similar to what @snhobbs CLI tool is generating:

image

snhobbs commented 1 week ago

Nice!