Symbol lib, same value but different name, how?

Or asked differently:
How can I have R_22k_0402, R_22k_0603, R_22k_0805 in the library, but when I load them into the schematic only 22k appears as value and R? as reference for the part?

I was cleaning my libraries and working on my import/export script for symbol fields and was beginning to wonder (*) why the symbol value appears 2 times in there, and they need to be the same as otherwise the symbol is being thrown out of the library or other weird stuff.

For example this resistor here in my local Passives.lib:

Inside the library the part looks like this:

#
# R
#
DEF R R 0 0 N Y 1 F N
F0 "R" -100 0 50 V V C CNN
F1 "R" -100 0 50 V V C CNN
F2 "_" 0 0 5 H I C CNN
F3 "_" 0 0 5 H I C CNN
F4 "_" 0 0 5 H I C CNN "Manf#"
F5 "_" 0 0 5 H I C CNN "Manf"
$FPLIST
 R_*
$ENDFPLIST
DRAW
S -40 100 40 -100 0 1 10 N
X ~ 1 0 125 20 D 50 50 0 1 P
X ~ 2 0 -125 20 U 50 50 1 1 P
ENDDRAW
ENDDEF

Note: …the library does remove fields like “manf#” if there is no char/string within the first two parenthesis… thus I put an underscore in there as long as I don’t have the information ().*

Anyhow, what I’m wondering is this… there are 3 lines there with an ‘R’ at the 2nd position… the one after ‘F0’ contains the REF** field… the ‘F1’ line seems to contain the Value field and the ‘DEF’ line must be the library name.
It would now naturally be nice to have a resistor appear as R_22k_0805 in the library (so you can differentiate by package size and it’s placed into the schematic with all bells and whistles - like partnumber/datasheet/etc.pp.) but only have ‘22k’ appear as value in the schematic.
For this to work the ‘DEF’ and ‘F1’ field would need to be different…
If you modify the library outside of the kicad part editor you can do that, it even shows in the library browser as expected…

#
# R_Test
#
DEF R_Test R 0 0 N Y 1 F N
F0 "R" -100 0 50 V V C CNN
F1 "R_Value" 100 0 50 V V C CNN
...
ENDDEF

But one can’t load such a contraption… neither the parts editor nor eeschema want to have anything to do with this… it’s not even R_Test anymore, it became R_Value.

So folks, back to the rephrased question at the top there.
How do you make it to have several parts in your library with the same value but different packages, which should also be mirrored in the symbol name, but only have the value appear when you place it in your schematic?!
Or am I off course here and there is another philosophy/workflow to achieve what I desire?

Big Thanks!

*) I stumbled over this via my script which mods library files directly https://github.com/JoanTheSpark/KiCAD/blob/master/KiCAD_Library2CSVandBACK.py

What if you created multiple libraries? One for 0402 resistors, one for 0603 resistors, one for 0805 resistors etc. and just have the names be 10R, 100R, 10k, 22k, etc.

When you place a symbol where there are similar named ones in several libraries, KiCAD/EEschema thinks it’s a good idea to take the symbol (plus all it entails like footprint/partnumber/etc.) from the library that comes first in the library order… ignoring the others in the process.
So, no, that won’t work.

Yes, I’ve just created a BOM without any plugin from within EEschema and the output shows that EEschema is able to distinguish between part name and value field in that instance

<comp ref="R101">
      <value>1.5k</value>
      <footprint>SMDx:R_0805</footprint>
      <datasheet>_</datasheet>
      <fields>
        <field name="Manf#">_</field>
        <field name="Manf">_</field>
      </fields>
      <libsource lib="Passives" part="R_1.5k_0805"/>
      <sheetpath names="/" tstamps="/"/>
      <tstamp>5668F282</tstamp>
     </comp>

…where as the editor/partpicker code isn’t able to.

<libpart lib="Passives" part="R_1.5k_0805">
   <footprints>
        <fp>R_*</fp>
      </footprints>
      <fields>
        <field name="Reference">R</field>
        <field name="Value">R_1.5k_0805</field>
        <field name="Footprint">SMDx:R_0805</field>
        <field name="Datasheet">_</field>
        <field name="Manf#">_</field>
        <field name="Manf">_</field>
      </fields>
      <pins>
        <pin num="1" name="~" type="passive"/>
        <pin num="2" name="~" type="passive"/>
      </pins>
  </libpart>

So yeah, I’ll do as you suggest and what I already thought of… replacing the Value field in EEschema after dropping the part. So far I only had the lonely R up there and put in the value every time, but this naturally doesn’t help with the way KiCost works. And replacing the value each time I drop one isn’t too bad, as most of my time is spent in PCBnew anyway…

Still, this is not properly implemented as the difference between the browser and the part-picker code shows. Anyone knows if there is a wishlist/bug entry for this kind of thing where I can lend some support?

Pretty cool, I remember reading about that some months back.
Thing is, the bloke that works with me and does the circuitry development is happy & determined to stay with 6 values per decade and 0805 size for the time being, so the number of resistors won’t reach insane levels (just had the fun to manually copy&paste the part name in the library into the value field in a backup I had as kicad just threw them out - LOL - so, it’s not thaaat many yet).
If we make it past prototyping things and really run for manufacturing (I can only imagine how many potholes and corpses will be on our way till then) and we need smaller sized housings for resistors/capacitors I’ll add another batch. It won’t grow to insane levels in any case.

Wohohoho… little test there, note the ‘ALIAS’ field:

#
# R_12k_0805
#
DEF R_12k_0805 R 0 0 N Y 1 F N
F0 "R" -100 0 50 V V C CNN
F1 "12k" 100 0 50 V V C CNN
F2 "SMDx:R_0805" 0 0 5 H I C CNN
F3 "_" 0 0 5 H I C CNN
F4 "_" 0 0 5 H I C CNN "Manf#"
F5 "_" 0 0 5 H I C CNN "Manf"
ALIAS 12k
$FPLIST
 R_*
$ENDFPLIST
DRAW
S -40 100 40 -100 0 1 10 N
X ~ 1 0 125 20 D 50 50 0 1 P
X ~ 2 0 -125 20 U 50 50 1 1 P
ENDDRAW
ENDDEF

And look - no error, no nothing, just works as I desired, the 12k is automatically used as value:

I thought.
But - there is always one, right - upon closer inspection there is trouble ahead:

  1. reloading the schematic (after placing two R_12k_0805 with value 12k being inherited via the ALIAS feature) we are presented with this:

  1. inspecting that …cache.lib we find (it’s already down to one entry with 12k at this point, lol) this:

    12k

    DEF 12k R 0 0 N Y 1 F N
    F0 “R” -100 0 50 V V C CNN
    F1 “12k” 100 0 50 V V C CNN
    F2 “SMDx:R_0805” 0 0 5 H I C CNN
    F3 “" 0 0 5 H I C CNN
    F4 "
    ” 0 0 5 H I C CNN “Manf#”
    F5 “_” 0 0 5 H I C CNN “Manf”
    ALIAS 12k

    ENDDEF

…and the BOM xml turns the world upside down, with making the alias the part name and the original part name becoming the alias…

<libpart lib="Passives" part="12k">
      <aliases>
        <alias>R_12k_0805</alias>
      </aliases>
      <footprints>
        <fp>R_*</fp>
      </footprints>
      <fields>
        <field name="Reference">R</field>
        <field name="Value">12k</field>
        <field name="Footprint">SMDx:R_0805</field>
        <field name="Datasheet">_</field>
        <field name="Manf#">_</field>
        <field name="Manf">_</field>
      </fields>
      <pins>
        <pin num="1" name="~" type="passive"/>
        <pin num="2" name="~" type="passive"/>
      </pins>
    </libpart>

Inspecting the component side of things in the BOM.xml I find it looks the same as for the other parts and the example I posted higher up.
Next I try KiCost on this file and it does still work and gives me correct output - yay.
That’s one down, how about the Layout?
Checking via CVpcb the footprint assignments are correct, it doesn’t freak out… good.
Next netlist generation… no hickups.
Opening PCBnew and loading the netlist I get this and am a happy panda :blush:

So, now off to making 3 similar parts with different packages and see how that works out.

Not good:

And it only goes downhill from there.
Placing a resitor like that looks OK first, the library lists all package variants as expected and when one places them they come with the 12k as value… placing another one, with the same ‘value’ but different package changes the package of the one already placed too. Having placed 3 different packages and looking at them they all get the package of the one placed last… so this doesn’t work.
The package variants also vanish from the parts list and only 12k is kept in the History, which probably is just the cache.lib for that project and that one - naturally, who would have thought otherwise - contains only one 12k part. Just perfect, Not. :angry:

Case closed.

In my library I just added a custom field “Resistance” for resistor value.
Same for capacitors (custom field “Capacitance”).
Same for ferrite beads (custom field “Impedance”).
Etc

Sounds nice, but I’d rather keep the added ‘clutter’ to a minimum… ManfID and Manf now has to come with every part for me already… adding another 3 starts to get nasty, especially when KiCAD insists on deleting extra fields (F4+) in the library that aren’t populated with content…

I’m 95% there now anyway for the simple “counted in the thousands” stuff… got myself a script that populates a library file how I want (part names with value, package and voltage) and manufacturer ID.
Still a lot of manual fiddling to set up the script for each series, but it get’s me there in pretty short time.
I now have 0805 resistors, capacitors and some 1210 caps… next will be alu caps and 0805 fuses.
Should suffice for the next couple of weeks.
If I need more I have a starting point and can refactor the code to make it more efficient and easier useable.

example (#5of 36, E6 series 1Ohm-1MOhms):

#
# R_4.7R_0805
#
DEF R_4.7R_0805 R 0 0 N Y 1 F N
F0 "R" -100 0 50 V V C CNN
F1 "R_4.7R_0805" 100 0 50 V V C CNN
F2 "SMDx:R_0805" 0 0 5 H I C CNN
F3 "E:\Datasheets\Electronics\Passives\SMD_Resistors\Panasonic_ThickFilmChip_AOA0000CE3.pdf" 0 0 5 H I C CNN
F4 "ERJ-6RQF4R7V" 0 0 5 H I C CNN "Manf#"
F5 "Panasonic" 0 0 5 H I C CNN "Manf"
DRAW
S -40 100 40 -100 0 1 10 N
X ~ 1 0 125 20 D 50 50 0 1 P
X ~ 2 0 -125 20 U 50 50 1 1 P
ENDDRAW
ENDDEF

Well, I agree with keepeng the clutter under control :smile:

In my case I use a “generic symbol” approach where symbols in library have only placeholders for visible fields. All other fields (including Manufacturer and Partnumber) are added when symbols are instantiated in the particular schematic.

That’s the reason I’ve asked for CSV export/import feature: https://bugs.launchpad.net/kicad/+bug/1521430
Fell free to vote for it :wink: