Error in sch file format

Bug #1577034 reported by Petar
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Expired
Undecided
Unassigned

Bug Description

I am making python scrip for cloning the part of the layout while making netlist in sync with the already annotated schematic.

I made couple of copies of hierarchical sheets using command "File/append schematic sheet".

Script that I am talking about reads the hierarchical sheets .sch files in order to determine which footprint in layout to rename.

The script actually works and I am able to make copy of layout but I notice that there are couple of capacitors and resistor that are not copied, so I investigate what is going on.... so I printed every component that script deals with and found that there are components with C? or R? names.
The script threat the schematic files like read only files, so they are not altered by it.

At the schematic files .sch there are couple of components with the "?" in its name.

Like this:

$Comp
L C C?
U 1 1 56F649D8
P 16050 7400
AR Path="/56FBE4F4/56F649D8" Ref="C?" Part="1"
AR Path="/56FBE4F2/56F649D8" Ref="C?" Part="1"
AR Path="/56FBE4F0/56F649D8" Ref="C?" Part="1"
AR Path="/55C09CB6/56F649D8" Ref="C56" Part="1"
F 0 "C56" H 16075 7500 50 0000 L CNN
F 1 "10nF" H 16075 7300 50 0000 L CNN
F 2 "C_0603_H" H 16088 7250 30 0000 C CNN
F 3 "" H 16050 7400 60 0000 C CNN
 1 16050 7400
 1 0 0 -1
$EndComp

So the script read this component like C? and can't find its match at some other hierarchical sheets in order to clone the circuit.

If I understand KiCAD "file formats" PDF the component name should be located at the next line from "$Comp" line.

When you look at the schematic that component has C56 name-designator and also at the pcbnew that component is C56.

Maybe KiCAD using this line "F 0 "C56" H 16075 7500 50 0000 L CNN" instead of this line: "L C C?" ?

Thanks,
Petar

Revision history for this message
Novak Tamas (novak-7) wrote :

Your point is not really clear for me:
is there a problem with initial sch file, or with your running script?

In your first sentence you mention " already annotated schematic". If original (before running script) schematic contains "C?" references, it is not fully annotated.
If you see "C?" after running script, then it's fine, as original "C56" should be copied into "C?" to avoid duplicate references and must be annotated later. Or your script makes automatic annotation of new distinc references?

So please put this in perspective.

Changed in kicad:
status: New → Incomplete
Revision history for this message
Petar (dpetar) wrote :

The problem is with initial sch file.

I first made the schematic.
The portions of schematic that I wanted to be cloned I made by using command "File/Append schematic sheet".
The schematic is than annotated it by using KiCAD annotate command and later I made DRC and export netlist to pcbnew.

The schematic, when you see it by means of schematic editor and by human eyes doesn't contain any component that has "?" in the name (component name, like C56). Export to pcbnew works great and there is no component in pcbnew with "?" in their names.

But when you open .sch file by means of text editor you will find components that has ? in the name like: C?.

I mean in the name like in this lines:
$Comp
L C C?

The script only reads the schematic files in order to determine the components names. It doesn't change single character in the .sch file. It only makes changes in the PCB file in order to maintain the sync between the schematic netlist and the layout. Also it doesn't change netlist.

Thanks,
Petar

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

There is no problem with the schematic file. You components in the sheet paths:

AR Path="/56FBE4F4/56F649D8" Ref="C?" Part="1"
AR Path="/56FBE4F2/56F649D8" Ref="C?" Part="1"
AR Path="/56FBE4F0/56F649D8" Ref="C?" Part="1"

have not been annotated. Open the annotate dialog and reannotate the entire schematic and then save. Make sure you have the annotate entire schematic option selected. These component paths should now have valid reference designators in the schematic file. If that doesn't work, please attache a copy of your schematic files so I can duplicate the problem.

Revision history for this message
Petar (dpetar) wrote :

Hi,

I already resolve the problem manually (by editing .sch files), so for my current project I don't have a problem. But the bug still remains (for all KiCAD user, not just for me).

Please notice that I don't want to use option to reset existing annotation (it is not the option that anyone wants to use in the middle of the place and route work....)

So, when I use this options (for annotation): "Use the entire schematic", "Keep existing annotation", "Sort component by X position", "Use first free number in schematic" and "Always ask for confirmation"

and when I click to "Annotate" button and than to OK button to confirm annotation and than to save...... and so on.........

Please notice when you open the "Input_0.sch" that C56 still looks like this:

$Comp
L C C?
U 1 1 56F649D8
P 2700 5600
AR Path="/56FBE4F4/56F649D8" Ref="C?" Part="1"
AR Path="/56FBE4F2/56F649D8" Ref="C?" Part="1"
AR Path="/56FBE4F0/56F649D8" Ref="C?" Part="1"
AR Path="/55C09CB6/56F649D8" Ref="C56" Part="1"
F 0 "C56" H 2725 5700 50 0000 L CNN
F 1 "10nF" H 2725 5500 50 0000 L CNN
F 2 "C_0603_H" H 2738 5450 30 0000 C CNN
F 3 "" H 2700 5600 60 0000 C CNN
 1 2700 5600
 1 0 0 -1
$EndComp

I am sending you my files (actually I have heavily trimed the project and only about 1% of the original project is present at the files that I am sending to you, but the project behavioural is still the same).

Thanks,
Petar

Revision history for this message
Wayne Stambaugh (stambaughw) wrote : Re: [Bug 1577034] Re: Error in sch file format

Did you originally create your schematic as a complex hierarchy with
your additional channels (sheets Input_1 - Input_3) inside the Input_0
sheet? That's what it looks like to me. If that's the case then maybe
Eeschema left the previously defined sheet paths in the Input_0.sch.
@JP, can you explain why there are sheet paths in the Input_0.sch file?

On 5/1/2016 11:59 AM, Petar wrote:
> Hi,
>
> I already resolve the problem manually (by editing .sch files), so for
> my current project I don't have a problem. But the bug still remains
> (for all KiCAD user, not just for me).
>
> Please notice that I don't want to use option to reset existing
> annotation (it is not the option that anyone wants to use in the middle
> of the place and route work....)
>
> So, when I use this options (for annotation): "Use the entire
> schematic", "Keep existing annotation", "Sort component by X position",
> "Use first free number in schematic" and "Always ask for confirmation"
>
> and when I click to "Annotate" button and than to OK button to confirm
> annotation and than to save...... and so on.........
>
> Please notice when you open the "Input_0.sch" that C56 still looks like
> this:
>
> $Comp
> L C C?
> U 1 1 56F649D8
> P 2700 5600
> AR Path="/56FBE4F4/56F649D8" Ref="C?" Part="1"
> AR Path="/56FBE4F2/56F649D8" Ref="C?" Part="1"
> AR Path="/56FBE4F0/56F649D8" Ref="C?" Part="1"
> AR Path="/55C09CB6/56F649D8" Ref="C56" Part="1"
> F 0 "C56" H 2725 5700 50 0000 L CNN
> F 1 "10nF" H 2725 5500 50 0000 L CNN
> F 2 "C_0603_H" H 2738 5450 30 0000 C CNN
> F 3 "" H 2700 5600 60 0000 C CNN
> 1 2700 5600
> 1 0 0 -1
> $EndComp
>
>
> I am sending you my files (actually I have heavily trimed the project
> and only about 1% of the original project is present at the files that I
> am sending to you, but the project behavioural is still the same).
>
> Thanks,
> Petar
>
> ** Attachment added: "project files"
> https://bugs.launchpad.net/kicad/+bug/1577034/+attachment/4652841/+files/project.zip
>

Revision history for this message
jean-pierre charras (jp-charras) wrote :

Yes, I am also thinking the schematic was created as a complex hierarchy , or the imported schematic comes from a complex hierarchy.

The only one strange thing, if the schematic was created as a complex hierarchy, is the fact the timestamps do not match all sheets timestamps (unless sheets are deleted and recreated). Only one matches.

There is nothing wrong in .sch files.
Just the trace of importation or the initial complex hierarchy, because the annotation was never cleared.

Any python script has to manage the Alternate References, otherwise it will *never* able to handle complex hierarchies, therefore it is potentially broken.

Revision history for this message
Petar (dpetar) wrote :

Hi all,

At my original project I have only one top sheet and in that top sheet I have all other sheets (lot of sheets I have removed because I don't want for everyone to see my project, maybe the project will become open source, but at the moment it is private). That is the reason why I removed lot of sheets from the top sheet.

I don't have any other hierarchy inside the others sheets.

So originally Input_0 to Input_3 sheets are all in the top sheet. I am not aware if there is some sheet path in the Input_0.sch file (I didn't wanted to make any other hierarchical sheet inside the Input_0.sch).

Have you tried to open my project and to annotate it? Do you experience the same tool behavioural like me?

As I desperately wanted cloning feature I made the script using python (actually I don't know python, but because I know whole bunch of languages like C++, VHDL, velrilog.... I decided to look at the python syntax and do some "code")

The script code will become open source. Actually it could become the part of the KiCAD, that would be much better.

I have already tried to make changes to your KiCAD code... with different results...

The script works like this:

I manually "duplicate" the circuit and place it at the positive coordinates at the PCB sheet (all other components are place so that their coordinate are negative). Also I erase the components that are to be cloned in PCB. So now we have two copies of the same circuit with the same designators.

The script searches the PCB files for components that has both X and Y as positive numbers and than store their designators.

Than the script searches two schematic files (that are to be "cloned") in order to determine what are the "same" components at the different hierarchical sheets (it does it simple by comparison of the X,Y positions at the sheet and because I made the sheets by coping all the same components has the same X,Y coordinates at the schematic sheet.

When script knows what are the components designators it just rename the components that I manually "duplicated" and the job is done.

Thanks,
Petar

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for KiCad because there has been no activity for 60 days.]

Changed in kicad:
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.