Could anyone have a python script to export the relationship between net and test point

Hi all,

In our company’s requirement, we need to have at least one test point for each net, so I always have to check the relationship between them.

But currently there is no fast way to do it. I always have to export netlist first and then check the netlist line by line, if the schematcs have many nets, this work will cost me much time.

Could anyone tell me a way, or have a python script for me, to export a list to show the relationship between nets and testpoint.

Thanks

Hi,

Can you provide a Netlist file as example where you have such missing relationship, I can have a lock and write a script to automate search.

Hi Oli,

Thanks for your reply.

The attachment is a netlist example which is used to generate bom.
Example.xml (262.3 KB)

Add let’s turn to row/line 4599, it’s the net section, in this section you will see all the nets and the net related component:

And you will see that the net contains a lot of component, one of them shall be a test point.

I want to do is to figure out which net contains 1 ore more test point( the designator begins with TP), , and which net doesn’t contain any test point, and then add test point to the net which has no test point.

Thanks

Hi,

You don’t use netlist in Kicad format instead of xml ?
I’ve just made a quick small script that use a Kicad format netlist parser, but I can parse XML too if it’s usual for you to use this format.
netlist_tp

Oli

Hi,

All the format is OK for me.

I use xml because it’s generated automatically when I generate a bom.

I will upload kicad default netlist format file later.

Thanks

Example.net (261.1 KB)
This is the KiCAD default netlist format file.

The net section is in line/row 4103.

It seems to work …
Found two nets without test point and a bunch of ‘unconnected’ net.

netlist_tp2

Hi Oli,

Could you public your script?

Thanks

I’m finalizing the script, he will be able to parse kical netlist format and xml netlist format.
Are you at ease with python environnement or do you prefer an executable file ?
I can easily make a .exe application.

Oli

i think python script source code is prefered.

Because more people can modify it. Maybe in the future, somebody can modify it and publish it inthe pcm as a plugin named ‘Kicad test point manager’.

Thanks

Ok, give me some time I’m gona format the project to place it on my Github.

@xzf16 Here is the Github repo address : https://github.com/Peboli/kicad_netlist_tp_parser
Let me know if everything is OK for you with this.
In a first time, despite what I said earlier, the script only manage xml format netlist.
I’ve tried with a third party module to parse netlist in .net Kicad format but it’s rather slow compared to the XML format.

Oli

1 Like

Thank you very much.

BTW, I found that this thread is your first post, it’s my pleasure that you give your first post to me.

Btw this is something suitable to be pcbnew action plugin. It would be much easier to use if it were just a button in the toolbar instead of manually generating netlist file and then feeding it to a python script.

2 Likes

Yes indeed, you’re right.
But this was just to answer to a ponctual request, I’ve made something quick and simple.
I still haven’t yet had a look at the Kicad API, but will do soon in my spare time.

2 Likes

Hi Oli,

If you want to do it more in the future, we can discuss the entire requirement for it.

I think we can have a summary section first like this:

======Summary=======
Total connected nets:100
Connected Net with TestPoint:96
Connected Net without TestPoint:4
Unconnected Nets:10
Test point coverage:96%
======Summary=======

And then, we can have a list for nets and test points, like this:

======Connected nets without test point=======
Net_1
Net_2
Net_3
...
======1 test point connected nets=======
Net_11     TP101
Net_12     TP102
Net_13    TP103
...
======More than 1 test point connected nets=======
Net_21    TP201 TP301 TP302
Net_22    TP202 TP210
Net_23    TP203 TP211 TP212 TP213 TP214
...
======Unconnected nets=======
Unconnected_Net01
Unconnected_Net02
...

If we have done so, this plugin will be a very good plugin analysis test point for KiCAD schematics.

Of coure, this is just a requirement discussion, if you think it’s too complex to achieve or it will cost you much time, we can left it open and maybe somebody else will achieve it.

Thanks

1 Like

Hi Floyd,

Okay, I’ll look into it.

Oli

@xzf16

I’ve pushed a new version (1.0.1) with your last requirements.
Let me know if this suit your needs.

Oli

Hi Oli,

Yes, this is the thing just want I want.

Thank you very much.

And next step, I think we should consider how to integrate it into KiCAD.

In KiCAD schematic editor, I haven’t found any external plugin menu, maybe it haven’t support external plugin. So, if we want to integrate this script into KiCAD, I think using BOM generate function is a good idea.

The main idea I have considered is to modify this script as a bom generation script, when we press the generate button, it shall do the things like this:
1.Using KiCAD internal xml generation command to generate xml file(just like the other BOM generation script)
2.Using the script we have done to read the xml file to get the test point list
3.export the list to a text file.

If you have another idea, please let me know.

Hi Floyd,

Yes, this is the next step, but for this I need to dive into Kicad scripting and understand how it works.
I don’t promise I’ll do that in the next days, but I’ll have a look at it soon.

Oli