Kicad/file formats

From Wikibooks, open books for an open world
Jump to: navigation, search

file formats[edit]

Kicad creates and uses files of several different formats.

  • Files that end in ".sch" are schematics.
  • Files that end in ".lib" are schematic part library files.
  • Files that end in ".cache.lib" are schematic part library files, too. But the parts are only a cache for parts used in the current project the file is named for.
  • Files that end in ".pro" are project files
  • Files that end in ".dcm" add documentation to parts in the library file with the same name. The ".dcm" file contains the description, keywords and docfilename whereas the ".lib" file contains information about how the part is drawn, the pins etcetera.
  • Files that end in ".bak" ... are old backup files ... (Don't archive).
  • Files that end in ".bck" ... are old backup files ... (Don't archive).
  • Files that end in ".brd" are PCB layout files.


  • Files that end in ".000" ...
  • Files that end in ".cmp" ... are footprint information files that are modified by the PCBNew program
  • Files that end in ".erc" are output from the schematic electronic rules check (ERC).
  • Files that end in ".gcd" ...
  • Files that end in ".lst" are netlist output from the schematic. (Don't archive).
  • Files that end in ".net" are netlist output from the schematic. (Don't archive).
  • Files that end in ".mod" are module libraries (a KiCad "module" is called a "footprint" or a "decal" in other CAD software)
  • Files that end in ".mdc" ...
  • Files that end in ".dsn" are regenerated from the ".kicad_pcb" file every time you hit the "autoroute" button and then hit the "Export a Specctra Design (*.dsn) file". (Don't archive).
  • Files that end in ".ses" are session files output from the autorouter. (Don't archive).

Schematic Files Format[edit]

Units[edit]

Sizes and coordinates are given in whole numbers of ten-thousandths of an inch (1/10000 inch). Coordinates may be negative by prefixing a hyphen (-) to the numeric value.

Angles are given in whole numbers of tenths of degrees (1/10°), specifying a rotation counter-clockwise.

Examples[edit]

Value Distance Angle
1 0.0001 inches 0.1° counter-clockwise
200 0.0200 inches 20.0° counter-clockwise
3599 0.3599 inches 359.9° counter-clockwise
-1234 -0.1234 inches invalid (negative value)
36000 3.6000 inches invalid (over 359.9°)

Header[edit]

EESchema Schematic File Version 1

LIBS: libraries list (not used, for information only).

EELAYER nn mm (nn mm not used, reserved)

EELAYER END

$Descr Sheet size dimx dimy (sheet size = A4..A0 ou A..E)

Title block description (Texts of the title block)

$EndDescr

EESchema Schematic Spins Version 1
LIBS:brooktre, cypress, ttl, power, linear, memory, xilinx, idiot, aaci, INTEL, special, device, dsp
EELAYER 20 0
EELAYER END
$Descr A3 16535 11700
Sheet 1 4
""
Date “28 DEC 1996”
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr

A later example:

$Descr size w h (size = A4..A0, A..E, or User. w = width(mils), h = height(mils), w and h are ignored unless size = User)

Sheet m n (m is the current sheet number, n is the total number of sheets. It appears that a sheet will not appear in the project list unless it is m = 1)

EESchema Schematic File Version 2  date 4/15/2011 3:59:54 PM
LIBS:mylib
LIBS:transistors
LIBS:someotherlib
EELAYER 25 0
EELAYER END
$Descr A4 11700 8267
Sheet 1 1
Title "DC Supply"
Date "15 apr 2011"
Rev "1"
Comp "Circuits R Us"
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr

Description of a component[edit]

Format:

$Comp

L name reference

U N mm time_stamp

P posx posy

List of fields:

F field_numbertextorientation posX posY size Flags (see below)

1 posx posy (redundant: not used)

A B C D ( orientation matrix with A, B, C, D = - 1, 0 or 1)

$EndComp

Description of the fields:

F n “text” orientation posX posY dimension flags

with n = field number (reference field = 0, value field = 1, N = 0..11)

orientation = H (horizontal) or V (vertical).

Example:

$Comp
L CONN_3 JP3
U 1 1 329879E1
P 1200 2000
F 0 “JP3” H 1250 2200 60 0000
F 1 “CONN_3” V 1350 2000 50 0000
1 1200 2000
- 1 0 0 - 1 
$EndComp

Description of a NoConnect symbol[edit]

Format:

NoConn ~ posx posy

Example:

NoConn ~ 13400 5500

Description of a hierarchical sheet symbol[edit]

Format:

$Sheet

S posx posy dimx dimy

List of Sheet Labels

$EndSheet

Format of Sheet Labels:

Fn “text” forms side posx posy dimension

With:

n = sequence number (0..x).

n = 0: name of the corresponding schematic file.

n = 1: name of the sheet of hierarchy.

form = I (input) O (output)

side = R (right) or L (left).

Example:

$Sheet
S 1800 1600 1500 1500
F0 “PROGALIM.SCH” 60
F1 “PROGALIM.SCH” 60
F2 “CLK” O R 3300 1800 60 
F3 “/RESET” O R 3300 2000 60 
F4 “VPWR” O R 3300 2700 60 
F5 “/HALT” O R 3300 2100 60 
F6 “TRANSF1” I L 1800 1900 60 
F7 “TRANSF2” I L 1800 2000 60 
F8 “3.84MH” O R 3300 2200 60 
$EndSheet

Description of a text note[edit]

Format:

Text Notes posx posy orientation dimension ~ Text

Example:

Text Notes 2100 3250 1 60 ~
TOTO

Description of a Global Label[edit]

Format:

Text GLabel posx posy orientation dimension shape

Text

Example:

Text GLabel 3100 2500 2 60 UnSpc
TITI
Text GLabel 3150 2700 1 60 3State
3STATES
Text GLabel 2750 2800 0 60 UnSpc
BIDI
Text GLabel 2750 2650 0 60 Output
GLABELOUT
Text GLabel 2750 2400 0 60 Input
RESET

Description of a Hierarchical label[edit]

Format:

Text HLabel posx posy orientation dimension shape

Text

Example:

Text HLabel 3400 2000 0 60 Input
/RESET

Description of a label[edit]

Format:

Text Label posx posy orientation dimension ~

Text

Example:

Text Label 3400 2000 0 60 ~
/RESET

Description of a junction[edit]

Format:

Connection ~ posx posy

Example:

Connection ~ 13300 6500

Description of a wire segment (Wire)[edit]

Format:

Wire Wire Line

startx starty endx endy

Example:

Wire Wire Line
3300 1800 3900 1800

Description of a Bus segment[edit]

Format:

Wire Bus Line

startx starty endx endy

Example:

Wire Bus Line
3900 5300 4500 5300

Description of a dotted line segment[edit]

Format:

Wire Notes Line

startx starty endx endy

Example:

Wire Notes Line 
2850 3350 2850 3050

Description of a bus entry[edit]

Format:

For an entry wire/bus :

Wire Wire Bus

startx starty endx endy


For an entry bus/bus :

Wire Bus Bus

startx starty endx endy


Example:

Wire/Bus:

Entry Wire Bus
4100 2300 4200 2400

Bus/Bus:

Entry Bus Bus
4400 2600 4500 2700

Schematic Libraries Files Format[edit]

Units[edit]

Sizes and coordinates are given in mils (1/1000 inch)

Headings[edit]

Format:

EESchema-LIBRARY Version 2.0 24/1/1997-18:9:6
description of the components
# End Library

Description of a component[edit]

The format is as follows :

DEF name reference unused text_offset draw_pinnumber draw_pinname unit_count units_locked option_flag

F0 reference posx posy text_size text_orient visibility htext_justify vtext_justify

F1 name posx posy text_size text_orient visibility htext_justify vtext_justify

F2 ???

F3 ???

$FPLIST

footprint list

$ENDFPLIST

ALIAS name1 name2 name3 fields list

DRAW

list graphic elements and pins

ENDDRAW

ENDDEF

Example:

DEF BNC P 0 40 Y NR 1 L NR
F0 “P” 10.120 60 H V L C
F1 “BNC” 110 - 60 40 V V L C
DRAW
C 0 0 70 0 1 0
C 0 0 20 0 1 0
X Ext. 2 0 - 200 130 U 40 40 1 1 P
X In 1 - 150 0.130 R 40 40 1 1 P
ENDDRAW
ENDDEF


Description of DEF[edit]

This is the component definition line.

Format:

DEF name reference unused text_offset draw_pinnumber draw_pinname unit_count units_locked option_flag

  • name = component name in library (74LS02 ...)
  • reference = Reference ( U, R, IC .., which become U3, U8, R1, R45, IC4...)
  • unused = 0 (reserved)
  • text_offset = offset for pin name position
  • draw_pinnumber = Y (display pin number) or N (do not display pin number).
  • draw_pinname = Y (display pin name) or N (do not display pin name).
  • unit_count = Number of part ( or section) in a component package. Limit is 26 (shown as chars form A to Z).
  • units_locked = = L (units are not identical and cannot be swapped) or F (units are identical and therefore can be swapped) (Used only if unit_count > 1)
  • option_flag = N (normal) or P (component type "power")

Description of F0 and F1[edit]

F0 is the component reference line. F1 is the component name line.

Format:

F0 reference posx posy text_size text_orient visibile htext_justify vtext_justify

F1 name posx posy text_size text_orient visibility htext_justify vtext_justify

  • reference = Reference ( U, R, IC .., which become U3, U8, R1, R45, IC4...)
  • name = component name in library (74LS02 ...)
  • posx, posy = position of the text label
  • text_size = Size of the displayed text
  • text_orient = Displayed text orientation (V=Vertical, H=Horizontal(default))
  • visible = Is label displayed (I=Invisible, V=Visible(default))
  • htext_justify = Horizontal text justify (L=Left, R=Right, C=Centre(default))
  • vtext_justify = Vertical text justify (T=Top, B=Bottom, C=Centre(default))

Description of $FPLIST[edit]

This line exists if one or more footprints are specified. Footprint names can have wildcards.

Description of ALIAS[edit]

This line exists only if the component has alias names.

Format:

ALIAS name1 name2 name3…

Description of DRAW[edit]

Lists graphic elements and pins. Each line defines a single element. The line starts with a single character indicating the type e.g. P indicates a polygon. The following items are commonly used in some of the elements:

  • posx, posy = Position of the graphic element
  • unit = unit no. in case of multiple units
  • convert = In case of variations in shape for units, each variation has a number. 0 indicates no variations. For example, an inverter may have two variations - one with the bubble on the input and one on the output.
  • thickness = line thickness
  • fill = fill colour (F=filled with foreground colour, f=filled with background colour, N=Not filled(default))

A record (Arc)[edit]

A posx posy radius start_angle end_angle unit convert thickness fill startx starty endx endy

  • posx, posy = centre of the circle part of which is the arc
  • radius = radius of the lost arc
  • start_angle = start angle of the arc in tenths of degrees
  • end_angle = end angle of the arc in tenths of degrees
  • startx, starty = coordiantes of the start of the arc
  • endx, endy = coordinates of the end of the arc

C record (Circle)[edit]

C posx posy radius unit convert thickness fill

  • posx, posy = centre of the circle
  • radius = radius of the circle

P record (Polyline)[edit]

The polyline has a series of points. It need not described a closed shape i.e. a polygon. To do this make the first pair the same as the last pair.

P point_count unit convert thickness (posx posy)* fill

  • point_count = no. of coordinate pairs. posx and posy are repaeated these many times.

S record (Rectangle)[edit]

S startx starty endx endy unit convert thickness fill

  • startx, starty = Starting corner of the rectangle
  • endx, endy = End corner of the rectangle

T record (Text)[edit]

T direction posx posy text_size text_type unit convert text text_italic text_hjustify text_vjustify

  • direction = Direction of text(0=Horizintal, 900=Vertical(default))
  • text_size = Size of the text
  • text_type = ???
  • text = Text to be displayed. All ~ characters are replaced with spaces.
  • text_italic = "Italic" or "Normal"
  • text_bold = 0 to normal 1 to bold
  • text_hjustify = C, L or R
  • text_vjustify = C, B or T

X record (Pin)[edit]

X name num posx posy length direction name_text_size num_text_size unit convert electrical_type pin_type

  • name = name displayed on the pin
  • num = pin no. displayed on the pin
  • posx = Position X same units as the length
  • posy = Position Y same units as the length
  • length = length of pin
  • direction = R for Right, L for left, U for Up, D for Down
  • name_text_size = Text size for the pin name
  • num_text_size = Text size for the pin number
  • electrical_type = Elec. Type of pin (I=Input, O=Output, B=Bidi, T=tristate,P=Passive, U=Unspecified, W=Power In, w=Power Out, C=Open Collector, E=Open Emitter, N=Not Connected)
  • pin_type = Type of pin or "Graphic Style" (N=Not Visible, I=Invert (hollow circle), C=Clock, IC=Inverted Clock, L=Low In (IEEE), CL=Clock Low, V=Low Out (IEEE), F=Falling Edge, NX=Non Logic). Optional (when not specified uses "Line" graphic style).

Board File Format[edit]

General Informations[edit]

Layer numbering[edit]

0. Back - Solder

1. Inner _back

2. Inner_frent

3. Inner

5. Inner

6. Inner

7. Inner

8. Inner

9. Inner

10. Inner

11. Inner

12. Inner

13. Inner

14. Inner

15. Front - Component

16. Adhestive/glue Back

17. Adhestive/glue Front

18. Solder Paste Back

19. Solder Paste Front

20. SilkScreen Back

21. SilkScreen Front

22. SolderMask Back

23. SolderMask Front

24. Drawings

25. Comments

26. ECO1

27. ECO2

28. Edge Cuts

First line of description[edit]

$GENERAL[edit]

$SHEETDESCR[edit]

$SETUP block[edit]

$EQUIPOT[edit]

$MODULE[edit]

General description[edit]

Field Description[edit]

Drawings[edit]

All physical units are in mils (1/1000th inch) unless otherwise noted. The default layer number for graphic segments is 21, which corresponds to SilkS_Front.

DS x1 y1 x2 y2 width layer

Draws a line segment from (x1, y1) to (x2, y2) with width width on the layer number specified.

DC x1 y1 x2 y2 width layer

Draws a circle whose center is (x1, y1), and whose radius is specified by the segment (x1, y1) - (x2, y2) with line width width on the layer number specified.

DA x1 y1 x2 y2 angle width layer

Draws a circular arc. Center is at (x1, y1). The arc's starting point is (x2, y2). The length of the arc sweeps clockwise (for positive angles) from here by the number of degrees specified by (angle / 10).

Pad Descriptions[edit]

$SHAPE3D[edit]

$PAD[edit]

A pad is usually a copper area for electrical connection to an electrical component. It has an optional hole for through-hole components, or may be defined as an area on a single copper layer for surface-mount components. It can also be used as a thermal connection for heat distribution, or as a hole for mounting or other uses.

Sh "padNum" shape xSize ySize yBaseIncrease xBaseIncrease angle

Defines the pad's dominant shape. padNum defines the pad number. The shape of the pad (shape) can be circular (C), ovate (O), rectangular (R), or trapezoidal (T) with its size specified by xSize and ySize. (Note that for circular pad shapes xSize and ySize must be equal.) The pad is rotated at an angle of angle. For trapezoidal shapes, yBaseIncrease specifies how much taller the pad's left edge is from its right, and xBaseIncrease specifies how much wider the pad's bottom is from its top; xSize and ySize then specify the size of the pad at its center and the trapezoidal effect increases one edge and decreases the other.

Dr dia xOffset yOffset

Defines the pad's drilled hole offset from the pad's position by (xOffset,yOffset) with a diameter of dia. To specify no hole, specify dia as 0. Note that the drilled hole can be located offset from the center of the pad's shape (Sh) although pcbnew requires the drilled hole be located on the pad itself.

At type flag layers

Defines the pad's attributes. The pad type is specified by type and can be STD for a standard pad with a hole, SMD for a surface-mount pad, CONN for a connector, or HOLE for a hole. flag is N (unknown function). layers specifies the active layers as a 32-bit hexadecimal number with leading zeroes such that active layers are indicated by a 1 bit and inactive by 0.

Ne unknown "netName"

Defines the net name as netName. There are other options specified by the unknown flag: it appears that unknown is 0 in a module library and has a numeric value other than 0 when placed and connected in a board file.

Po x y

Defines the position of the pad as (x,y). This is the point that traces must terminate for pcbnew to confirm connection to a pad.

Graphic items[edit]

$DRAWSEGMENT[edit]

Line[edit]

Circle[edit]

Arc[edit]

$TEXTPCB[edit]

Te "text"

Defines text as the string to render.

nl "newLineText"

If present after Te, renders newLineText on the line after text. This can be repeated multiple times for multiple new lines. It is also common to have no nl entries if text is to fit on one line only.

Po x y height width thickness angle

Defines the position of the text as (x,y) with a height of height, a width of width, a thickness of thickness, and an angle of angle. Although the user interface only supports angles of 0, 900, 1800, and 2700, other angles can be entered in the board file.

De layerNum mirror 0 style

Defines the options for the text. The text is rendered on layer layerNum. If mirror is 1, the text is rendered normal; if it is 0 it is mirrored. Setting style to Normal renders the text normal and Italic renders the text italic.

$MIRE[edit]

$COTATION[edit]

Track, vias and Zone section[edit]

$TRACK[edit]

Comes in Po, De pairs. Example:

Po 0 38900 95200 39500 95800 80 -1
De 0 0 1 0 80000


Po ? x1 y1 x2 y2 width ?

De layer ? net ? flags

flags bitfield: Unknown length (probably 32 bit), printed as hex with leading 0's truncated.
Binary: ???? ???? al?? ????  ???? ????  ???? ????
a = Autorouted Flag
l = (Segment?) Locked Flag

 

Example: (open a new .brd file, add a track, save it - and then insert/replace the changes below in a text editor; no nets are assigned)


(FIXME: add an example of "(kicad_pcb (version 3)".)

PCBNEW-BOARD Version 1 date 2012-03-18T07:15:54 CET
# Created by Pcbnew(2010-00-09 BZR 23xx)-stable
$GENERAL
LayerCount 6
Ly 1FFF801F
EnabledLayers 1FFF801F
....
$TRACK
# gray track (Inner4 - jumper layer):
Po 0 32000 25250 32000 23250 80 -1
De 3 0 0 0 0
#
# red track (front layer):
Po 0 24250 10750 24250 25250 80 -1
De 15 0 0 0 0
#
# green track (back layer):
Po 0 24250 25250 30000 25250 80 -1
De 0 0 0 0 0
#
# via between red and green track:
Po 3 24250 25250 24250 25250 350 -1
De 15 1 0 0 0
#
$EndTRACK
...

$ZONE[edit]

$CZONE_OUTLINE[edit]

$EndBOARD[edit]

Historical notes[edit]

As of 2013, the PCBnew application creates ".kicad_pcb" files that begin with "(kicad_pcb (version 3)". All distances are in millimeters. If the distance is not an integer number of millimeters, the distance will be indicated with a decimal point. (For example, the vast majority of PCBs have a board thickness of 1/16 inch ~= 1.6 mm,[1] so Version3 board files often have a line

   (thickness 1.6002)

.) (The internal PCBnew unit of length is now[2] integer multiples of 1 nanometer, which enables exact representation of metric units and imperial units down to 1/100 mil = 1/100,000 inch.)[3]

Early versions of the PCBnew application create ".brd" files that begin with "PCBNEW-BOARD Version 2". Such files typically have a line

   Units mm

indicating that all distances are in millimeters. If the distance is not an integer number of millimeters, the distance will be indicated with a decimal point. (For example, the vast majority of PCBs have a board thickness of 1/16 inch ~= 1.6 mm,[1] so Version 2 board files often have a line

   BoardThickness 1.6002

.)


The earliest (?) versions of the PCBnew application created ".brd" files that begin with "PCBNEW-BOARD Version 1". Such files have all distances in integer multiples of some tiny reference unit. Typically such files have a line

   InternalUnit 0.000100 INCH

indicating that all distances are in integer multiples of 1/10,000 of an inch, which was once the internal PCBnew unit of length.[4] (For example, the vast majority of PCBs have a board thickness of 1/16 inch ~= 0.063 inch,[1] so Version 1 board files often have a line

   BoardThickness 630

.)

  1. a b c Practical Electronics/PCB Layout#Board Thickness and Layers
  2. Done. KiCad internal units in nanometers. "KiCad Development".
  3. "KiCad: Internal unit system".
  4. "KiCad: Convert Internal CPB Units to 1nm".