It became necessary to create a spiral coiled conductor pattern on a printed circuit board. The printed circuit board CAD KiCad [^ 1] does not have such a function. It's a lot of work to create by hand, and it's difficult to create regular patterns. It is realized as a footprint using an independent tool.
Find the published tool. A web search will give you those images and hints. Spiki [^ 3] was introduced on the page [^ 2] that introduces the plugin, but I gave up because it required Python2 and PyQt4 and it was difficult to maintain the operating environment. I searched GitHub and was able to use the latest kicad-coil-generator [^ 4].
Download the installation program [^ 5] and run it. The default seems to be the 32-bit version. This time I chose the 64-bit version. Enable the PATH addition option during installation and also perform the process of removing the character limit of PATH. I also created a virtual environment with venv.
C:\Users\user_name>python -m venv venv_kicad
C:\Users\user_name>call venv_kicad/scripts/activate.bat
(venv_kicad) C:\Users\user_name>
--Confused venv (standard with Python3) and virtualenv (provided by a third party). --Line 1: Running the "python3" command at the Windows 10 command prompt does not run python and does not cause an error. The venv folder is also not created. I found that losing the command parameters led to a Python installation in the Windows Store.
Clone kicad-coil-generator from github and install the Python library according to the README.md. I was angry that I didn't have a wheel, but KiCadModTree was installed.
(venv_kicad) C:\Users\user_name\kicad_coil_generator>pip install wheel
(venv_kicad) C:\Users\user_name\kicad_coil_generator>pip install -r requirements.txt
(venv_kicad) C:\Users\user_name\kicad_coil_generator>
Display help.
(venv_kicad) C:\Users\user_name\kicad_coil_generator>python coil_generator.py --help
usage: coil_generator.py [-h](-r R_INNER | -d D_INNER) (-R R_OUTER | -D D_OUTER) -n N_TURNS -w LINE_WIDTH [--direction {counter_clockwise,clockwise}]
[-p {SMT,THT,CONNECT}] [-x DRILL_RATIO] [-a RING_WIDTH] [--points_per_turn POINTS_PER_TURN]
file_name {spiral,square}
Generates KiCad footprints of spiral/square coils.
positional arguments:
file_name path to the file in which to save the footprint; will overwrite previous file (this program cannot addmultiple footprints to the same file, so
files have to be concatenated manually)
{spiral,square} type of the coil created
optional arguments:
-h, --help show this help message and exit
-r R_INNER, --r_inner R_INNER
inner radius of the coil [mm]
-d D_INNER, --d_inner D_INNER
inner diameter of the coil [mm]
-R R_OUTER, --r_outer R_OUTER
outer radius of the coil [mm]
-D D_OUTER, --d_outer D_OUTER
outer diameter of the coil [mm]
-n N_TURNS, --n_turns N_TURNS
number of turns of the coil
-w LINE_WIDTH, --line_width LINE_WIDTH
width of the copper path used [mm]
--direction {counter_clockwise,clockwise}, --dir {counter_clockwise,clockwise}
direction in which the coil turns (starting from outer part)
-p {SMT,THT,CONNECT}, --pad_type {SMT,THT,CONNECT}
type of the pads drawn at the ends of coil's path
-x DRILL_RATIO, --drill_ratio DRILL_RATIO
ratio of the drill in pad to line width (only for SMT/THT pads)
-a RING_WIDTH, --ring_width RING_WIDTH
Width of the ring around the drill
--points_per_turn POINTS_PER_TURN
(spiral only) number of arcs used for each full turn of the coil
(venv_kicad) C:\Users\user_name\kicad_coil_generator>
It cannot be executed by using py instead of the python command.
(venv_kicad) C:\Users\user_name\kicad_coil_generator>py coil_generator.py --help
Traceback (most recent call last):
File "coil_generator.py", line 12, in <module>
import KicadModTree as kmt
ModuleNotFoundError: No module named 'KicadModTree'
I created two types, spiral) and square, with an inner radius of 35 mm, an outer radius of 45 mm, 20 turns, and a pattern width of 0.25 mm. Kicad footprint format files "test1.kicad_mod" and "test2.kicad_mod" have been generated.
(venv_kicad) C:\Users\user_name\kicad_coil_generator>python coil_generator.py test1 spiral -r 35 -R 45 -n 20 -w 0.25
Line spacing = 0.250 mm
(venv_kicad) C:\Users\user_name\kicad_coil_generator>python coil_generator.py test2 square -r 35 -R 45 -n 20 -w 0.25
Line spacing = 0.276 mm
(venv_kicad) C:\Users\user_name\kicad_coil_generator>dir
There is no volume label for drive C.
Volume serial number is 6A6D-1120
C:\Users\user_name\kicad_coil_generator directory
2020/07/18 13:55 <DIR> .
2020/07/18 13:55 <DIR> ..
2020/07/18 12:59 6,999 coil_generator.py
2020/07/18 12:59 808 README.md
2020/07/18 12:59 58 requirements.txt
2020/07/18 12:59 <DIR> screens
2020/07/18 12:59 4,978 spiral.py
2020/07/18 12:59 2,086 square.py
2020/07/18 13:54 8,128 test1.kicad_mod
2020/07/18 13:54 7,743 test2.kicad_mod
2020/07/18 13:23 <DIR> __pycache__
7 files 30,800 bytes
4 directories 194,298,355,712 bytes of free space
(venv_kicad) C:\Users\user_name\kicad_coil_generator>
Import the generated footprint file into KiCad's footprint editor for viewing. "test1.kicad_mod" "test2.kicad_mod" I feel it is a beautiful pattern.
Based on the generated pattern, I created a footprint with swirls placed on both sides and a via connection in the center.
The tip of the coil is a "connector", but if it is left as it is, it will not be possible to connect the wiring after placing it in the printed circuit board editor. I think this is because there is a prohibited area around the coil pattern. The shape of the connectors on both ends has been changed to a "custom shape (circular anchor)" and modified to draw out from the coil pattern.
KiCad has the feature that the data is in text format and can be modified or completed by an external program. Many people create and publish useful external programs. I would like to thank these people and make effective use of their assets. I hope I can provide some useful tools in the future.
Recommended Posts