This is a tutorial about creating a new part (specification for an electronic component) for Fritzing
Many common parts are distributed with Fritzing but users can create and contribute parts.
The example is part number BQ25504. It is only sold in the QFN-16 package, an SMD package.
You can buy an adaptor from a QFN-16 package to a DIP package. Suppose you want to build a PCB optimized for small size, without an adaptor. But the QFN-16 package is not in Fritzing. Thus you need to create a new part, loosely speaking. But you can do so by extending the “Generic IC.”
About Fritzing’s “Generic IC”
A “Generic IC” is a part in Fritzing. In most cases, a generic IC represents a class of real parts that are available:
- in a standard DIP package suitable for use on a breadboard OR fitting an adaptor to a standard DIP package
- in other packages for use on a PCB.
A set of generic IC instances in a Fritzing design may all look the same in the breadboard view (having a DIP package), but have different packages (footprints) in the PCB view. You can specialize a generic IC by choosing a package for an instance. (You can also specialize an instance by choosing a count of pins, or by changing pin labels. In other words, a part class is a template.) Here, we extend the “Generic IC” template by adding a package.
(Suppose you don’t intend to build a breadboard. Then Fritzing’s breadboard and schematic views are an abstraction, where you can abstractly specify your design. Then it doesn’t matter what package appears in the breadboard view. This example is building a package for the PCB view of Fritzing. Generally you breadboard before going to a PCB, but you might have an evaluation board for prototyping.)
Alternative: Creating a new, special part class
An alternative is to create a whole new part class, or template. It might have a unique breadboard and schematic image. Each pin in the template might have a unique label such as “VCC”, instead of a generic label “1.” Creating a whole new part class saves time when you place many instances of the part in a Fritzing design: it saves extra steps to specialize each instance. This example is for a part that usually appears once in a design.
The usual strategy is:
- open an existing part (template) i.e. open files that specify the template
- modify the files
- “Save As”
You usually start from a template similar to the goal. Here we start with the files that define the “QFN-20-0.4MM” package of the “Generic IC”, which has four more pins (pads) than we need.
I use the word “reimplement” to mean the process of deriving a new variant of an existing object.
What files to reimplement
A Fritzing part class is defined by five files:
- icon image SVG file (.svg)
- breadboard image SVG file
- schematic image SVG file
- PCB image SVG file
- metadata xml file (.fzp)
Here we reimplement the fourth and fifth files:
- the PCB image file because we are redefining it.
- the metadata file to point to the new PCB image file, to delete connectors.
Our new part class will share the first three, existing files with other part classes.
Finding files to reimplement
The process is:
- find the metadata file
- read the metadata file to find a reference to the PCB image file
Loosely speaking, there is one metadata file for each unique (part class, package) combination.
The metadata files are in a subdirectory of ~/Fritzing/parts. Here, they are in the “core” subdirectory.
The metadata files are often similar to the package names. Browse the directory to find a likely candidate. Here, the file is:
Confirming the metadata file
Open the metadata file using a text editor (it is XML.)
<property name="package"> <property name="family">
The value for family should be “Generic IC”. (More generally, the value should match the family name you see in the Fritzing Inspector window when you browse the part by icon, for the part class (template) you are reimplementing.)
The value for package should be “QFN-20-0.4MM”. (More generally, the value should match one of the package names you see in the “Package” pulldown menu in the Fritzing Inspector window.)
Finding the existing PCB image file to reimplement
Still with the metadata file open, find:
<pcbView> <layers image=
The next string is the name of the PCB image file, here “pcb/QFN-20-0.4MM_pcb.svg”.
The path prefix to the PCB image file usually differs slightly from the path to the metadata file. Here, it is “~/Fritzing/parts/svg/core”. The full path is:
Where “~” means the home directory in Linux, or where ever you installed Fritzing (since we are reimplementing files from the standard installation.)
Where to “Save as” reimplemented files
Put them in the directory for user specific Fritzing configuration. (You CAN put them in the Fritzing install directory, but they might be destroyed by an updated installation of Fritzing.)
On most Linux distributions, in:
~/.config/Fritzing/parts/user/ (for the metadata file) ~/.config/Fritzing/parts/svg/user/pcb/ (for the PCB image file)
(The directories might be empty unless you have already created or imported a part.)
Reimplementing the PCB image file
Open the file with an SVG editor such as Inkscape.
Modify it to suit (here, delete four pin rectangles and rearrange the rest.)
(It might be easier to edit the SVG file with a text editor to delete rectangles for pin/pads.)
You also might need to redefine the viewbox (details omitted.)
But the resulting drawing should match the industry standard for the QFN-16 footprint (or the manufacturer’s footprint drawing if non-standard.)
The dimensioning is important!
“Save As” the drawing (don’t overwrite the original!)
Reimplementing the metadata file
Open the file with a text editor.
Find the text we found to confirm the metadata file. Change them:
- Change the “package” property to a new, descriptive name, here “QFN-16”. (Leave the “family” property as “Generic IC”.)
- Change the reference to the PCB image file to refer to your reimplemented PCB image file.
- Everywhere, change the old package name “QFN-20-0.4MM” to the new package name “QFN-16”.
- Change the reference to the breadboard image file to ‘breadboard/generic_ic_dip_16_300mil_breadboard.svg’
- Change the reference to the schematic image file to ‘schematic/generic_ic_dip_16_schem.svg
Also delete four connectors, now extra. Find:
<connector id="connector16" type="male" name="17"> ....
And delete four “connector” tags worth of text. (See elsewhere for a discussion of what the text means.)
“Save As” the new metadata file (don’t overwrite the original!)
An adapted SMD part
The part we chose to reimplement, the QFN-20-0.4MM package, is actually an adapted generic IC. That means that the breadboard view shows an adaptor part which adapts an SMD chip to a DIP form factor. (You buy the adaptor, solder your SMD part to it, and plug the adaptor into the breadboard.) In other words, the specification of the QFN-20-0.4MM package includes a breadboard image SVG file that looks precisely like the adaptor part; it does not share a breadboard image with any other generic IC’s (yet.)
In the steps above, by changing the reference to the breadboard image file to ‘breadboard/generic_ic_dip_16_300mil_breadboard.svg’, we made the new QFN-16 package specification share its breadboard image with other generic IC’s (having 16 pins.) This saved us from reimplementing a breadboard image. The downside is that the the breadboard view does not show the adaptor part, it only shows an abstraction, the image shared with other generic IC’s of 16 pins. Again, in this example, we don’t intend to build a breadboard and don’t care that the breadboard does not look exactly as built. If you want to build a breadboard, you could still use the new QFN-16 package and just remember that you actually need an adaptor.
(As to why the QFN-20-0.4MM package refers to its own schematic image file, I can’t yet explain. To me it looks just like the schematic image for a generic IC of 20 pins, only rotated. Why not share?)
The next time you start Fritzing, you can drag a “Generic IC” it to say the breadboard view. In the Inspector window, pull down the “Package” menu and choose the package you reimplemented. In the breadboard view, you should see a DIP with 16 pins. In the PCB view, you should see the SMD footprint you reimplemented.
I hope to:
- actually walk through this, make corrections, and upload the part to the Fritzing community.
- discuss the “Mystery Part” and its relation to the “Generic IC” part
- create an advanced tutorial that creates a real QFN-16 package, which has 17 pins if you include the grounded heat sink pad!