Multiple clones of R_US but not C?

Trying to understand the underlying database in Schematic to be able to both manage BOMs and do some work with Python to automate things.

I just ran into something peculiar that I don’t quite understand. I’m sure its something obvious, I just haven’t seen it yet.

After generating a BOM from a test schematic that consists of mostly stock parts from the stock libraries this caught my attention:

R1, R10, R11, R13, R15, R20, R21, R25, R26,     9    330        R_US_1
R12,                                            1    4.7K 1%    R_US
R17, R18, R19, R22, R23, R24,                   6    100        R_US_6
R2,                                             1    19.1K      R_US
R3,                                             1    110K       R_US
R4, R14, R16,                                   3    10K        R_US_4

Note that there are multiple “R_US” variants. This is the “Cmp name” field in the BOM.

I took a look a the schematic file and found this:

  (symbol (lib_id "Device:R_US") (at 60.96 72.39 270) (unit 1)
    (in_bom yes) (on_board yes)
    (uuid 00000000-0000-0000-0000-00005edae9f0)
    (property "Reference" "R7" (id 0) (at 60.96 67.1322 90))
    (property "Value" "" (id 1) (at 60.96 69.4436 90))
    (property "Footprint" "" (id 2) (at 60.706 73.406 90)
      (effects (font (size 1.27 1.27)) hide)
    )
    (property "Datasheet" "~" (id 3) (at 60.96 72.39 0)
      (effects (font (size 1.27 1.27)) hide)
    )
    (pin "1" (uuid f9446bbe-b1cb-45cf-a29a-082cbc6f848c))
    (pin "2" (uuid d7aacbcf-fb19-4266-ad3d-af83ce372548))
  )

  (symbol (lib_name "R_US_1") (lib_id "Device:R_US") (at 359.41 71.12 270) (unit 1)
    (in_bom yes) (on_board yes)
    (uuid 00000000-0000-0000-0000-00005ede0881)
    (property "Reference" "R6" (id 0) (at 359.41 65.8622 90))
    (property "Value" "" (id 1) (at 359.41 68.1736 90))
    (property "Footprint" "" (id 2) (at 359.156 72.136 90)
      (effects (font (size 1.27 1.27)) hide)
    )
    (property "Datasheet" "~" (id 3) (at 359.41 71.12 0)
      (effects (font (size 1.27 1.27)) hide)
    )
    (pin "1" (uuid 3367972f-528d-4624-89f4-0b3b2f6850f4))
    (pin "2" (uuid acce2396-cc0f-49b8-9df3-4bee59c4dbf0))
  )

  (symbol (lib_name "R_US_2") (lib_id "Device:R_US") (at 359.41 78.74 270) (unit 1)
    (in_bom yes) (on_board yes)
    (uuid 00000000-0000-0000-0000-00005ede1624)
    (property "Reference" "R8" (id 0) (at 359.41 73.4822 90))
    (property "Value" "" (id 1) (at 359.41 75.7936 90))
    (property "Footprint" "" (id 2) (at 359.156 79.756 90)
      (effects (font (size 1.27 1.27)) hide)
    )
    (property "Datasheet" "~" (id 3) (at 359.41 78.74 0)
      (effects (font (size 1.27 1.27)) hide)
    )
    (pin "1" (uuid d50b858f-870b-4b80-a32f-fd9892957fb1))
    (pin "2" (uuid 1da08b61-e38a-47c0-a30b-9fc7d843ca7e))
  )

The first block describes “R_US” for R7, then comes “R_US_1” for R6 followed by “R_US_2” for R8.

These all refer to “Device:R_US” as their source.

If I single-click on R8 on the schematic and look at the lower left status display, I see this:

So, R8’s “Name” is “R_US” but the name on the BOM is “R_US_2”. I cannot seem to find a reference to “R_US_2” anywhere on the schematic editor.

If I look at R8’s property sheet I get this:

How does “R_US_2” happen? Where does it come from? Is this created when you copy-and-paste symbols in schematic?

And here’s the kicker: This does not seem to happen with capacitors or any other components, just these resistors. I did not try any other type of resistor other than “R_US”.

No, it comes from editing a symbol from the schematic. Whenever you use the “Edit with Symbol Editor” action to modify a particular instance of a symbol in a schematic (rather than editing the version in the library) a copy is made so that the edits only apply to the selected symbol. These all will have unique names, but the same library reference.

The problem is that you are using the cmp_name field – you probably want a different field in your BOM, such as the library reference. In the default BOM generator, this is done with the line:

row.append( c.getLibName() + ":" + c.getPartName() )

KiCad v6 allows you to modify symbols in the schematic (Ctrl-E). Once you modify them, they are no longer the same as the original library symbols.

The field cmp_name gets an increment to designate a new, unique symbol. If you go to the top of your file, you will find symbol entries for R_US_1, R_US_4, etc with the edits shown that differentiate them from the standard R_US.

If you accidentally used Ctrl-E to modify the value of the symbol, you still get the extra copies.

Ah, OK, that’s probably how it happened.

The BOM was generated using the stock “bom_csv_grouped_by_value_with_fp” script. That’s how I discovered this. I am now slowly crafting a different program that will delivery a BOM I can actually use.

Thanks. I understand where this comes from now. I’ll run some experiments to gain a better handle on it.