geekhack

geekhack Projects => Making Stuff Together! => Topic started by: adamws on Thu, 30 April 2020, 07:38:41

Title: PCB generator and helper plugin for KiCad
Post by: adamws on Thu, 30 April 2020, 07:38:41
Hi,

those of you who did PCB design probably know that manual placement of elements is tedious task. For me it was unbearable so I decided to automate this with KiCad API.
My work can be found at https://github.com/adamws/kicad-kbplacer
It is not yet polished but should be usable at this stage. So far I did 4 projects with it and it was a breeze.

I would like to hear your feedback and suggestions about features you would like to see.
Title: Re: Helper plugin for KiCad
Post by: Zustiur on Mon, 11 May 2020, 18:17:45
I did wonder if such a tool existed. I've finished my layout for now but will try to remember this next time.
Title: Re: Helper plugin for KiCad
Post by: adamws on Sat, 20 February 2021, 12:29:38
This project was in my backlog for a while but I picked it up again and here are the results: https://github.com/adamws/keyboard-tools
It's yet another PCB generator but with slightly different approach in terms of implementation. It can be played with here http://keyboard-tools.xyz/ - I also prepared short guide: https://adamws.github.io/keyboard-tools/kicad-project-generator/guide.html

Backbone of this project is plugin I shared earlier, but it should be easier to use this way.
Title: Re: PCB generator and helper plugin for KiCad
Post by: suicidal_orange on Tue, 23 February 2021, 04:22:34
Looks like an easy way to get most of the traces done, thanks for sharing :thumb:
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Tue, 09 March 2021, 13:13:53
I've just added new feature. My netlist generation script is now able to include simple atmega32u4 circuit (https://github.com/adamws/kle2netlist/blob/master/kle2netlist/skidl.py#L218) which can be copied to generated kicad project from template file (https://github.com/adamws/kle2netlist/blob/master/kicad-templates/atmega32u4-au-v1/atmega32u4-au-v1.kicad_pcb). This is how PCB looks like straight out of my website:
[attachimg=1]
so in theory, user does not have to design controller circuit in separate step (described here https://adamws.github.io/keyboard-tools/kicad-project-generator/guide.html) if simple generic one is sufficient.
Once I figure out how to copy everything from template (including tracks which are right now missing) the only manual part would be controller-matrix routing and usb routing.
This will remain as an option and old workflow is still working.
I might also add some parameter options to controller circuit but at this stage, from functional point of view, project does pretty much what I wanted.
Title: Re: PCB generator and helper plugin for KiCad
Post by: Gorbon on Tue, 09 March 2021, 16:16:22
Hi adamws and thank you for making this. It's such a great tool and I've used quite often lately.

One thing I found, is that when selecting the ai03 library, it causes an exception, halfway through the process.

[attach=1]

Also, as you mention in your guide, routing seems to fail for some rotated switches.

[attach=2]
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Tue, 09 March 2021, 17:34:16
thanks for feedback!
One of the big issues is that I do not have any tests at this moment and I'm checking things manually - indeed ai03 lib is not working anymore and I didn't catch that.
Also, I still need to improve error reporting mechanism - because some of the processing steps are started as sub-processes, the error message in popup is not very helpful (it only points to failed step but exact reason is lost - I do not store job history on the server).

Routing for rotations is another part to be improved, I will try to fix it somewhere down the line.

and just a note, to anyone using it - github issues are welcome. Posting it here is also fine.

edit: ai03 is fixed now
Title: Re: PCB generator and helper plugin for KiCad
Post by: npeng on Sun, 14 March 2021, 06:05:30
I had this error but I figured it out.
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Wed, 17 March 2021, 18:12:36
Improved switch-diode routing for rotated switches:
before:
[attach=1]
after (track is rotated same as switch/diode):
[attach=2]

started some quality checking/examples: https://github.com/adamws/kicad-kbplacer/tree/master/examples
Title: Re: PCB generator and helper plugin for KiCad
Post by: StormyMonday on Mon, 06 December 2021, 06:09:12
Sorry to necro this, but more folks need to be aware of and use this project.

I just stumbled on this tool and it looks very promising. But, being a noob, I have failed to convince it to function correctly for me.

Issues
I uploaded perhaps a half dozen JSON files files from the Keyboard Layout Editor, but a few of them do not render at all and one rendered incorrectly, no matter which Project Options I chose.
For instance:
My Kyria layout will not render at all, nor did another layout that I am currently working on, which is a 60% ortholinear layout that resembles a Planck, but with staggered columns. In each case I received an error message that wasn't particularly helpful. Here is an example:
Code: [Select]
{ "exc_message": "Traceback (most recent call last):\n File \"/kicad/src/tasks.py\", line 69, in generate_kicad_project\n log_path = kicad.new_pcb(task_id, task_request, __update_percentage)\nException: Preview render failed\n", "exc_type": "Exception" }
My Iris layout does render, but both haves of this split board render as one single, large PCB, instead of two separate pieces. I suppose that this makes sense and I should have submitted this layout one half (one PCB) at a time..
Other layouts, such as a standard 60% and a Cherry 1800 layout render just fine.

That said, of all of the layouts that did render, I had a problem when clicking on the "Download Project" button. In each case, all I received was a zero length file. I tried temporarily disabling my firewall, but this brought me no joy.

Anywho, this is a brilliant project that more folks should be test driving, so I thought that I'd offer some feedback.

Thanks for your efforts!!!
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Sun, 01 January 2023, 11:57:47
After almost two years since last update I released v0.2 of https://github.com/adamws/kicad-kbplacer (https://github.com/adamws/kicad-kbplacer) which is now KiCad 6.0 compatible and available on official KiCad's plugin repository.

There has been some updates on http://keyboard-tools.xyz/ (http://keyboard-tools.xyz/) as well. Although functionality is unchanged, I updated dependencies and fixed storage related bug which was causing space issues on server.
Website still uses previous kicad-kbplacer version (KiCad 5.1 compatible) but I'm planning to update it as well and keep it alive.

In case you encounter any bugs I encourage to open issue on github, that's best way to get my attention. I'm checking it far more often than this forum.
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Wed, 22 March 2023, 15:17:40
I released v0.3 and v0.4 since last post.
Main changes:
- add KiCad 7 compatibility
- add support for customizable diode positions:

(https://raw.githubusercontent.com/adamws/kicad-kbplacer/master/examples/2x3-rotations-custom-diode-with-track/render.svg)

- improved 'router' algorithm and add track collision prevention.

I also finally updated version running on http://keyboard-tools.xyz/ (http://keyboard-tools.xyz/) website and added some extra features like preview of both sides of generated PCB.
Title: Re: PCB generator and helper plugin for KiCad
Post by: KiserDesigns on Thu, 06 April 2023, 09:08:08
I just stumbled upon this, and I am absolutely amazed!
I could see this working well to automatically place (and maybe route) a pro-micro footprint as well, going from KLE to working PCB in just a few clicks!
Love that it is open sourced too, very nice.
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Fri, 07 April 2023, 09:00:51
I could see this working well to automatically place (and maybe route) a pro-micro footprint as well, going from KLE to working PCB in just a few clicks!

I already played with that idea. When running via web-interface you can select 'Controller circuit'
[attachimg=1]
and you would get something like this:
[attachimg=2]

template is located here: https://github.com/adamws/kle2netlist/tree/master/kicad-templates/atmega32u4-au-v1 (includes tracks as well)

It works well with 'whole-project-generator' (website) because then it have full control over netlist and saved template matches the netlist which is generated with skidl.
When using as kicad plugin (locally) there is this option:
[attachimg=3]
but then it is up to the user to ensure netlist-template compatibility.
Title: Re: PCB generator and helper plugin for KiCad
Post by: KiserDesigns on Fri, 07 April 2023, 11:36:59
Wow, that is quite impressive!
Since AVR's aren't quite as popular for new designs, could you see yourself adding pre-generated RP2040 circuitry instead?
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Fri, 07 April 2023, 14:06:54
Since AVR's aren't quite as popular for new designs, could you see yourself adding pre-generated RP2040 circuitry instead?

there was a plan to add more templates but that's not something I will do soon.

My current priorities for keyboaard-tools.xyz are:
- improve service stability. Based on server logs some jobs fail - need to investigate why
- fix memory leak (?) - server sometimes needs to be rebooted due to oom
- add more footprints (kailh hotswap)
- add optional selection of diode footprint and diode location

For kicad-kbplacer I plan to:
- add option to set non-default 1U switch distance
- add option to ignore diode placement (place switches only)
- support 'raw-data' from keyboard-layout-editor (and not only parsed json)
- support multi-layout (?)
Title: Re: PCB generator and helper plugin for KiCad
Post by: Im_Pigeon on Tue, 11 April 2023, 05:49:05
Thank you for making this available. It really makes the process of making my first MK PCB less daunting.
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Tue, 20 June 2023, 11:29:03
New release just dropped, you can get it from here: https://github.com/adamws/kicad-kbplacer/releases/tag/v0.5
Should be available via KiCad's PCM soon.

You can now change 1U distance between switches (so it is usable for Kailh Choc designs) and define placement rules for additional elements (probably LEDs but perhaps someone will find other use-case - there is no limit to number of extra elements).

(https://github.com/adamws/kicad-kbplacer/blob/master/resources/plugin-gui.png?raw=true)
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Sat, 19 August 2023, 16:10:25
Just deployed https://github.com/adamws/keyboard-tools/releases/tag/v0.3 (https://github.com/adamws/keyboard-tools/releases/tag/v0.3) to the server.
There are no new features, just some bug fixes and performance improvements.
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Tue, 22 August 2023, 16:12:10
Release v0.6 of kicad-kbplacer is out. It includes KiCad 7.0.7 compatibility fix and some new features.
Plugin now accepts raw kle layout files (as downloaded from keyboard-layout-editor, converting to internal form with another tool) and there is new experimental ergogen support.

Release notes can be found here: https://github.com/adamws/kicad-kbplacer/releases/tag/v0.6
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Sat, 23 September 2023, 09:41:59
Next release will get better track template support, hopefully making it viable choice for ergogen users:
[attachimg=1]

so far it was not possible to define template between more than two pads, making it unsuitable for reversible footprints.
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Mon, 02 October 2023, 15:33:37
Release of kbplacer v0.7 is almost there (wait for merge into KiCad's PCM).
In the meantime I've written script which scraps via layouts and automatically generates (and routes) PCBs based on them. I did it for demo purposes and too see how router is working with variety of layouts.
Anyway, results can be found here https://adamws.github.io/keyboard-pcbs/

Some selected results:

(https://adamws.github.io/keyboard-pcbs/output/latin64ble/latin64ble-render.svg)

(https://adamws.github.io/keyboard-pcbs/output/sofle/keyhive_sofle_rgb-render.svg)

(https://adamws.github.io/keyboard-pcbs/output/hotdox/hotdox-render.svg)

As you may see it is not perfect but it is not terrible either.

I've also written python renderer for kle-layouts and ported obscure https://github.com/cerebral/urlon js package (keyboard-layout-editor uses that) to python so I can have nice images (and links) on that site. So even if you find those PCB files not interesting. https://adamws.github.io/keyboard-pcbs/ could still be usable as layout viewer.
Title: Re: PCB generator and helper plugin for KiCad
Post by: 2keys on Tue, 17 October 2023, 11:41:07
Thank you for this great tool, it helped me a lot with positioning key switches in bulk (though I had to move them around in designs where rows are offset). I noticed that the reason was it places each switch cluster in the order it appears in the provided json. I managed to get around it by following a design schema where I declare the position of each switch manually in the json starting left to right and figured out the way KLE does the positioning (before it refactors it for efficiency). Looking forward for new updates
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Sat, 23 December 2023, 02:36:28
New kbplacer release is up https://github.com/adamws/kicad-kbplacer/releases/tag/v0.8
Just a minor bugfix this time.
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Thu, 11 January 2024, 16:29:49
Deployed new version of https://keyboard-tools.xyz/
For release notes check https://github.com/adamws/keyboard-tools/releases/tag/v0.4
Title: Re: PCB generator and helper plugin for KiCad
Post by: adamws on Sat, 24 February 2024, 09:50:54
kbplacer v0.9 is out, it is quite big release: https://github.com/adamws/kicad-kbplacer/releases/tag/v0.9

I also drafted some guide about usage with ergogen https://adamws.github.io/keyboard-pcb-design-with-ergogen-and-kbplacer/
[attachimg=1]