kicad-action-scripts icon indicating copy to clipboard operation
kicad-action-scripts copied to clipboard

A new valid placement area calculation method

Open m-schubert opened this issue 3 years ago • 8 comments

There's been a couple of of issues (#23, #31, maybe #29) about the way the via stitching plugin places vias on a grid and handles step and clearance settings.

I ran into these same problems, and so I've started on a bit of a new algorithm for via placement. It goes like this:

  • For our target areas, set their net to "no net" and refill them. This way islands are allowed, and the fills will have the correct clearance to all pads, vias, board edges, etc.
  • Do a union of all filled target areas on the top layer, and shrink (deflate) them by half our via size
  • Do the same for the bottom area
  • Union together the top/bottom areas. The resulting area set is the area we can place via centres without the vias being outside a zone, or interfering with traces, pads or anything else.
  • Place vias however we want (grid, star, random, etc).

At this point I've only implemented the standard grid pattern, but if there is interest I can do the star pattern, and I was thinking of doing a proper Poisson disc random distribution. For now, at least, here is my WIP.

Oh yeah, the new algorithm seems to be a bit quicker, too.

m-schubert avatar May 13 '21 11:05 m-schubert

Here's an example of the random Poisson disc sampling (via Bridson algorithm): image

And a standard grid fill: image

m-schubert avatar May 13 '21 19:05 m-schubert

I think this is now ready to review. Behaviour has changed a little from the previous implementation:

  • "Via grid" sets the exact distance between centres for the star/grid stitches, and the minimum distance between centres for the random stitches.
  • There is no such thing as a "star" or "grid" random stitch. If you check the random checkbox, you get random.
  • "Clearance" is now simply extra clearance from the edge of a fill area to the stitching vias. It doesn't dictate clearance between the vias themselves (use the "via grid" setting for that).
  • There's no real debugging, so the debug mode doesn't do anything.
  • "Only under selected zone" requires that you select both top and bottom zones you want to stitch between. It also requires that the selected zones have the same net as specified in the dialog for them to be filled.

I've tried to leave the GUI alone, but possibly it'd be worth updating that to be more in line with my changes? I'm trying to think of functionality or use cases that I've dropped with my sweeping changes, but nothing really sticks out. Feedback is welcome.

m-schubert avatar May 16 '21 05:05 m-schubert

@jsreynaud, any thoughts on this PR? If it is too much of a drastic change, I'm happy to fork it off into another repo as a standalone plugin.

m-schubert avatar May 30 '21 06:05 m-schubert

@m-schubert First the code look better than mine. Placement strategy are in class. It's really a good idea ! Then I had made some test and I find some regression.

I had test with pic_programmer.kicad_pcb file (in kicad demo)

  1. It don't put any via (around 282 is placed with previous version) is there is not area on top+bottom.

I think it's normal since there a single area (bottom). But if you change the configuration of the board by adding 4 layers and if you duplicate the bottom area and put the new one on inner1 or inner2 it don't place any via.

=> Your plug-in put via only if there are a top+bottom configuration. Could you fix it ?

  1. If there is a track on any other layer than top+bottom, some via can be put inside Example with track on inner1

For me you don't check collisions with elements in inner layers. => Could you fix that ?

As I see your fix is for KiCad 5.1. I'm really interested to merge it and then make the appropriate corrections to be able to use it on future 6.0 version.

Thanks,

jsreynaud avatar Jun 15 '21 08:06 jsreynaud

Thanks for the feedback!

=> Your plug-in put via only if there are a top+bottom configuration. Could you fix it ?

Yep, it should be possible to adjust the code to connect any two copper layers.

For me you don't check collisions with elements in inner layers. => Could you fix that ?

Good pick up. I'll have to think a bit about how to adapt my "valid placement region" generation code, but it should be possible. There may be some edge cases to consider.

As I see your fix is for KiCad 5.1. I'm really interested to merge it and then make the appropriate corrections to be able to use it on future 6.0 version.

Sounds good. I'll let you know when I've finished making my changes.

m-schubert avatar Jun 15 '21 17:06 m-schubert

@jsreynaud, I think I've updated it to behave like you've suggested. Are you able to test it and let me know?

With the new code, vias will be placed in positions that:

  • Have areas of the specified net on at least 2 copper layers (could be front/inner 1, or front/back, or back/inner 2, etc)
  • Are at least the via radius + clearance away from any copper trace or pour on any layer

m-schubert avatar Jul 10 '21 17:07 m-schubert

Sorry for late reply. I want to use your proposal as a new option for via placement (to keep, old method and have also your new method). I have a little rework for that...

jsreynaud avatar Jul 28 '21 12:07 jsreynaud

@jsreynaud any news on this PR?

easyw avatar Mar 04 '23 10:03 easyw