Skip to content

KiCAD plugin to help place switch footprints based on a KLE

License

Notifications You must be signed in to change notification settings

zykrah/kicad-kle-placer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KiCAD KLE Placer

A plugin for KiCAD used to place switches based on a KLE. Tested (and should work) in KiCAD 6. Based on kicad-kbplacer.

NOTE:

  • Rotated keys in KLE are NOT SUPPORTED (I'm working on it, read at the bottom of the page) Rotated keys requires you to enable the Specific Reference mode.
  • Diode placement is NOT SUPPORTED (I'm working on it) DONE. Read below.
  • Plugin is not fully tested, the more complex layouts you try with it, the less likely it is to work fully. Please open issues for any unintended behaviour.
  • I tested this plugin with marbastlib (symbols and footprints).

Installation (KiCAD 6)

To use this plugin with KiCAD 6, you'll have to use the legacy 6.0 branch which you can access here. The installation instructions for that version will be available there. Just make sure you are downloading the code from that version.

For installation instructions for KiCAD 7+, scroll down or click me

Usage

Initial note: There should be the SAME number of footprints/symbols (in your KiCAD project) as there are keys (in the KLE).

The script takes in the json file of a KLE, downloaded as shown:

image

Follow the following KLE guidelines to enable more advanced functionality of the plugin:

KLE Guidelines

image

  • 3: Multilayout index
  • 4: The reference number REQUIRED FOR SPECIFIC REFERENCE MODE AND ANGLED KEYS (e.g. if this key corresponds to SW1, put 1 in this label)
  • 5: Multilayout value
  • 9: Stabilizer flip (if you want to flip the stabilizer, place F in this label)
  • 10: Extra switch rotation in degrees (e.g. if the default orientation is north facing switches, and you wanted specific keys to be south facing, put 180 in this label)

Order of keys in KLE/Schematic (Normal mode)

By default ("normal mode"), the plugin counts by footprint reference (i.e. SW1, SW2, etc...) starting from the top left-most key. It then goes left to right (based on the horizontal center of the key), then up to down (based on the top edge of the key).

Example of how it's ordered:

image

Another example with multilayout. See how the 2u key is in the middle of the 1u keys when overlapped, so it goes in between those in the order (NOTE: I didn't mark the multilayout value/indices here, but you need to for the script to work):

image

Diode placement

You can disable diode placement by unchecking Move Diodes in the dialog (enabled by default).

If Move diodes based on first switch and diode is checked/enabled, the diode placement will be based on the first switch in the pcb editor (recommended). Otherwise, diodes will just be placed at the center of their respective switch footprint.

Example of 2x2 board with Move Diodes and Move diodes based on first switch and diode enabled:

image

image

Place the first (top-left) switch down and place its diode appropriately:

image

When you run the script, the rest of the diodes will move the same way:

image

Extra switch rotations

At first, all switches will be set to the same rotation as the first key. You can then use extra switch rotations (assign them in label position 10) to further rotate specific switch footprints. This is useful for e.g. specifying certain keys to be north facing, when the rest of the keys on the board are south facing.

Based on above example:

image

image

Multilayout

NOTE: colour is irrelevant for multilayout, but makes reading it easier.

You can either follow the guidelines and place the appropriate multilayout labels OR "squish" the keys together (layer the same multilayouts on top of eachother):

image

image

NOTE: the above examples are for normal mode, but the same rules apply to specific reference mode

Example Schematic (Demonstrating multilayout, diodes and stabilizers)

In terms of stabilizers, if the switch footprint library you're using has separate switch and stabilizer footprints (e.g. marbastlib): use the same reference for the stabilizer as the switch it corresponds to (e.g. SW54 and S54).

In terms of diodes, use the same reference for the diode as the switch it corresponds to (e.g. SW54 and D54).

IMPORTANT: See the rules mentioned above for an explanation on how you should order your schematic.

NOTE: I am using symbols from marbastlib. You can use any switch symbol you want.

Schematic from the same example as earlier, note the order of the symbols:

image

To mass-annotate symbols, you can use this tool in the schematic editor. If you order your symbols as in the example above, this will work well for switches, but for diodes you will need to either manually assign the values, or select specific diodes and change the value of Use first free number after: appropriately:

image

SPECIFIC REFERENCE MODE (and rotated keys)

It's hard to do rotated switches with the board's normal mode (it goes left to right based on the order of switches, SW1, SW2, and so on). The order of keys in KLE gets mixed up/is hard to interpret once you introduce rotated keys, so my solution/compromise for accurately relating keys on the KLE to footprints on the PCB, is to add a separate mode.

To enable it, check the Specific Reference Mode checkbox in the dialog.

Furthermore, with this mode, you're required to fill out label 4 with the reference value of the switch footprint that the key corresponds to (e.g. the key that corresponds to SW1 should have 1 in label position 4, see guidelines above).

EXAMPLE: Specific reference mode + rotated keys

KLE:

image

Schematic:

image

PCB after the script has run:

image

Installation (KiCAD 7+)

To install the plugin on KiCAD 7+, you have to use KiCAD's Plugin and Content Manager (PCM):

Make sure to enable automatic updates if you want to ensure the plugin is always up to date.

image


To use, paste https://raw.githubusercontent.com/zykrah/zykrah-kicad-repository/main/repository.json into KiCAD's PCM Repository manager:

image


From there, change the repository at the top to Zykrah's KiCad Repository, press Install on the plugin, and press Apply Pending Changes at the bottom left.

image


You should see the plugin now in your PCB editor:

image

What the dialog looks like. Read the usage documentation to get started with the plugin:

image