Rounded Tracks Reloaded ... again: RF Tools for KiCad

Thank you for appreciating :smiley:

That was a typo :rofl: … (I’m not a native speaker of English)
It should be fixed now at the repo :smiley:
Thx

2 Likes

I have a lot of questions and comments relevant to this thread.

Looking @Anool’s posting above, I see that the 5.1.4 build for Ubuntu 18.04 has Python3 enabled. Mine, for Ubuntu 16.04, doesn’t (or so “About” claims). Why? Does it mean I need to take the risk of upgrading to Ubuntu 18.04?

I want to point out an ingenious subtlety in @maui’s RF tools: In the schematic, they are used as flags between connected nodes. This circumvents the problem of having a two-port copper “component,” which would require a different net on each port, causing the DRC to flag an error of shorted nets. However, the issue of grounding traces which are “hot” on the other side (which are a significant fraction of the wavelength) persists in RF design. As I mentioned in this forum before, since the DRC only thinks in DC, it cannot accommodate RF design. Take the printed F antenna as an example (look for “PIFA” in wikipedia): The bottom of the F is electrically “hot,” while the end of each arm is grounded. Perfectly understandable in terms of RF, since each dimension is a significant part of a wavelength, but the DRC’s “DC-only” thinking would flag a nonexistent error (shorting to ground). Probably a zero-length component would do, but how would it be visible in the layout? This problem is not unique to KiCAD.

I installed the KiCad action scripts, but only the ViaStitching plugin shows up. Here is my ‘~/.kicad_plugins’ directory structure:

kicad_plugins20191011

And here is the directory structure of ‘~/.kicad_plugins/kicad-action-scripts’:

kicad-action-scripts-20191011

‘ViaStitching’ and ‘CircularZone’ are links to the original subdirectories under ‘./kicad-action-scripts’. All installed plugins except CircularZone show up.

Concerning via stitching, I think it fails to function when I tell it to place vias only within a zone (selecting the last option on the bottom only). Otherwise, it seems to work. In general, if I had a coplanar waveguide (see, for example, https://en.wikipedia.org/wiki/Coplanar_waveguide) and I wanted a “via fence” to ground extending only a certain distance from the hot trace, is there any easy way to do that? It would be something like using the trace to define a path in Inkscape.

Finally, here is the information about my KiCAD 5.1.4:
Application: KiCad
Version: 5.1.4-e60b266~84~ubuntu16.04.1, release build
Libraries:
wxWidgets 3.0.2
libcurl/7.47.0 OpenSSL/1.0.2g zlib/1.2.8 libidn/1.32 librtmp/2.3
Platform: Linux 4.15.0-65-generic x86_64, 64 bit, Little endian, wxGTK
Build Info:
wxWidgets: 3.0.2 (wchar_t,wx containers,compatible with 2.8) GTK+ 2.24
Boost: 1.58.0
OpenCASCADE Community Edition: 6.8.0
Curl: 7.47.0
Compiler: GCC 5.4.0 with C++ ABI 1009

Build settings:
USE_WX_GRAPHICS_CONTEXT=OFF
USE_WX_OVERLAY=OFF
KICAD_SCRIPTING=ON
KICAD_SCRIPTING_MODULES=ON
KICAD_SCRIPTING_PYTHON3=OFF
KICAD_SCRIPTING_WXPYTHON=ON
KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
KICAD_SCRIPTING_ACTION_MENU=ON
BUILD_GITHUB_PLUGIN=ON
KICAD_USE_OCE=ON
KICAD_USE_OCC=OFF
KICAD_SPICE=ON

The latest Debian has both.
hermit@~:locate bin/python
/usr/bin/python
/usr/bin/python2
/usr/bin/python3
hermit@~:ls -la /usr/bin/python
lrwxrwxrwx 1 root root 7 Mar 4 2019 /usr/bin/python -> python2

It defaults to python2 though. I’d say check to see if you have both on your system. If so, then you may be able to work from there.

Just noticed you have python3 scripting = off.

An other small tool:
Trace length caliper

1 Like

@hermit: I do have python3 installed on my system. ‘ls -la /usr/bin/python’ shows me ‘/usr/bin/python -> python2.7’. Yes, I have ‘KICAD_SCRIPTING_PYTHON3=OFF’. I had 5.1.4 installed from the repo (js-reynaud-ubuntu-kicad-5_1-xenial.list); I did not compile it from source. That’ how it came from the repo. Is there a way to change ‘KICAD_SCRIPTING_PYTHON3’ without compiling from source (and selecting it as a config variable before ‘make’ is run?)?

@maui: Wow! I just did a git pull and the track caliper works! One comment: It seems to me that the track caliper and the via stitcher only work in mm and don’t care if I change the units to inches.

Thanks for your great work!

1 Like

@skuep started to develop on 2017 this action via fence plugin
I have updated the plugin adding some features and let it work with kicad 5.1.4 and did a PR, but ATM it is not merged.
You can test my version downloading my forked repo here:
Via Fence plugin

It should work fine if you select a Zone and after run the tool checking the related box.

@maui: Wow, the via fence plugin works beautifully!

As for the via stitching of a zone, I had to do the following to a zone on an inner layer, declared to be GND:

  1. Insert a couple of vias manually, and declare each of them to be part of the same net (GND); that enabled showing the whole zone filled and with the fillets at the corners.

  2. Delete the manually-placed vias, still keeping the filled display of the zone.

  3. Activate the via stitching tool, set the parameters, and then run it.

I think the crucial step was (1) above. Probably only one manually inserted via would have done it. Well, zones have always been quirky anyway. One more thing: The vias were not quite aligned (see pic). Could the grid settings have anything to do with that?

stitched_zone

Is there any way to use a different step size along different directions?

Once more, thank you for your excellent work, which elevates the value of KiCAD!

@hermit: Thank you for the suggestions. I do have python3 installed in my system. In fact, I have Ubuntu 16.04’s version, the snap version (both system-wide, of course), the anaconda version (locally, so this should not matter)… And yes, ~/usr/bin/python is a link to python2.7. I think the lack of python3 scripting is a packaging issue and I need to contact the packager—if I only knew how. Otherwise, I need to bite the bullet and compile KiCAD from source, which I’d rather avoid at the moment.

thanks… please consider that fencing vias plugin is still in development and ATM doesn’t check any DRC and can place vias on not allowed zones/pads.

Via Stitching plugin has instead already a DRC check when placing vias and it will place vias only on the selected net and allowed zones/places.

Not ATM.

Still if there is room for improvements, I think KiCAD can now handle many critical aspects that weren’t easily obtainable before.

I have done a small video to show the tools capabilities:

4 Likes

This is functionaly the same as the [Pad2pad action plugin](https://github.com/MitjaNemec/Kicad_action_plugins#pad2pad-track-distance. I should have put more resources in PR activities :grinning:

:smile:
Moreover track length feature is also available in kicad std menu (Route:Tune track length) , but I needed a very basic way to get the length without the risk to modify the track itself.

BTW I have to thank you for other code snippets :wink:
Particularly useful the hack for wxFormBuilder (which is generating incompatible dialog code for wxPython & python version 2) that I slightly modified.

I should have included contribution in my code as the hack regarding the SetSizeHints is not mine but from Qu1ck Length stats: action plugin

1 Like

please consider that fencing vias plugin is still in development and ATM doesn’t check any DRC and can place vias on not allowed zones/pads.

However, if I explicitly invoke DRC chekcing (say from the tool button), shouldn’t the errant vias be caught then?

The desired behavior would be not to place vias on not allowed places as via stitching plugin already does…
But yes, you can check DRC after invoking the fencing plugin and fix the issues.
So it is useful even if it is not complete …

1 Like

But yes, you can check DRC after invoking the fencing plugin and fix the issues.
So it is useful even if it is not complete …

Great! In reality, via fencing will most probably take place far away from non-RF components and traces, so there should be little chance of forbidden stitching anyway.

1 Like

Via fencing generates an immediate exception on Windows 5.1.4

Your exception should cite:

ModuleNotFoundError: No module named ‘pyclipper’

Via fencing plugin requires ‘pyclipper’ to be available.
Unfortunately pyclipper is not deployed on KiCAD win installation.
You need to add it using ‘pip’… open a command prompt and digit:

cd C:\Program Files\KiCad\bin
pip install pyclipper

(assuming you have installed KiCad on ‘C:\Program Files\KiCad\bin’)

@davidsrsb Please let me know if this will solve your issue on your system.

There is a further complication in MacOS as Kicad uses a specific bundled version of Python found at
/Applications/Kicad/kicad.app/Contents/Frameworks/Python.framework/Versions/Current/bin/python and does NOT use the system python. You can’t import pcbnew into the system python so you have to use the specific kicad version.

Unfortunately, the Kicad python version does not come bundled with pip or setup_tools.

If you try and run the Pyclipper setup.py using the Kicad version of python, this fails with
Download error on https://pypi.org/simple/setuptools_scm_git_archive/: unknown url type: https -- Some packages may not be found! which is a bit strange.

So I next tried /Applications/Kicad/kicad.app/Contents/Frameworks/Python.framework/Versions/Current/bin/python /usr/local/bin/pip install pyclipper

This fails as the ssl module is not available - which possibly explains the failure of the https download.

Trying to install these dependancies is becoming too much of a rabbit hole! Is the pyclipper dependancy essential for the functionality of the plug in or is it only used for the graphical display? If so, could this be made an option?

WRT the rounded tracks & taper action plug-ins, these work really well, thank you!!

Trouble here:

C:\Program Files\KiCad\bin>pip install pyclipper
Collecting pyclipper
Downloading https://files.pythonhosted.org/packages/20/a3/a60a7bad5246d66f3c54127b34b90e6d34b2cc006b84135bfcbfee4514b1/pyclipper-1.1.0.post1.zip (135kB)
100% |UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU| 143kB 728kB/s
Installing build dependencies … done
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File “”, line 1, in
File “c:\users\david\appdata\local\temp\pip-build-env-cwepg6\lib\python2.7\site-packages/setuptools/init.py”, line 228, in
monkey.patch_all()
File “c:\users\david\appdata\local\temp\pip-build-env-cwepg6\lib\python2.7\site-packages/setuptools/monkey.py”, line 101, in patch_all
patch_for_msvc_specialized_compiler()
File “c:\users\david\appdata\local\temp\pip-build-env-cwepg6\lib\python2.7\site-packages/setuptools/monkey.py”, line 164, in patch_for_msvc_specialized_compiler
patch_func(*msvc9(‘find_vcvarsall’))
File “c:\users\david\appdata\local\temp\pip-build-env-cwepg6\lib\python2.7\site-packages/setuptools/monkey.py”, line 151, in patch_params
mod = import_module(mod_name)
File “C:\Program Files\KiCad\lib\python2.7/importlib/init.py”, line 37, in import_module
import(name)
File “C:\Program Files\KiCad\lib\python2.7/distutils/msvc9compiler.py”, line 306, in
raise DistutilsPlatformError(“VC %0.1f is not supported by this module” % VERSION)
distutils.errors.DistutilsPlatformError: VC 6.0 is not supported by this module

----------------------------------------

Command “python setup.py egg_info” failed with error code 1 in c:\users\david\appdata\local\temp\pip-install-ltz6bm\pyclipper\

C:\Program Files\KiCad\bin>

:grinning:

Unfortunately it is essential to get the trace expansion path.
mathplot and numpy are instead needed only for debugging.

I did managed to use pyclipper in kicad just installing pyclipper on OSX using the os python and then I just copied the lib ‘pyclipper.so’ to the plugins path.

This is strange… I managed to install pyclipper from kicad pip directly… I will investigate further.

The KiCad exception
(Why cannot these errors be cut and paste as text?)
Via_Fence_error