Text Replacement Variables in Footprints


I’m currently working on an external numpad, and ran into the problem that while arranging the keys on the PCB, it’s hard to differentiate between the different keys, since the refs are all just indexed (like “D12”), and are not the keycode (like “KP_7”)

My project setup is the following:

  • My root schematic contains the 17 keys in hierarchical sheets (all pointing to the same file), the different sheets/keys have different names, all corresponding to their keycodes (see screenshot)
  • Inside the hierarchical sheet there are the symbols that make up a “key module”, the switch itself, a diode for the switch matrix and RGB (of course, also see screenshot)
  • I’m using the Replicate Layout plug-in, to keep the layout of the key modules’ components on the PCB in sync
  • I have also set up some custom symbols and footprints

The root schematic (partially) and the hierarchical sheet (sorry, new user, one embed limit)

What I want to do:

I would like to annotate the different keys with their keycodes on the silkscreen (or at least the fabrication layer), so that it will be easier to arrange the keys on the PCB and would be easier to troubleshoot any problems that come up

In my opinion, the best way to do this would be to:

  1. Set the sheet names (or a custom field on the hierarchical sheet) to the keycodes (as I have done already)
  2. Pass the value to the symbol (also works fine)
  3. Have that symbol pass the value to its footprint (can’t figure out how to do this, if at all possible)
  4. Then the footprint can display it on the silkscreen, or any other layer of our choosing, with the help of a text item

Also, I’m on KiCad 6.0.6 Release

So is it possible to do it like this and I just haven’t found the correct syntax, or is it currently not possible?
If not, are there any alternatives besides placing the annotations individually on the PCB?

Thanks in advance!

First off, thanks for the comprehensive reply!

I swear I tried something like that before, but it didn’t work. Guess I forgot to update or save something and wrote it off :sweat_smile:

So now I tried your suggestion, and it does work for unique symbols, however for my application it sadly doesn’t (altough I believe it should work this way).

Like you suggested, I added the fields, then updated symbols, footprints, etc., but got the following:

As you can see on the sheet, the text substitution works fine, when I set the field to Show, it displayed the sheet name.
The footprint also takes the field from the symbol, since it doesn’t display “${KeyCode}” on the PCB, however it doesn’t display the value of the sheet name either.

My guess would be that the footprint doesn’t evaluate the substitution in the symbol’s field, thus taking “${SHEETNAME}” as a value. Or it tries to evaluate the substitution, but in the footprint’s context instead of the symbol’s, where ${SHEETNAME} doesn’t exist.

Changing the value at the symbol doesn’t work for me, because all keys use the same hierarchical sheet, if I change one, I change all. Adding custom fields to the sheets on the main sheet (through Right-Click → Properties…) results in the same substitution error.

So… it seems I’ll have to annotate by hand currently, but more suggestions are welcome!

Might also test around a bit more and open an issue on git.

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