8.1. pyopus.netlister.kicad
— KiCad netlister¶
Main KiCad netlister module.
Invoke it by running
python3 -m pyopus.netlister.kicad <options>
Command line arguments:
-t
,--console
- run in console mode. Displays output and errors in console. By default the netlister runs in GUI mode where the resulting netlist and errors are reported by popping up a window.-c
,--config-file
- name of the default config file/name suffix. If not specifiednetlister.json
is used. This must be a file name, not a path to a file. The config file is assumed to be in the same folder as the intermediate XML netlist file.-s
,--skip-config
- do not read a config file in JSON format.-n
,--no-print-netlist
- disables displaying the netlist on success.-d
,--dump-config
- dumps the configuration in JSON format to an output file if it is specified with-o
. Otherwise dumps to a popup window or STDOUT (if-t
is specified). This feature is useful for debugging. It can also be used for creating an initial configuration file that is a starting point for customizing netlist generation.-i
,--input-file
- input KiCad XML netlist file. Default isnetlist.xml
.-o
,--output-file
- output Spice Opus netlist file Default isnetlist.cir
. Also used for specifying where to store the JSON configuration file.
By default a JSON config file is read from <output file>.netlister.json
.
If this file is not found the config is read from netlister.json
. The
default configuration file/name suffix can be specified with the -c
option. The configuration file is assumed to be in the same folder as the
intermediate XML netlist.
The config file is in JSON format. The mapping
member is dumped as a
list. Every component mapping is a list with 3 elements: library name,
component name, and an associative array with the same keys as the
description of an entry in the mapping
member of config.
8.1.1. Setting up KiCad¶
PyOPUS requires KiCad 5 or 6. Start the schematic editor (eeschema). In KiCad 5 select Tools/Generate Netlist File in the menu. In KiCad 6 select File/Export/Netlist in the menu. Click “Add Plugin”. Under “Name” enter:
Spice Opus
Under “Netlist command” enter:
python3 -m pyopus.netlister.kicad -i "%I" -o "%O"
For Windows the command for running the netlister is:
<full path to pythonw.exe> -m pyopus.netlister.kicad -i "%I" -o "%O"
Click “OK”. A tab will appear for generating Spice Opus netlists. You need to do this only once. KiCad will store your settings in its configuration. For Linux make sure python3 is in your path. Also make sure the PyOPUS installation folder is listed in the PYTHONPATH environmental variable if PyOPUS is not installed in the Python libraries folder.
To make KiCad 5/6 behave in the same manner as KiCad 4 when placing symbols, select Preferences/General Options (Preferences/Editing Options in KiCad 6) in the menu. Select the Editing tab. Uncheck:
Automatically place symbol fields
Allow field autoplace to change justification
Always allign autoplaced fields to the 50 mil grid
The pyopus symbol library is distributed with PyOPUS demos in demo/kicad/library. For KiCad 5 you need files: pyopus.lib (symbol definitons) and pyopus.dcm (auxiliary data). For KiCad 6 the symbol library is in pyopus.kicad_sym (definitions and auxiliary data). To specify the location of the pyopus symbol library, select Preferences/Manage Symbol Libraries in the menu. In the Global Libraries tab click on Append Library. Fill the created entry with the following values:
Active: mark checkbox
Nickname: pyopus
Library Path: <absolute path to pyopus.lib for V5 or pyopus.kicad_sym for V6>
Plugin Type: Legacy for V5, KiCad for V6
Decription: PyOPUS symbol library
Leave the Options field empty. This procedure also needs to be done only once.
To generate a Spice Opus netlist in KiCad 5, select Tools/Generate Netlist File
in the menu. In KiCad 6 choose File/Export/Netlist.
Choose the “Spice Opus” tab, and click on “Generate”. A window with the
generated netlist will pop up. In case of an error the window will show
the error message. To disable the popup window and show it only in case
of an error add the -n
option to the Netlist command.