How to duplicate a PCB layout in Kicad 5?

Hi all,

I am new to Kicad 5.0 yet have in the last couple of days come to appreciate the relative simplicity of the eeschema sub-program. I would say that it allowed me to make a relatively complex schematic faster than I have done previously - great help & thanks for making this program available :wink:

However, in the schematic I have made there are 12 power supplies (PSU) which are more or less identical. Thus, when importing the netlist to PCBnew I would like to make just one layout of this PSU circuitry and then copy eleven times - AND update the eeschema schematic to reflect this copy in PCBnew (subsequently with the correct global connection labels).

Does anyone here know how this is done? Would be fine with a link to a youtube tutorial, or some other tutorial where it is shown how it can be done ā€¦ I have skimmed through this document:

http://docs.kicad.org/stable/en/getting_started_in_kicad.pdf

  • and watched Digikeyā€™s Kicad tutorial videos but I canā€™t see any information about this ā€¦

Thanks for reading and for any help in this!

Jesper M

If you made you schematics with PSU circuitry in one hierarchical page, this is doable via Replicate layout action plugin. If you donā€™t have support for WXPYTHON, you can still run it in standalone mode

2 Likes

Hi Mitja ā€¦ Thanks for your feedback :wink: ā€¦

I am, however a bit unsure how I should interprete what you write: Does this mean that copying a part of a PCB layout in eeschema and/or PCBnew is not possible without some kind of plugin - like e.g. yours? There is not by default a way to do this in the basic KiCad installation?

I am asking because I am not at all a programmer - and from looking at the link you provided I donā€™t really know:

  1. Exactly which programme files to copy (and how do I make them a .py file - as it seems to be required)
  2. Exactly where to place them in the KiCad folder structure (here? C:\Program Files\KiCad\bin\plugins ā€¦ and should it be in a separate folder - with which name?)
  3. How do I enable KICAD_SCRIPTING_WXPYTHON if the most feasible way to work with your script/program?
  4. Do I otherwise need to update/change something in the Kicad installation to make this work?

I know these are many questions - I hope it is ok to ask them - and I would appreciate your help in this, if possible :upside_down_face:

Cheers,

Jesper

There are many ways how to achieve similar things in KiCad.
In eeschema you can either:

  • put the section that you wish to copy in its own sheet, and have multiple references to this sheet
  • select the ciruitry you wish to duplicate, right click and choose duplicate block

in pcbnew you can:

  • select part of the circuitry you wish to duplicate, right click and choose duplicate block. Keep in mind that these changes will not be back-annotated to schematics
  • use the Replicate layout plugin. In order to do so, the schematics has to be prepared accordingly (multiple references to the same sheet). Only this pard is not possible without a plugin.

As for the plugin you should:

  1. check if you have KICAD_SCRIPTING_WXPYTHON enabled. If you donā€™t have and you are on windows, reinstall Kicad using this installer (it is the same as official V5.0 only with WXPYTHON enabled)
  2. download the .zip containing all my plugins from github (big green button)
  3. extract the replicate_layout folder from the zip and put it in:
    %APPDATA%\kicad\scripting\plugins

And finally the forum is here exactly for this purpose. Asking questions. So I donā€™t mind. You do have to keep in mind that person on the other side can have totally different background (language, culture) and some misunderstandings are to be expected.

1 Like

Hi Mitja,

Thanks again for your feedback! ā€¦ Iā€™ve looked into your suggestions today and it seems to me that this may be the most feasible solution as I would like the schematic to be a representation of what the components, traces, etc. actually look like on the PCB:

However, I have searched for the meaning of ā€œmultiple referencesā€ in the eeschema and I canā€™t find this described in the manual or elsewhere ā€¦ I likely have missed it but can you briefly say what it means and how it is done in practice? Here I would have liked to upload a small example schematic but being a new member on this forum I cannot do so ā€¦

About the folder in which to install the plugin I have searched my computer for it but I canā€™t find it ā€¦ (?) Again I would have liked to upload a screen dump of what the file structure looks like - the folder ā€œprogramsā€ on C:\ (not ā€œprograms x486ā€ but KiCad is not here) is locked and I cannot unlock it even if I try the hints I have found searching the internet incl. additional administrator rights via the command prompt - so I donā€™t know if %Appdata% is found there ā€¦

In C:\users"my name"\ ā€¦ there is a hidden file called ā€œapplication dataā€ but I canā€™t get access to this file either ā€¦

So I am a bit stuck here ā€¦ Might you have a suggestion?

And they - just FYI - I will not be back to the forum for the next three days - i.e. not until Tuesday morning. Have a good weekend when to get to this point ā€¦

Cheers,

Jesper

He is referring to hierarchical schematics. There is a section in the manual for hierarchical schematics. Also, there is another recent thread where I encouraged the OP to convert his schematic with 4 repeated sub circuits to a hierarchical schematic. See the second half of this post for my result (pdf only) and some notes I wrote about hierarchical schematics: (One of these days, Iā€™ll actually spell ā€œhierarchicalā€ correctly an not rely on spell check to correct me. Apparently not even in this parentheticalā€¦:roll_eyes:)


It also might be instructive to read over the full thread to see someone elseā€™s design options and decisions (and I think he might have attached his project to the thread after he converted to hierarchical schematic to give you something to play with).

You sure it is a file? It should be a folder, and named (in US-english localizations) ā€œAppDataā€. The environmental variable %APPDATA% actually fully resolves to ā€œC:\Users<user name>\AppData\Roamingā€, but Microsoft doesnā€™t want normal people to access that file so it is hidden.
You would need to enable it in Windows using the ā€œFile Explorer Optionsā€. Set the setting that I have my mouse pointer on in this screenshot:
2018-10-05%2010_28_16-File%20Explorer%20Options

I hope your absence is for good things. In that spirit, I wish you an enjoyable weekend.

Hi SembazuruCDE ā€¦ just a brief remark to say that I have seen your post and it already helped me find the appdata folder - as it correctly is - thanks.

It is for the good in many ways, thanks - best wishes for your weekend as well :wink:

Jesper M

Yeah, I can imagine that my instructions were terse and I probably did not use the same terms that are used in KiCad documentation. Anyhow, when you create hierarchal sheet you give it a sheet name and you also give it a schematic file name. You can then create another hierarchal sheet, with different sheet name, but the same file name

Hi all,

So I am back after having had to divert my attention mainly to getting a CNC router I bought work as intended. Unfortunately this is not yet the case but while building a new CNC mill ā€œin the backgroundā€ I would now like to return my attention to learning KiCAD ā€¦

Since our previous posts I have been reading up on hierarchical (@SembazuruCDE: I remember how to spell ā€œhierarchicalā€ by memorizing that it needs two "r"s - seems to work ;-)) schematics and the options here. And I would now have liked to download the WXPYTHON enabled version that MitjaN linked to so that I could practice these duplicate hierarchical schematics with PCBNew.

However, in the meantime thereā€™s a new version of KiCAD - 5.01 - and your link (MitjaN) from Oct. 5th no longer works. Thus, any chance I can ask you to link to the right file again? Or tell me what to look for in the KiCAD installation versions here:

http://downloads.kicad.org/windows/stable/

Have a good day,

Jesper M

The official kicad 5.0.1 for windows has WXPYTHON enabled so you can download the one avaliable at https://kicad.org/download/windows/

Thanks Mitja for your prompt reply. I will do that.

Cheers :wink:

Jesper

Hi again,

Just wanted to say - in case somebody else reads this thread - that the plugin folder where the replicate_layout folder is to be placed can be found here:

C:\Program Files\KiCad\share\kicad\scripting\plugins

And not in the:

C:\Users<user name>\AppData\Roaming ā€¦ I thought I had found it here earlier but there is no replicate_layout folder here (but thanks to SembazuruCDE for suggesting ;-))

Cheers,

Jesper

It is generally better not to put user files there for two reasons:

  1. Windows will put them into the virtual store instead and the program might not be able to access them
  2. if you upgrade KiCad the user files might be lost

C:\Users_user_\AppData\Roaming\kicad\scripting is the best place to put third party scripts.

1 Like

As explained above, exactly this flow is not supported, and it would be quite hard to do.
It might be easy to say, but the ā€œAND update the eeschema schematic to reflect this copy in PCBnew (subsequently with the correct global connection labels).ā€ would require some level of clairvoyance.

  • Where would eeschema place those parts added by copy in PCB ?
  • What if you add or delete one more part ?
  • You must manually re-annotate the refdes in PCB, how does eeschema know what rules you used ?
  • Presently, block duplicate in PCB, also duplicates exactly the net names, which is not what you want

Hence the more conventional flow is to duplicate first in eeschema, using the one hierarchical page mentioned above, and now eeschema manages the 12 copies and the refdes re-labeling rules and the trace net-name re-labeling rules.

That just leaves clone by script in PCB, and the 12x parts and nets are already imported, just in a big pile !
Thus that script mentioned, is used to be given a starting routed example, and then it picks from the pile, the 11 copies and moves parts/clones traces.

This is all much simpler, as the script is doing nothing more than move and copy, it does not relabel anything.

The script github, has very clear examples

Hi all ā€¦ & thanks again for considering & replying ā€¦

@bobc:

Hi ā€¦ to the best of my very limited programming knowledge I havenā€™t put any ā€œuser filesā€ here. Only the replicate_layout file suggested by MitjaN above.

And the replicate layout plugin now shows up in PCBNew when I go into ā€œtools ->external pluginsā€.

However, I apparently am missing something related to how to use this plugin ā€¦ I have set up a very simple schematic only consisting of a few components on two hierarchical subsheets - yet no matter what I do I get the same message saying "more or less than 1 module selected ā€¦ " . I have attached a screendump showing what happens ā€¦

Looking at MitjaNā€™s images and the gif on the github download pages I donā€™t exactly know what could be amiss here ā€¦ But I reckon that it may have something to do with selecting the layout to be replicated in the right way.

Any ideas would be appreciated ā€¦

Cheers,

Jesper

P.S.: FYI I have also uploaded what I guess may be the schematic files - hope they can be opened on their ownā€¦

NPN.sch (1.9 KB)

Trial3.sch (413 Bytes)

You have to select one and only one of the modules (footprints) which are to be replicated.

It might be a bit strange at first but if you have a dense design it might be hard to select all the modules, so Iā€™ve implemented it this way. Also the modules might be on different hierarchical levels, and it is easier to control which level to replicate when you select only one module

Hi Mitja,

  • thanks again for following up on this ā€¦ I would say that I am doing what I should be doing (always saying this with appropriate humbleness :wink: ) but I think there is either something in the setup that doesnā€™t ā€œworkā€ or ā€¦ something else ā€¦ The schematic is extremely simple (3 components on each subsheet) but I still get the message I mentioned in my post ā€¦

One thing I notice is that in your gif on github you seem to select the subsheet in the ā€œhierarchical treeā€ drop-down box. Even if I do this it has no effect in PCBNew.

FYI I have attached pdf showing what the root sheet, two subsheets and PCBNew looks like.

What I do is that when inside PCBNew I select e.g. the right subsheet circuit with the mouse - then I go into options -> external plugins -> Replicate layout ā€¦ And here it is that I get the error message.

What may I be doing wrong?

Cheers,

Jesper

mitja.pdf (1.1 MB)

It is just a language barrier that we have to cross. Donā€™t select complete subsheet circuit. Selet only and only U1, and then call the plugin

Oho! ā€¦ Seems this may be it as the dialog box shown in your gif file pops up when I only select one of the ICs. Will look into it - thanks :wink:

Jesper

It is good engineering practice to always put a 0 (zero) in front of the decimal marker for numbers less than 1 (one). This is so that on a medicine bottle if the decimal marker gets obliterated you donā€™t want to be giving a baby ten times the dosage prescribed. For a .1 ĀµF capacitor this would be 0.1 ĀµF but it would be better to state it as 100 nF. This way you donā€™t have to figure out how to get the Greek letter lower case Mu.

I have not used hierarchical schematics and would suggest using the non-class letter N in a ref des prefix, as described in ANSI/ASME Y14.44, for your 12 power supplies circuitry. You said all 12 are similar but not the same, so this would allow you to segregate the 12 power supplies with differences. You would have N1 through N12 as ref des prefixes and thus N1R1 would not have to be the same value as N12R1 and N1VR1 would not have to be the same as N2VR1, etc.

Larry