Improvement ide

Hello!
Something I find really hard to use is that kind of symbol. It makes the schematic basically unreadable.
The chips are so huge that it makes it very difficult to search in zillons of pins the one that seems to correspond to what you are planning.

I’m a ST micro user, and they have an interesting idea in their code generator. You can select among many functions for each pin the function you want to use. See below. So using a similar method, it would be possible to select the function to be used and leave only that one. The chips would be smaller and the readability improve. In order to find easily what you want to use, a search box could suggest pins. Example, you enter TX, and the schematic would highlight all the pins having a label “TX”.

Choosing

Chosen

Version 6 will bring the option to have alternative functions for pins. Until then i suggest you use the approach of the official lib and have only the pin identifier (the main name for example PB0) in the symbol.

Where does the schematic symbol with all the long text come from?
Is it from the default KiCad libraries, or from another source? It looks like it’s completely unusable,

The texts for the pins are easily editable in the Symbol Editor. You can get a schematic symbol into the Symbol Editor by hovering over it and pressing [Ctrl + e]

Especially if it’s a symbol from KiCad’s default libraries (which are read-only for mortal users), it is a bit more involved, as you will also have to do some library management.

Currently most KiCad documentation is a bit out of date. The most current info is in the FAQ section of this forum, for library management, start reading at:
https://forum.kicad.info/search?q=library%20category%3A19

Hello!

Where does the schematic symbol with all the long text come from?

Sorry, I don’t remember where I got them. It happened once when I couldn’t find in the default lib the chip I was using. So I downloaded a whole bunch of symbols from the net, but anyway I don’t use them anymore because the pins are not in the same order as on the physical layout and it always results in circuits with complicated wiring (example, first pin of the SPI port goes out from one side, second pin from the opposite side and third pin yet from somewhere else). So I generate my own symbols directly from Stm32 Cube MX’s .ioc file. I leave only the default pin and the actually used alternate pin function. The inconvenience is that I need to create a new symbol for each project, but a perl script does it for me like this : makesymbol file.ioc file.lib.
But the advantage is that I’m (almost) sure that the software will match the hardware because it’s generated from the same file I used to generate the symbol. For instance in the example below, the names DM and DP are in the symbol, and there is no way to mistake, except if I screw up the labels.
If I had only PA12 and PA11, I know I’m stupid enough to invert them.

Pascal

Example

If you generate your own schematic symbols from scripts, you have full control over what’s in it and where the pin locations are.

So you’re in luck that KiCad’s file formats are easy to hack text files, but you already know that.

Did you also find the pdf with kicad’s description of file formats on:
https://kicad.org/help/file-formats/

Hello!

If you generate your own schematic symbols from scripts, you have full control over what’s in it and where the pin locations are.

I agree, but the point of my first message was to submit an improvement idea (the final ‘a’ didn’t make it into the title). I have full control with the scripts I wrote, but it would be better to have full control from Kicad.
Anyway what I was describing is already planned for version 6 which is good news. And beside this, one functionality I don’t have now is that I have to generate one symbol per project, depending on the functionality I use for each pin, and beside this, the schematics I write cannot be shared without sending my generated libraries. I have no problem with sending them, but adding versions of the same chip just adds noise.
Thanks for the file formats. I will have a look at these documents. By the way, is it possible to add php extensions to Kicad? I read somewhere that there are python extensions but I have never programmed in python.
And yes indeed, all the files are plain text, which makes it easy to customize a lot of things.
Pascal

No no no no. (Makes the sign of a cross.) PHP is the worst. ever. language. I. have. used. :grimacing:

Anyway this will never happen. It’s already a big effort to support one embedded language and a second one is out of the question.

Because of it’s open ness and Open Source-ness and popularity a lot of side projects have sprung up around KiCad.There probably are 20+ of them.

I don’t generally make much use of these myself, as I do not make too many PCB’s and are perfectly happy (concerning KiCad) with it’s default functionality. At least one of those side projects was about cutting text tables from a .pdf datasheet, then pasting them in a spreadsheet, adding some metadata end a script to generate a footprint from that.

It’s been years since I last saw that project, don’t know what has become of it

Did you mean the uConfig project? Seems to be still alive - the last commit was a few months back.

And a Hackaday review here

1 Like

KiPart makes schematic symbols from spreadsheet/CSV files. One of its options is to make symbols based on the output from stm32cube:

When the option ‘-r stm32cube’ is used, the input file should be the pin layout file exported from the STM32CubeMx tool. To create this file; create a project with STM32CubeMx then from window menu select “Pinout -> Generate CSV pinout text file”. If you select pin features or define labels for pins these will be reflected in the generated library symbol.

3 Likes

Hello!

No no no no. (Makes the sign of a cross.) PHP is the worst. ever. language. I. have. used. :grimacing:

You are allowed to dislike PHP, and I’m allowed to like it. But your vociferations are a bit off topic.
The point is that I have quite a few PHP scripts that I could easily reuse. I was just asking if it’s
supported, if it’s not, replying no would be just fine.
PHP (from my point of view at least) and its object oriented features are excellent in processing text.
And Kicad files are only text files. I’m not saying PHP is the best, it’s just another language which is
convenient for what I’m doing.

It’s already a big effort to support one embedded language and a second one is out of the question.

This is a good argument and I understand it even without the need of getting emotional.
I will check if I can make a python plugin allowing me to call PHP scripts and that will do just fine.

Best regards,

Pascal

2 Likes

For a serious software practitioner learning another language is just a routine thing. Python is just as good and I would say even better than PHP for text processing. So why not spend the effort that you would put into developing a Python-PHP shim into learning another, quite useful, language. You’ll find that the software patterns, if you have got them correct, will port easily.

BTW even though KiCad files are text files, they have structure. If you were going to process the whole file, then it’s irrelevant that the embedded language is Python. And while you may get away with substituting strings with regexes in a script that handles the whole file, one day escaped characters, or a multi-line field, or nested parentheses will break your program. To do it right you need to parse the text file (usually S-expressions). An embedded language has the advantage of access to the data structures and functions of the running instance of the KiCad program without having to parse the file, and changes from the embedded language take effect immediately in the instance.

On the other hand if you were going to map the Python objects to PHP objects then by the end of that exercise you will have learnt Python. :wink:

Hello!

BTW even though KiCad files are text files, they have structure.

I’m glad you tell me, I didn’t notice.

Speaking of “serious software practitioner”, porting my scripts would have a cost, as for any
porting. Port the code, test it. Test takes even more time than writing the code. If you are
employee of some company, you don’t care about cost, you do it if you have time, you get your pay
check at the end of the month and that’s about it. I do care about cost. Shifting from Eagle to Kicad
had a cost, even if I’m glad I did it now. Even if I don’t pay for an expensive software now,
making the move was expensive, I had to rewrite custom libraries, I was less efficient for a few
months, etc…
Adding a new language on my palette will have a cost. Adding just enough to run existing scripts
will limit that cost, it’s as simple as that. Every extra hour has a cost.
That said, I have no doubt that python or perl or whatever, you name it, can do as good as PHP
as long as you are used to it and feel comfortable with it.

Pascal

Once you have several languages (computer or natural) under your belt, the incremental cost decreases. You figure out the same things in each language.

How do I open, read and write a file?
How do I write to the console?
How do I manipulate a string?
How do I index an array? An associative array?
How do I access an object member?
How do I call functions? Object methods?
How do I write a conditional?
How do I write a loop?
How do I iterate across a collection?
What libraries are available to save me time?

These are pretty much similar in imperative languages.

I quite dislike at least 3 important aspects in python:

  • The ridiculous dependency on whitespace, which leads to many bugs (and then try to format a patch !!!)
  • No declarations of variables, Every time you mis-spell a var, python just invents a new one.
  • No compilation, simple syntax errors are only caught when that particular line is executed.

There are probably more, but I have not used python much yet.

That said, Python is a quite universal scripting language, used in many different applications. In the last years it seems to have become the defacto standard for scripting. Also for KiCad. There are some 20+ side projects around KiCad and most of them use Python. Python is also used as a scripting language in Pcbnew (although the API apparently has not stabilized yet) and in KiCad V6 it’s also going to be implemented in Eeschema as a scripting language.

KiCad’s footprint wizards are also python scripts.
When you also use python you get access to all the stuff already written for and around KiCad, which is the way Open Source works. You benefit from the code others have written, others benefit from the code you have written, and together the usability of KiCad increases, which makes it more interesting for more people.

Github lists 601 repositories related to KiCad and Python:
https://github.com/search?l=Python&q=kicad&type=Repositories

On Mitja’s request, updated link from his fork to the more upto date:

Over there I counted more then 60 hand picked projects before it gets into “half-baked tools” and “Plumbing”. I did not count those :slight_smile:

At the risk of sounding like a Python fanboy—it’s only one of several languages I use—open source has solutions to some of these drawbacks.

What you actually mean by “dependency on whitespace” is nesting by indentation. This feature is certainly an outlier amongst languages and people usually either love it or hate it. I was on first name terms with Guido when and where the predecessor to Python, ABC, was developed as an educational language to surplant BASIC, so I know where it came from. For me it’s just meh, you can work around it with an IDE or a smart editor.

Use without declaration is a common feature of interpreted languages. You can ameliorate some of the drawbacks by using a checker like pylint. Most of the time, an unintended variable will show up as a reference before set, or a set with no reference. I should mention that some modern languages like Rust and ML are strict type-checked without declaration by using type inference.

Similarly it’s not correct that there’s no compilation phase. There is, to bytecode, but execution follows immediately so you think of it as interpreted. Also a syntax error will not allow execution. Some errors due to dynamic aspects of the language are not however caught until execution. You can run a compilation by itself or use a checker like pylint again.

Besides IDEs there is the autopep8 tool which advises on best practice formatting for readability and is worth using before releasing your opus to the world.

For a web based multimedia project I did, I chose PHP, because it was the most suitable for the task, despite frustrations with it. I did however use a MVC framework so there was an organising concept.

For another project involving HL7 standards I used Java despite its prolixity, because the overriding factor was the existence of a very complete class library implementation.

For KiCad I would stick to Python because it’s supported. Of course you can write external scripts to process files in any language, including bash or sed if you wish, but you lose the tight integration of objects and methods with the running KiCad program.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.