KiCAD

How to connect 100Base-FX transceiver to SFP module (schematic)

Also see my post on selecting a suitable 100Base-FX Ethernet PHY.

Note that sometimes the capacitors and the 100 Ohm termination resistor is integrated in the specific SFP module in use! In that case, replace the capacitors by 0 Ohm resistors and omit the 100 Ohm resistor. My recommendation is to check out the datasheet of the SFP module or just try it out with the capacitors & termination if you don’t know.

100Base-FX transceivers are pretty easy to connect to the PHY, but you have to terminate the high speed interface correctly. Since PECL logic is used, the termination scheme is somewhat difference.

PECL & AC termination

The first thing is understand is that while all SFP modules are equal (i.e. subject to the SFP multi-source agreement), some are more equal than others.

More specifically, some of them include termination resistors, some of them include AC coupling capacitors, some of them include both and some of them include none. My recommendation is to assume that the SFP module contains both AC coupling caps and the transmit termination, but have spare component footprints in case you need to add them. Similar strategies are recommended

What you absolutely need is:

  • A 50 Ohm differential trace between the SFP and the PHY
  • Some termination scheme on the PHY side
  • You 100% absolutely need to checkout your PHY’s datasheet, or ask the manufacturer for reference schematics!
  • Short traces – the shorter the traces, the less headache you’ll get from debugging. You don’t want more headache than neccessary, believe me.

What you might or might not need, depending on SFP, PHY and board layout is:

  • Additional terminations (if you add those while other termination is already in place, this will approximately half your signal amplitude.
  • AC coupling capacitors (doesn’t hurt all too much to include them even if they are redundant)
  • Pullup resistors for the PHY driver

Variant 1: Microchip

The following information is based on Microchip’s application note for the LAN93xx series. The basic termination strategy is to use a 100R differential transmit termination, included with the note that some transceivers already contain the termination resistor inside them and using an extra termination resistor.

Note that in one of the schematics Microchip swapped the termination resistors. The 130 Ohm resistor should go toward 3.3V and not toward ground.

Furthermore, Microchip requires 50 Ohm (read: 49.9 Ohm) pull-up resistors to be fitted to the transmit lines. These resistors are required for the Microchip drivers, but not required for all drivers.

Variant 2: Marvell

In Marvell’s 88E3015/88E3018 datasheet, a slightly different termination scheme is implemented which omits the differential 100R termination resistor in favour of a pair of

Note that the Marvell device does not specify 50R pullup resistors. As far as I could find out SFP modules never appear to require these pullups, but some PHYs do. The only safe variant is to include these pullups into the schematic and do not populated them.

Combining the variants

A good idea with high speed signals, especially with different transceivers is to include all possible options and then just try out what works best.

Download KiCAD schematic

My recommendations on what to start with are as follows:

  • All resistors shown with NA values: Do not populate, populate only if needed experimentally
  • Since most SFP receivers already include AC coupling capacitors, these are not needed, but they typically do not hurt either
  • Try to keep the traces between the PHY and the SFP module short. This will solve most signal integrity problems without having to test-fit resistors etc.

In addition to the high speed data connection from the SFP module to the PHY, you want to find the LOS (loss of signal) pin, sometimes called signal detect or link detect and also connect it directly from the SFP module to the PHY (no termination or pullups required).

Regarding the layout, as usual with high speed connections, ensure that the components are placed near to the relevant components and try to place the PHY and the SFP module as close together as possible.

Posted by Uli Köhler in Electronics, KiCAD, Networking

How to initialize your KiCAD 6 project on the command line

For the KiCAD 5 version of this script see How to initialize your KiCAD 5 project on the command line

TL;DR:

Inside the directory where you want to create the project, run

wget -qO- https://techoverflow.net/scripts/kicad6-init.sh | bash /dev/stdin MyProject

You should replace MyProject (at the end of the command) with your project name.

Note: This will initialize an empty KiCAD project without any libraries. This is equivalent to creating a new project in KiCAD itself (using the GUI).

Continue reading →

Posted by Uli Köhler in Electronics, KiCAD, Shell

How to fix KiBot ‘KiBoM not installed or too old’

Problem:

When running kibot-check, you see the following warning message:

* KiBoM not installed or too old
  Visit: https://github.com/INTI-CMNB/KiBoM
  Download it from: https://github.com/INTI-CMNB/KiBoM/releases
  - Mandatory for `kibom`

but even installing kibom using pip install kibom, the warning does not disappear.

Solution:

You need to install a specific fork of KiBom:

pip install git+https://github.com/INTI-CMNB/KiBoM

After that, the warning will disappear.

Posted by Uli Köhler in Electronics, KiCAD, Python

How to check only a single schematic symbol against KLC (KiCAD library conventions)

In our previous post How to check KiCAD symbol library against KLC (KiCAD library conventions) we showed how to use check_symbol.py to check a symbol library against the KiCAD library guidelines.

You can also use it to check only a specific symbol in that library by name, which removes most of the clutter from the output. Use -c "CD4066B" to just check the component named CD4066B.

~/kicad-library-utils/klc-check/check_symbol.py MyLibrary.kicad_sym -vv -c "CD4066B"

This will print, for example:

Checking symbol 'Analog_Switch:CD4066B':
  Violating S3.1
    Origin is centered on the middle of the symbol
    Symbol unit 3 slightly off-center
     -   Center calculated @ (-25, -25)
    Symbol unit 4 slightly off-center
     -   Center calculated @ (-25, -25)
    Symbol unit 5 not centered on origin
     - Center calculated @ (-100, 0)
  Violating S4.1
    General pin requirements
    Pins not located on 100mil (=2.54mm) grid:
     - Pin C (6) @ (-400,50) 
     - Pin C2 (9) @ (350,-100) 
     - Pin D2 (10) @ (350,-100) 
     - Pin D (12) @ (-400,50) 
  Violating S5.2
    Footprint filters should match all appropriate footprints
    No footprint filters defined

 

Posted by Uli Köhler in Electronics, KiCAD

How to check KiCAD symbol library against KLC (KiCAD library conventions)

First, clone kicad-library-utils using

git clone https://gitlab.com/kicad/libraries/kicad-library-utils.git

Then, run the check script against your library using

~/kicad-library-utils/klc-check/check_symbol.py MyLibrary.kicad_sym -vv

You might need to adjust the path to kicad-library-utils accordingly.

This will provide colored output on the command line such as

Checking symbol 'Analog_Switch:FSA3157L6X':
Checking symbol 'Analog_Switch:NC7SB3157P6X':
  Violating S3.1
    Origin is centered on the middle of the symbol
    Symbol unit 1 not centered on origin
     - Center calculated @ (0, -112)
  Violating S3.6
    Pin name position offset
    Pin offset outside allowed range
     - Pin offset (5) should not be below 20mils

 

Posted by Uli Köhler in Electronics, KiCAD

How to install KiCAD 6.0 on Ubuntu

Run this to install KiCAD 6.0:

sudo add-apt-repository ppa:kicad/kicad-6.0-releases
sudo apt update -y
sudo apt -y install kicad

 

Posted by Uli Köhler in KiCAD, Linux

How to start KiCAD installed from flatpak

After you have installed KiCAD from Flatpak using

flatpak install --from https://flathub.org/repo/appstream/org.kicad.KiCad.flatpakref

you can run it using

flatpak run org.kicad.KiCad

You can append any arguments to KiCAD, for example open a project file directly from the command line:

flatpak run org.kicad.KiCad MyProject.pro

 

Posted by Uli Köhler in KiCAD

How to fix KiCAD Unable to add inotify watch: (error 28: No space left on device) on Linux

Problem:

When opening KiCAD on Linux, you see the error message Unable to add inotify watch: (error 28: No space left on device):

Solution:

You need to increase the number of inotify watches that can be active at once:

echo fs.inotify.max_user_watches=65536 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

and then restart KiCAD

Posted by Uli Köhler in KiCAD

Where to find DO214AC package in KiCAD?

The DO214AC package is more commonly called SMA. In KiCAD you can find it in the Diode_SMD library as D_SMA package

Posted by Uli Köhler in Electronics, KiCAD

How to draw PCIe card edge connectors in KiCAD

You can download the Connector_PCBEdge library from the KiCad website and use the footprints from there for your PCI express card. You can use one of these footprints:

  • BUS_PCIexpress_x1
  • BUS_PCIexpress_x4
  • BUS_PCIexpress_x8
  • BUS_PCIexpress_x16
Posted by Uli Köhler in KiCAD

What .gitignore to use for KiCAD projects?

KiCAD generates a lot of backup-like files, for example MyPCB.sch-bak that should be ignored by git and don’t need to be committed to the repository.

This is the .gitignore file I use to manage my KiCAD projects:

*-bak
*-backups
*-cache*
*-bak*
_autosave*
\#auto_saved_files\#

Note that TechOverflow’s KiCAD project initialization script automatically generates this.gitignore.

Posted by Uli Köhler in KiCAD

Arduino MKR Zero schematic library for KiCAD

This library provides a schematic symbol for the Arduino MKR zero’s 2.54mm (0.1″) headers. Currently I don’t have the footprint

Download KiCAD schematic library here (ArduinoMKRZero.lib)

This KiCAD library is hereby released into the public domain (CC0 1.0 Universal)

This image shows the Arduino MKR Zero schematic symbol from the library.

Posted by Uli Köhler in Arduino, Electronics, KiCAD

Reading and writing KiCAD libraries in Python

This snippet provides a parser and serializer for KiCAD schematic symbol libraries and DCM symbol documentation libraries. It will parse the KiCAD libraries into a number of records, consisting of a list of lines. An extended version of this snippet has been used in my KiCADSamacSysImporter project

__author__ = "Uli Köhler"
__license__ = "CC0 1.0 Universal"

class KiCADDocLibrary(object):
    def __init__(self, records=[]):
        self.records = records
        
    @staticmethod
    def read(file):
        # A record is everything between '$CMP ...' line and '$ENDCMP' line
        records = []
        current_record = None
        for line in file:
            line = line.strip()
            if line.startswith('$CMP '):
                current_record = []
            # Add line to record if we have any current record
            if current_record is not None:
                current_record.append(line)
            if line.startswith("$ENDCMP"):
                if current_record is not None:
                    records.append(current_record)
                    current_record = None
        return KiCADDocLibrary(records)
        
    def write(self, out):
        # Write header
        out.write("EESchema-DOCLIB  Version 2.0\n")
        # Write records
        for rec in self.records:
            out.write("#\n")
            for line in rec:
                out.write(line)
                out.write("\n")
        # Write footer
        out.write("#\n#End Doc Library\n")        

        
class KiCADSchematicSymbolLibrary(object):
    def __init__(self, records=[]):
        self.records = records
        
    @staticmethod
    def read(file):
        # A record is everything between 'DEF ...' line and 'ENDDEF' line
        records = []
        current_record = None
        current_comment_lines = [] # 
        for line in file:
            line = line.strip()
            if line.startswith("#encoding"):
                continue # Ignore - we always use #encoding utf-8
            # Comment line processing
            if line.startswith("#"):
                current_comment_lines.append(line)
            # Start of record
            if line.startswith('DEF '):
                current_record = current_comment_lines
                current_comment_lines = []
            # Add line to record if we have any current record
            if current_record is not None:
                current_record.append(line)
            if line.startswith("ENDDEF"):
                if current_record is not None:
                    records.append(current_record)
                    current_record = None
            # Clear comment lines
            # We can only do this now to avoid clearing them before
            #  they are used in the DEF clause
            if not line.startswith("#"):
                current_comment_lines = []
        return KiCADSchematicSymbolLibrary(records)
        
    def write(self, out):
        # Write header
        out.write("EESchema-LIBRARY Version 2.4\n#encoding utf-8\n")
        # Write records
        for rec in self.records:
            for line in rec:
                out.write(line)
                out.write("\n")
        # Write footer
        out.write("#\n#End Library\n")        

 

Posted by Uli Köhler in Electronics, KiCAD, Python

How to initialize your KiCAD 5 project on the command line

In case you are using KiCAD 6 (released in 2021), this is not the right post for you ! See How to initialize your KiCAD 6 project on the command line

Note: This script initializes a KiCAD project in the recommended configuration (i.e. with project-specific footprint and symbol libraries). In case you want to initialize an empty project, see How to initialize an empty KiCAD project on the command line

TL;DR:

Inside the directory where you want to create the project, run

wget -qO- https://techoverflow.net/scripts/kicad-init.sh | bash /dev/stdin MyProject

You should replace MyProject (at the end of the command) with your project name.

Note: This will initialize an empty KiCAD project without any libraries. This is equivalent to creating a new project in KiCAD itself (using the GUI).

Continue reading →

Posted by Uli Köhler in Electronics, KiCAD, Shell

What are KiCAD .lib files?

.lib files in KiCAD contain schematic symbols, for example

or

Continue reading →

Posted by Uli Köhler in KiCAD

How to initialize an empty KiCAD project on the command line

TL;DR:

Note: We recommend to use our new script to initialize a project with project-specific footprint and symbol libraries, see How to initialize your KiCAD project on the command line. The script on this page initializes an empty project without any libraries.

Inside the directory where you want to create the project, run

wget -qO- https://techoverflow.net/scripts/kicad-initialize.sh | bash /dev/stdin MyProject

You should replace MyProject (at the end of the command) with your project name.

Note: This will initialize an empty KiCAD project without any libraries. This is equivalent to creating a new project in KiCAD itself (using the GUI).

Continue reading →

Posted by Uli Köhler in Electronics, KiCAD, Shell