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.

Tuesday, February 21, 2023

Lead Acid Battery Charger to Lithium Ion Battery Charger

I have a spotlight lamp that runs off a small 6V lead acid battery which no longer holds charge.  I replaced it with some used laptop battery cells.   The charger power adapter is just a simple transformer with full-bridge rectification; its output voltage depends on the load and can be as high as 11V .  The lead acid battery is tolerant of overcharging, but not the lithium ion battery.  So I decide to add circuitry to limit charging voltage to 8.4V.  There is a blocking diode before the battery, so the output of the power adapter should be 9V or below.   I put a 5.6V Zener off a 3.3V LDO to generate 8.9V.  The circuit is first drawn using KiCAD before assembled on a prototype board that is small enough to be placed inside the power adapter.

Thursday, November 17, 2022

Microsoft Wireless Mouse Power Circuitry

 The Microsoft wireless mouse takes two AA batteries in parallel.  Tests show that it can start at 0.8V and run down to 0.7V provided that there is enough current, which is generally not available when the batteries are drained to this low.   The voltage has to be boosted to run the optical mouse sensor, the LED and the EEPROM.  There is a boost converter, a 10-pin SSOP IC U2 that I could not identify.   But I believe it is a synchronous boost converter.   The output of the converter is measured to be 1.8V.    


We also see two diodes (D1 and D2) and another voltage of 3.2V.   We  can see the following circuit.


We can see the switch node S (Ch1) and the node A (Ch4).


The switching frequency is about 550KHz.  When the switch is on driving the node S to ground, the node A is being charged up to 1.8V and when the switch is turned off, the node S is up to about 1.8V and the output diode is turned on to drive the node B to 3.2V.   This appears to be common technique to generate an auxiliary voltage.

Friday, August 12, 2022

Multi-Slope ADC on PSoC5

High-resolution multimeters use multi-slope ADC to digitize analog voltages.  Here we implement a multi-slope ADC on a PSoC5 device; all the circuitries are inside the PSoC except for a capacitor and resistors.  The design is based on the description given in AoE3.

The bandgap reference provided is 1.024V (+/- 0.5%); it is measured 1.019V, or 0.5% from the nominal, just within the spec.   This reference is doubled to be the upper reference  and the ground is the lower reference; so the ADC range is [0, 2.048] V.   The upper reference is measured to be 2.060V; the PGA gain error can be +/-4%.  The circuit switches between the upper and lower reference to keep the integrator output near 1.024V.  One counter counts up and down according to the switch position.  At the end of the conversion, the counter value is captured and  a 12-bit SAR ADC measures the residue.  The combination is the multi-slope ADC output.

We test it by stepping the input from 0 to 2.5V in 0.1V step and convert only counts to voltages.  We get the following results.  The step size appears correct, but there is 0.1V offset, which we'll look into.


Monday, July 25, 2022

Data Acquisition through Microphone Input

We like to make use of the PC audio device for data acquisition.  Here we'll do some testing to understand the capability.  Most of the recent laptops have only one 3.5mm 4-contact jack; the connection is normally tip: left audio, 1st ring: right audio, 2nd ring: return, sleeve: microphone input.   The common 3-contact headphone plug shorts out the microphone input.    The microphone input supplies a small current to power microphones with a FET amplifier.   For the laptop that I have, the open circuit microphone input voltage is 3.168V and short circuit current 1.46mA; the source impedance is about 2K Ohm.  A typical microphone draws about 0.15mA.

Python sounddevice module can be used for acquiring the signal from the microphone input.    The output seems to be limited to [-1, 1].  The microphone properties settings of output level and boost affect the gain.  For 100 output level and 10dB boost, the gain seems to be x50; 20mVpp input has value of 1 peak-to-peak and above 40mVpp input returns 2 peak-to-peak.  Interestingly, although the output is limited to [-1, 1], it does not show clipping effect.  We do a frequency sweep from 20Hz to 20KHz and look at the power spectrum density.  The sample rate is 96KHz.


There is a sharp cutoff at 15KHz and low frequency limit around 100Hz.   The resolution seems to be 16bit.  There is another cutoff about 22KHz (perhaps for anti-aliasing).

Here is 2KHz square wave input,


The upper cutoff frequency is unfortunate because the sample rate seems to be capable of up to 384KHz.   We'll have to use frequency conversion for signal outside of the frequency range.  

Wednesday, July 20, 2022

Fluke 87

We've looked at a few of very cheap multimeters (1234).  How do they compare with the venerable Fluke DMM?  Here we'll look at an older model of Fluke 87 DMM, which costs hundreds of dollars.


The date code shown on the PCB is 1986; so perhaps Fluke 87 was first released in 1987.  The service manual is available; it contains the full schematics and parts list.  Besides the main ASIC (which does dual slope A/D conversion with a16-bit counter for 4.5-digit resolution) , there are a few ICs, a reference voltage (LM285), a RMS to DC converter (AD737), a dual opamp (TLC27M21), and a hex inverter.  The rotary knob switch is more robust than those sliding on the PCB tracks.  The input overload protection circuit is much more comprehensive, including 1500V spark gap surge protector, 910V MOVs, thermistor, a fusible resistor (1KΩ), fuses and the PCB has slots for creepage.  The DMM has a CAT III rating (1000V working voltage and 8000V transient).   Split jacks are used to detect if probes are plugged correctly for the current measurement.  Also a number of film capacitors are used and as well as a precision resistor pack.  There are two adjustable resistors and capacitors for calibration.

One factory test feature is the ultrasonic data communication.  The DMM can be put in the ultrasonic data mode by holding the HOLD button while powering up.  A periodic burst of buzzing can be heard.  We sample the speaker output at 100KHz for 2 seconds. We see it has a burst of 350ms every 600ms.  

Zoom in; we see the structure of the data.  
Zoom in further, we see 16.7KHz pulses.

We will look into how to decode it later.