Hi!
I’m trying to figure out some details and limitations of the new schematic format.
Context: I’m implementing the variants mechanism of KiBot for KiCad v6, and as the Python bindings for EEschema won’t be in v6 I have to understand the file format.
My main doubts are about what happends when a project uses a sheet more than once.
From what I see the only thing that I can change is the components annotation, all other details are shared, which seems confusing. Let me explain:
The example I used
In my example we have a main sheet called pp.kicad_sch
that contains two instances of a sub-sheet called subsheet.kicad_sch
. The sub-sheet contains just a resistor.
The first instance is:
(sheet (at 101.6 50.8) (size 25.4 12.7) (fields_autoplaced)
(stroke (width 0.1524) (type solid) (color 0 0 0 0))
(fill (color 0 0 0 0.0000))
(uuid f2044410-03ac-4994-9652-9e5f480320f0)
(property "Sheet name" "Sheet_1" (id 0) (at 101.6 50.0884 0)
(effects (font (size 1.27 1.27)) (justify left bottom))
)
(property "Sheet file" "subsheet.kicad_sch" (id 1) (at 101.6 64.0846 0)
(effects (font (size 1.27 1.27)) (justify left top))
)
)
With UUID f2044410-03ac-4994-9652-9e5f480320f0
The second instance of the sub-sheet looks like this:
(sheet (at 101.6 76.2) (size 25.4 12.7) (fields_autoplaced)
(stroke (width 0.1524) (type solid) (color 0 0 0 0))
(fill (color 0 0 0 0.0000))
(uuid 6bfab902-8625-4b2e-8c24-5092d47d0de8)
(property "Sheet name" "Sheet_2" (id 0) (at 101.6 75.4884 0)
(effects (font (size 1.27 1.27)) (justify left bottom))
)
(property "Sheet file" "subsheet.kicad_sch" (id 1) (at 101.6 89.4846 0)
(effects (font (size 1.27 1.27)) (justify left top))
)
)
Its UUID is 6bfab902-8625-4b2e-8c24-5092d47d0de8
KiCad 6 improves the sheet numbering by defining the numbers in the main sheet like this:
(sheet_instances
(path "/" (page "1"))
(path "/f2044410-03ac-4994-9652-9e5f480320f0" (page "2"))
(path "/6bfab902-8625-4b2e-8c24-5092d47d0de8" (page "3"))
)
This is clear and solves the old problem about page numbers. The first instance is page 2 and the second is page 3. Good.
The symbol instances are declared like this:
(symbol_instances
(path "/f2044410-03ac-4994-9652-9e5f480320f0/c3f25bab-d21c-43b9-bb4f-57d9b5e2645a"
(reference "R1") (unit 1) (value "220") (footprint "Resistor_SMD:R_0603_1608Metric")
)
(path "/6bfab902-8625-4b2e-8c24-5092d47d0de8/c3f25bab-d21c-43b9-bb4f-57d9b5e2645a"
(reference "R2") (unit 1) (value "220") (footprint "Resistor_SMD:R_0603_1608Metric")
)
)
Ok, the UUID c3f25bab-d21c-43b9-bb4f-57d9b5e2645a
is the resistor symbol that I have in sub-sheet.kicad_sch
. Looking there I have:
(symbol (lib_id "Device:R") (at 116.84 55.88 0)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid c3f25bab-d21c-43b9-bb4f-57d9b5e2645a)
(property "Reference" "R1" (id 0) (at 118.618 54.9715 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Value" "220" (id 1) (at 118.618 57.7466 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Footprint" "Resistor_SMD:R_0603_1608Metric" (id 2) (at 115.062 55.88 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 116.84 55.88 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "mnf#" "4567" (id 4) (at 116.84 55.88 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid d7abc30b-0879-4741-86ef-a26cf4381a4c))
(pin "2" (uuid c7f74e02-22a2-44c3-ba93-2cb4738b7c33))
)
This is an instance of the library symbol Device:R
(also included in subsheet.kicad_sch
)
The confusing part
Looking at the symbol instance I can see the following attributes:
- Reference
- Value
- Footprint
- Unit
First doubt
I can’t find a mechanism in the UI to change Value
and/or Footprint
for one instance without affecting the other. Only the Reference
can be modified.
This looks like a severe limitation in the UI, or a waste in the file format. Can somebody explain me this?
Second doubt
The Reference
, Value
and Footprint
are in fact properties. Why are they handled in such a different way in the instance? Isn’t much more generic to just add property
attributes to symbol_instances.path
? In this way we could change other details. If Value
and/or Footprint
are part of the instance (or will be in the future) then other properties will need to be there, starting with the Datasheet
and any user field that describes the manufacturer part number.
Third doubt
Having the Unit
as part of the instance looks quite dangerous. Different units could have very different representation and/or pin-out. I don’t see we can change this attribute for each instance.
On the other side: why things like in_bom
and on_board
aren’t part of the instance? This looks quite plausible.
I’m not claiming the format is wrongly designed, just looking to remove my doubts.