How to duplicate a PCB layout in Kicad 5?

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

Unfortunately, in the context of KiCad I don’t know how to do this with hierarchical sheets. That two part numbering sequence for the reference designators can’t automatically be done by KiCad. If it does work (I haven’t tried, so it very well might work) would have to be completely hand annotated.

But, even worse, the only thing that can be entered differently on different instances of hierarchical sheets that use the same schematic file are the reference designators. All the values will be the same. If you set N1R1 to 50Ω on page 2 (assuming page 1 is the top-level hierarchical sheet), then as soon as you open page 3 to change N2R2 to 100Ω, N1R1 will also be changed to 100Ω (as will all the other N#R1 values).

I don’t think MitajN’s script will work for hierarchical sheets that use separate schematic files. How is the script supposed to realize that the schematics of different files are, actually, the same schematic just with different component values?

There is no schematic capture program, including KiCad, that understands the mechanical-boundary line convention of ASME Y14.44, Figure 3 Reference Designation in a Typical Schematic Diagram. I was suggesting an alternative method that can be used and doesn’t use the hierarchical method. The use of the (non-)class letter N, which is listed in IEEE 315, Clause 22.4 Class Designation Letters: Alphabetical List, is covered by ASME Y14.44, Clause 3 LOCATION NUMBERING METHOD (see ASME Y14.44, Figure 15 Location Numbering Applied at Several Subdivision Levels that is an extension of the Unit Numbering Method covered by ASME Y14.44, Clause 2 UNIT NUMBERING METHOD. Yes, you would have to “manually” put the proper N# ref des prefix ahead of the basic ref des for each “sub circuit”.

I just did a top level schematic diagram that had a Front Panel, Rear Panel, and a printed circuit board assembly (PBA). For the Front Panel parts I used ref des prefix A1, for the Rear Panel parts I used ref des prefix A2, and for the PBA (PCB) I used ref des prefix A3. I then copied this schematic, deleted all parts with A1 and A2 ref des prefixes, leaving me with the parts that make up the PBA (PCB). Now I am in a quandary. How do I separate the PCB from the PBA? How would you provision the use of a PCB to be used in two or more different assemblies?

Larry

If I understand what you are trying to do correctly, you can achieve this by:

  • Create .kicad_pcb for all three schematics.
  • Sart pcbnew on it’s own (not using the project manager).
  • Open the first .kicad_pcb, then use File->append board… feature to add the other two board files to your .kicad_pcb…

I hope this helps.

Cheers,
Piotr

1 Like

Hi all,

A somewhat belated coming back to this topic - the days have been busy and I have considered which way of doing this may be most feasible in my context. To this end I noticed PCBWiz’es comment below:

Can I just briefly ask you to say why this is not what I would want?

Cheers,

Jesper

Maybe because you want 12 sub-circuits with identical placement of footprints and identical routing but not a unique sub-circuit 12 times.

I mean, if you have 2 resistors, R101 and R102 linked for the net-1 what we understand is that you want 12 sub-circuits with
R101 R102 net-1
R201 R202 net-2
R301 R302 net-3… and so on.

With the current block duplicate you would get R101 R102 net-1 12 times:
R101 R102 net-1
R101 R102 net-1
R101 R102 net-1 etc.

At least with recent nightly builds when you paste/drop the copied/duplicated track so that it’s on pad it gets the net from that pad. No problems.

EDIT: but footprints can’t be copied that way.

Yes, eelik. This feature was present even in v4.

I haved used it to replicate tracks between “channels”. But the footprints must be positioned first. It may help to use a custom grid where you can snap each item directly into its position, if that’s possible. Another option is to position one channel (from one sheet) and then drag each component from another channel on top of the corresponding component. That way it’s easier to do identical layout. Then select all components of the sheet with RMB->Select->Items in Same Hierarchical Sheet and move them together to their final place.

These are tedious workarounds but possible if you have few components or few channels. Needless to say, native “channels” are desparately needed in KiCad. I’m not sure if this was already mentioned here: https://bugs.launchpad.net/kicad/+bug/1521062. Please vote there, although it has already been assigned to a developer. If Mitja rewrites his plugin to support free positioning and in-place editing I will use it until a native solution.

See replies above. You usually want some nets to duplicate (GND, VCC) but others (local nodes) need new unique net names, to prevent across-module joining. (that’s the bit you don’t want)

I think the replicate scripts use some net-name rule to decide which are global, and which are local.

Note also the scripts work as outlined above, using the feature that a trace polyline, seeds the net-name from the PAD, so it first does a XYRF array part re-place, then a trace overlay.

Hi PCB_Wiz & All … Thanks for your feedbacks. Trying to get a hold of which method may be the most feasible to helpful to get some insight into advantages and shortcomings of each …

Cheers,

Jesper

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.