knowledge_base:professional:kicad

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
knowledge_base:professional:kicad [2023/06/16 16:45] – [Library Database Setup] Normal Userknowledge_base:professional:kicad [2023/08/01 09:45] (current) – [Python Scripting] Normal User
Line 2: Line 2:
  
 ===== Using Git Server with KiCAD ===== ===== Using Git Server with KiCAD =====
 +
 +  * Each functional PCB is a repository and each revision is a folder
  
 ==== .gitignore file ==== ==== .gitignore file ====
 +
 +**.gitignore**
  
 <code> <code>
Line 21: Line 25:
 !*.kicad_pcb !*.kicad_pcb
  
-Sym lib table+Project specific sym lib table
 !sym-lib-table !sym-lib-table
  
-Footprint lib table+Project specific footprint lib table
 !fp-lib-table !fp-lib-table
  
Line 30: Line 34:
 !*.kicad_dru !*.kicad_dru
  
-# Schematic change list+# Schematic change list (user created)
 !SCH_Changelist.csv !SCH_Changelist.csv
  
-# PCB change list+# PCB change list (user created)
 !PCB_Changelist.csv !PCB_Changelist.csv
  
Line 43: Line 47:
 </code> </code>
  
-==== Python Scripting ====+**File types may not need to save** 
 + 
 +<code> 
 +# For PCBs designed using KiCad: https://www.kicad.org/ 
 +# Format documentation: https://kicad.org/help/file-formats/ 
 + 
 +# Temporary files 
 +*.000 
 +*.bak 
 +*.bck 
 +*.kicad_pcb-bak 
 +*.kicad_sch-bak 
 +*-backups 
 +*.kicad_prl 
 +*.sch-bak 
 +*~ 
 +_autosave-* 
 +*.tmp 
 +*-save.pro 
 +*-save.kicad_pcb 
 +fp-info-cache 
 + 
 +# Netlist files (exported from Eeschema) 
 +*.net 
 + 
 +# Autorouter files (exported from Pcbnew) 
 +*.dsn 
 +*.ses 
 + 
 +# Exported BOM files 
 +*.xml 
 +*.csv 
 +</code> 
 + 
 +===== Python Scripting =====
  
   * https://kicad.mmccoo.com/   * https://kicad.mmccoo.com/
Line 49: Line 87:
   * https://docs.kicad.org/doxygen-python-7.0/namespacepcbnew.html   * https://docs.kicad.org/doxygen-python-7.0/namespacepcbnew.html
   * https://docs.kicad.org/7.0/en/pcbnew/pcbnew.html   * https://docs.kicad.org/7.0/en/pcbnew/pcbnew.html
 +  * (GERBER) https://gist.github.com/aster94/bd52972ab6dbf13a44fc046b4222f7e7
 +  * (GERBER) https://gist.github.com/spuder/4a76e42f058ef7b467d9
 +  * https://dev-docs.kicad.org/en/python/pcbnew/ (how to write pcbnew plugin)
  
 +==== Hide 3D Models ====
 +
 +https://gitea.isolo.org/cpan/KiCad_Plugins
 +
 +<code>
 +# import pcbnew; print(pcbnew.PLUGIN_DIRECTORIES_SEARCH)
 +
 +C:\Program Files\KiCad\7.0\share\kicad\scripting
 +C:\Program Files\KiCad\7.0\share\kicad\scripting\plugins
 +C:\Users\TomWang\AppData\Roaming\kicad\7.0\scripting
 +C:\Users\TomWang\AppData\Roaming\kicad\7.0\scripting\plugins
 +C:/Users/TomWang/Documents/KiCad/7.0/scripting
 +C:/Users/TomWang/Documents/KiCad/7.0/scripting\plugins
 +C:\Users\TomWang\Documents\KiCad\7.0\3rdparty\plugins
 +</code>
 +
 +<code>
 +from pcbnew import *
 +board=GetBoard()
 +c86=board.FindFootprintByReference('C86')
 +d3=c86.Models()
 +d3.clear() # this cleared all the 3D models - not what we want
 +</code>
 +<code>
 +I did (in the Scripting Console)
 +
 +models = fp.Models()
 +m = models[0]
 +m.m_Show = False
 +pcbnew.Refresh()
 +</code>
 +
 +==== Custom Rules ====
 +
 +<code>
 +(version 1)
 +
 +(rule "Distance between different packages"
 + (constraint courtyard_clearance (min 10mm))
 + (condition "A.Type == 'Footprint' && B.Type == 'Footprint' && A.Library_link == '*R_0402*' && B.Library_link == '*L_1210*'"))
 +</code>
 ===== Library Database Setup ===== ===== Library Database Setup =====
  
Line 244: Line 326:
 } }
 </code> </code>
 +
 +===== Saving Configuration Files =====
 +
 +https://docs.google.com/document/d/1Rq8i2Ay7qpGpffaj-AQmE-Xp88ikHhgyt0Ygpi8717o/edit#heading=h.osuronu74isn
 +
 +https://docs.kicad.org/7.0/en/kicad/kicad.html
 +
 +KICAD_CONFIG_HOME - If we consider how KiCad is started and how the path variables are defined, this is the most important of those variables. Namely, every other variable can be defined from within KiCad so that they are stored into KiCad's own configuration. But naturally you can't store the location of the configuration into the configuration. This is the only variable you absolutely must set from outside KiCad itself if you want to change it. Every other variable you can change through KiCad's Configure Paths dialog, provided that the variable hasn't already been set from outside KiCad as an actual system environment variable.
 +
 +The default location of configuration is at C:\Users\<username>\AppData\Roaming\kicad\7.0 if KICAD_CONFIG_HOME is not set. The following three files are important:
 +  * kicad_common.json - it has a section that stores environment variables
 +  * fp-lib-table - global footprint library links.
 +  * sym-lib-table - global schematic symbol library links.
 +
 +One convenient way of saving configuration is to save the entire folder of C:\Users\<username>\AppData\Roaming\kicad\7.0 (push to git). Then delete the folder. KiCad will give you an option to import configuration the next time it starts. Point to the saved folder to import all the configurations.
 +
 +Example configuration (version 7.0.5) - {{ :knowledge_base:professional:kicad_config.zip |}}
 +
 +=== List of Environment Variables ===
 +
 +^Variable name^Explanation^
 +|KICAD_CONFIG_HOME|Directory for the KiCad configuration files.|
 +|KICAD_SYMBOL_DIR|Used in the official symbol library's sym-lib-table to point to the directory where the symbol libraries are installed.|
 +|KISYSMOD|Used in the official footprint library's fp-lib-table to point to the directory where the footprint libraries are installed.|
 +|KISYS3DMOD|Used inside the official footprint library's footprint files to point to the directory where the 3D model libraries are installed.|
 +|KIGITHUB|Not used anymore with official libraries. This was used when the official libraries were still loaded from github by KiCad (in version 4).|
 +|KICAD_TEMPLATE_DIR|Directory for the KiCad's official project templates. See File -> New -> Project from Template in the project window.|
 +|KICAD_USER_TEMPLATE_DIR|Directory for the user's own project templates. See File -> New -> Project from Template in the project window.|
 +|KICAD_PTEMPLATES|Not recognized anymore. Use KICAD_TEMPLATE_DIR and KICAD_USER_TEMPLATE_DIR.|
 +|KICAD_WKSFILE|Full path to the .kicad_wks file which has the page layout. See File -> Page Settings in Pcbnew and Eeschema.|
 +|EDITOR|The text editor which KiCad may open. See the project window -> Browse -> Open Text Editor and Preferences -> Set Text Editor.|
 +|XDG_CACHE_HOME|See XDG_RUNTIME_DIR below. See *NOTE below.|
 +|XDG_CONFIG_HOME|Directory for the configuration files. Use KICAD_CONFIG_HOME instead, which also overrides this if set. This is recognized on all platforms. See *NOTE below.|
 +|XDG_RUNTIME_DIR|Unix only (excluding OSX). Directory for the lockfile (used for the "kicad is already running" warning). If this is not set, XDG_CACHE_HOME is used. If that is not set, either, $HOME/.cache is used. On non-Unix systems the lockfile is saved to a system specific fixed location. See *NOTE below.|
 +
 +=== Using Template to Save Board Settings ===
 +
 +
 +=== GERBER out procedure ===
 +
 +https://www.circuitstate.com/tutorials/how-to-get-your-kicad-pcb-design-ready-for-automated-assembly-kicad-6-tutorial/
 +
 +https://www.pcbway.com/blog/help_center/How_to_Generate_Gerber_and_Drill_Files_in_KiCad_7_0_ab0d12bb.html
 +
 ==== References ==== ==== References ====
  
  • Last modified: 2023/06/16 16:45
  • by Normal User