Coder Social home page Coder Social logo

kicad-pinout-generator's Introduction

KiCad Pinout Generator

Compatibility: KiCad 6.0, KiCad 7.0.

Plugin presentation

This KiCad plugin generates pinouts of components from a PCB file to various formats:

  • Text formats for documentation:
    • Markdown table
    • HTML table
    • CSV
    • List (tab separated)
    • WireViz
  • Code format for software development:
    • C/C++ enums
    • C/C++ #define
    • Python/MicroPython dict.
    • Xilinx XDC constraint (FPGA)
    • Microsemi PDC constraint (FPGA)

Example applications:

  • Automatically create the pin assignment from a microcontroller to C code,
  • Generate interface documents for connectors.

HTML and C sample output Example of a export as HTML (left) and C/C++ enum (right)

Install instructions

Method A: Plugin and Content Manager (recommended)

The easiest way to install this plugin is to open KiCad's Plugin and Content Manager, look for "Pinout Generator" and press "Install"!

Pinout Generator in the PCM

Method B: Manual install (for development versions)

To install the plugin from GitHub:

  1. Clone/download this repository and extract it to your KiCad plugin folder. You can find it by opening the PCB editor, and using "Tools" > "Externals Plugins" > "Open Plugin Directory".
  2. Refresh the plugins by restarting the PCB editor or using "Tools" > "Externals Plugins" > "Refresh Plugins".

Usage instructions

To use the plugin:

  1. Select one component (or more),
  2. Run the plugin by using the toolbar button or the Plugins menu,
  3. Choose the desired format with the drop-down menu and copy-paste the result!

This plugins only gives useful output if the pins have net names. Use labels in the schematic editor to give the nets a human-readable name.

Note: in the generated code, both unconnected and power nets are ignored (commented in the output).

For C/C++ and Python format, there is a checkbox to use the pin name instead of pin number as the variable value. When checked, a filter can also be entered:

  • If the filter is left empty, the full pin name is used.
  • If something is entered, the plugin looks for this in the pin name, and extract the number after this string. For instance, if a pin name is "GPIO64/SPI", entering "GPIO" as filter will result in "64" in the output.

License

This plugin is published under MIT license.

View my other KiCad plugin: https://github.com/CGrassin/kicad-auto-silkscreen

kicad-pinout-generator's People

Contributors

cgrassin avatar pumafpv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kicad-pinout-generator's Issues

Use Pin Name instead of Pad number

It would be great to add the possibility of using Pin Name instead of Pad number (in some cases they do not match and the correct one is the Pin Name)
It might also need some kind of filtering as Pin Name could be "GPIO26" and we only want "26".
It could be implemented as a checkbox next to the dropdown menu.
I'm not quite sure how to do it, but I'd love to help.
You can contact me on Discord at PumaFPV#7895

Allow multiple component selection

Allow to select multiple components at once. The behavior depends on the format:

  • Formats with "structures" shall generate one structure per component, e.g. Python below. Formats: C enum, Python dict, HTML Table, MD Table.
pinout_U1 = { pin1: .....}
pinout_U2 = { pin1: .....}
  • Formats without structures shall instead display an error message "Multiple component selected (). Select only one to generate an output with this format." Formats: VHDL, C #define.

Notes:

  • TBC how to handle CSV/List formats.
  • This evolution is useful for documentation format, especially on connectors (e.g. #1).
  • Major code refactoring is required to implement this.

Add Microsemi PDC format output

Support for Microsemi's Physical Design Constraint File (*.pdc file extension) for Libero SoC (for the following FPGA family: PolarFire, SmartFusion2, IGLOO2, RTG4, SmartFusion, IGLOO, ProASIC3, Fusion).

Sample:

set_io LED1 -pinname J16 -fixed yes -DIRECTION OUTPUT

Sorted xdc by net name

Hello,
This is a really great tool and safes us a lot of time. Thank you for uploading this! This comment is not an issue... It would be nice, if the function "xdc_format(self, component)" in pinout_plugin.py would create the output sorted by net name and not by pin name/number.
Because of that I have made some changes in this function:


_def xdc_format(self, component):
    added_vars = []
    output = "## Pinout generated for "+component.GetReference()+" ("+component.GetValue()+")\n"
    pinout = get_pins(component)
    mylist = []                         
    for pad in pinout:
        myliststr = ""        
        var_name = str_to_C_variable(pad.GetNetname())
        myliststr += var_name + "ä"        #  ä=delimiter
        if var_name in added_vars or not pad_is_connected(pad) or pad_is_power(pad) or pad_is_passive(pad):
            myliststr += "# "
        else:
            added_vars.append(var_name)
        myliststr += "set_property -dict { PACKAGE_PIN "+pad.GetNumber()+"    IOSTANDARD LVCMOS33 } [get_ports { "+var_name+" }];\n"  
        mylist.append(myliststr) 

    #sort alphabetical
    mylist = sorted(mylist)               
    for i in range(len(mylist)):         
        output += mylist[i].split("ä")[1]
    return output

Sorry, i'm python newbie and I do not know how to solve it better.

Regards

Works properly on KiCAD 8.0.2, but not available in the plugin manager

Fairly self-explanatory: I've previously used it on version 7.0 and liked the results, so I've now installed it on KiCAD v8.0.2 (using Method B) and used it to export C++ #defines for an ESP32-S3 based PCB I'm working on.

Works out of the box, behaviour unchanged since I last used it. I found no errors when checking ithe output manually. Output for the other languages appears to be good as well.

I suggest that the kicad_version_max be updated to allow it to be downloaded via the Plugin and Content manager once again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.