Wednesday, April 19, 2023

KiCad 7 vs Altium 22

 Both software evolves fast, so we compare the specific versions.

Altium is a feature rich package, exceeding KiCad in all capabilities.  However, KiCad is free and open-source and supported on multiple OSes, Windows, Linux, Mac OS.  It is very nice to be able to  work on the design on both Windows and Linux.  There is no license to mess with and not to have to worry about lose connection to the license server.

Altium still crashes quite frequently.  KiCad is getting more stable, but I have not tried with large design.  I suspect it may not handle large designs well.  

First we look at the importing Altium files into KiCad, which gives an indication of the equivalency in the features.   It does not seem to be an option to import the project directly (as there are for EAGLE and CADSTAR project).  We start by importing the PCB file in the PCB editor and a KiCad project is created.  Then we import the schematics in the schematic editor.  The importer seems doing a reasonable good job.  A hierarchical design can be imported all at once, but  for a flat design, sheets have to be imported one by one and sheet blocks have to be added.  But this leads to discrepancies with the imported PCB which uses flat netlist, and not all can be resolved by relinking.  Netclass is imported into the PCB, but the netclass labels are not shown the schematics. Harness is not handled correctly.  Text links are not imported,  Off Sheet Connectors are imported to global power net symbols, which does work correctly, but they are more propriate as global labels., Text locations are not always show correctly, because the justification is not applied correctly.  No compiler mask.  Solid region is mapped to polygon but it cannot be assigned a net.  There is no line arrow mode.  Ellipse drawing object is not supported.  Embedded bitmap is not imported.  Altium nets are flatten in the PCB, but KiCad maintains hierarchical net names. Stackup information is not imported, such as layer thickness, dielectric constant.  Polygon cutout turns into a keepout area.  Some multi-part symbols are not imported correctly.  Overall it seems to do a much better job with the PCB documents than schematics.  Schematic editor does not allow reference designator to contain space, although the netlist seems to allow it, just cannot manually edit it.

 KiCad schematic origin is at the upper left corner.  KiCad's coordinates y-axis points downwards and Altium is the opposite.  Altium uses parameters, KiCad has Text Variables.

KiCad's symbol and footprint libraries are very extensive.  And SnapEDA, Ultralibrarian can support KiCad and Altium.  Altium has BOM support with distributors, which can get inventory information.

KiCad has no specific support for rigid flex design, like specifying multiple stackups.   But rigid flex PCB can certainly be design using KiCad; some footprints may have to be modified to be placed on the inner layers that are used for flex section.

In KiCad, whether to tent via is a global option, actually only in effect when generating Gerber files.  So it can be applied to selected vias. The 3D viewer seems to ignore the option, only show tented vias.

KiCad lacks something like Altium's Navigator.  Symbol Field Table can somewhat remedy this by browsing the components, but no netlist.

Altium has more extensive support for design rules, which is vital for large complex designs. 

Altium Note is collapsible.

KiCad use Python as the script language for plugins.  Interactive HTML BOM (ibom) plugin is very nice.

KiCad themal relief properties are settable for each pad.

KiCad has only one type of copper area, zone. Altium has fill, solid regsion, polygon pour.  KiCad does not have real plan layer; the plane layer has to be created with zone.

Altium is much more capable of editing multiple selected objects.  This is an important feature that a good PCB layout tool must have.  KiCad property manage can do some of it, but lack a similar feature in schematic editor (Edit Symbol Field edit can edit multiple symbol field.).   

Altium has more ways to select, Find Similar is useful.  KiCad has selection filter for PCB, but not for schematic.

KiCad cannot open multiple sheets at the same time, no tabbed view like Altium.  One way to get around it is to open another sheet separately with  another instance of Schematic Editor

KiCad has bus similar to harness.  KiCad bus can define fields beyond simple array.

KiCad requires hierarchical bocks for multiple sheets.  It is not necessary a bad thing, but sometimes you just want to draw one circuit over over multiple pages.

KiCad does not have multichannel support.  Altium has the concept of room, which aids multichannel layout.

Crossing probing works, the components are selected, but the nets and pads have to use net highlighter. 

Search Panel shows Footprints, Zones, Nets and Text, but the list cannot be sorted.  When clicked on, the item is highlighted, but not centered and zoomed.  It does center and zoom on the schematics.

There is no integrated library in KiCad, which is not much an issue.  The symbols can have default  footprints, but cannot be overridden, which I think is preferable.

KiCad does not have a way to create a simple 3D body; but creating mechanical models are better done in MCAD anyway.  The integration between KiCad and FreeCAD through KiCadStepup is good enough.

For interactive routing, KiCad supports  Highlight collisions, Shove, Walk around; more or less matching Altium's.  Altium also has a HugNPush mode and Altium seems faster especially for large designs.

Altium has more copper zone editing features.  Altium can shelve copper pours.  KiCad can display copper zone in filled or outline mode.  KiCad can control thermal relief on individual pad settings.  Altium does it with design rules.

No revision control integration.

No support for curve routing, but Fillet Track can round corners.  There is also a plugin to round tracks.

No support for auto routing, but there is the freerouting plugin.

Altium includes field solver integrated in the stackup to calculate controlled impedance.  KiCad's Calculator Tools can estimate some transmission line parameters.

KiCad may not be able to replace Altium for professional work, but it can certainly handle most of the PCB designs and it will keep Altium on their toes, which is a good thing.


Thursday, April 6, 2023

Building KiCad from Source

KiCad has become increasingly capable of taking on large PCB designs.  It's good to take a look at the source code.  We'll try to the build on Ubuntu 20.04.  The latest version is 7; and the work on version 8 has begun.  The source code is cloned, `git clone --filter=blob:none https://gitlab.com/kicad/code/kicad.git`; we use the filter to keep the repo small, still it is almost 400MB. 

The next is to install all the necessary libraries, wxWidgets, Boost C++, GLEW, ZLib, GLM, GLUT, Cario 2D Graphics, OpenCascade, ngspice, curl, wxpython

libbz2-dev, libcairo2-dev, libglu1-mesa-dev,  libgl1-mesa-dev, libglew-dev, libx11-dev, libwxgtk3.2-dev, mesa-common-dev,  libssl-dev, python3-dev,  python3-wxgtk4.0, libboost-all-dev, libglm-dev, libcurl4-openssl-dev,  libgtk-3-dev, ngspice-dev, libngspice0-dev, libocct-modeling-algorithms-dev, libocct-modeling-data-dev, libocct-data-exchange-dev, libocct-visualization-dev, libocct-foundation-dev, libocct-ocaf-dev, unixodbc-dev, zlib1g-dev

The KiCad 7 requires  wxwidget 3.2, which is not in the Ubuntu repositories.  We have to get an unofficial release from https://repos.codelite.org/wx3.2.0/ubuntu/.  And wxpython version 4.0 has to be installed and built against wxwidget 3.2.

And some tools, 

cmake, doxygen, build-essential, pkg-config, source-highlight, cmake-curses-gui, debhelper, swig4.0, dblatex, po4a, asciidoc, shared-mime-info

To make the build faster, we'll use ninja as the build system and lld as the loader.

cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DKICAD_USE_EGL=ON -DCMAKE_INSTALL_PREFIX=/opt/kicad -DCMAKE_CXX_FLAGS=-fuse-ld=lld ../../

Then kick off the build with ninja.  The build process took a hour and half on my computer.   The build files total 11GB.   The installed files are almost 3GB, without symbol and footprint libraries which are on a separate repository.  The files are large because we build with debugging info.  

To make a smaller release build, 

cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DKICAD_BUILD_QA_TESTS=OFF -DKICAD_USE_EGL=ON -DCMAKE_INSTALL_PREFIX=/opt/kicad -DCMAKE_CXX_FLAGS=-fuse-ld=lld ../../

This only takes about half an hour, with the build files total 600MB and the installed files less than 300MB.  The executables are much smaller in size.