LTspice to KiCad symbol conversion

Hi there,

I have a large number of component symbols in LTspice and need to be able to use them in KiCad 5.1.5. I’m looking for a way to automatically convert from one file format (LTspice .asy files) to the other (KiCad .lib files).

I found a github link in a post from @laurent that links to a script they wrote to do this, unfortunately, the results of that script are unusable. Lines aren’t ended properly, reference numbers and part names are overlapping and the properties fields are not properly filled out (An unnecessary 5th field is created for all of them).

This script has not been updated since 2017, do any other ones exist? What is the best way to convert these symbols?

It would be nice but, AFIK, can’t be done.

Consider this:
In LTspice, you can create a Potentiometer using a Voltage Divider and overlay it with a single Resistor graphic.
Here’s a Link to the most widely known Tutorial to do that.

But, I can’t do it in ngspice/KiCad. AFIK, can do only a typical Resistor Divider that represents a Pot. No no ‘real’ pot overlaying graphic.
Sure, I drew a graphic box around the two resistors with a Text label but, that’s not quite the same as having a correct looking Pot.

If someone can do it, please show us how…

You may use one of the three leg pot symbols, e.g. Device:R_POT, and then add a ngspice subcircuit model to the symbol, as Ste has shown in Basic Potentiometer simulation

If this issue is important to you, then consider learing some scripting yourself.

both the Spice .asc and KiCad’s symbol libraries are simple ascii format and if you’ve already got an example that seems to be 80% there, then it actually is 95% done already.

If you do not want all those “5th fields”, then that’s probably just a single line to edit in the script for example.

The script itself is just a few hundred lines of Python. If you have any interest in Python, a project like this is is a good start to dive into it.

On the other hand:
How many of those symbols are actually useful for you?
Attaching a spice model to an existing KiCad symbol is just a few mouse clicks, remapping the pins may take some time to figure out.

Also:
These .asc things. Are those just graphical schematic symbols, or complete schematics wit multiple symbols and wires between them?

I’m planning on learning some scripting and fixing this up myself. I was just wondering if anyone else did it already to save some time. I have some basic python knowledge but it’s been a couple of years and I’m completely new to scripting.

These .asy files are just graphical schematic symbols so not that bad to create (especially with something like KiPart) but we have upwards of 2000 of them that need to be migrated so doing it by hand is not an attractive option.

I’ll write my own script and update you guys once I get it working, thanks for your help!

A desctiption of some of KiCad’s file formats should be here:
https://www.kicad.org/help/file-formats/

Unfortunately the file looks like *&^%$#@! and has done so for quite some time. I thought it would have been fixed by now…

So here is my personal copy:
file_formats.pdf (379.2 KB)

And when you fixed the script, don’t forget to send a patch (or the whole file for such a small project) back to github where you started from.

1 Like

I can’t recite the dates of releases, but 2017 wasn’t v5.x. it was maybe v4.x
This is important as lib file formats changed from v4 to v5 and “fixing” the old script may not get you a v5 file.

As a reference you may want to look at the source code for the feature that converts v4 to v5.

@iabarry The script is indeed for KiCad 4.x, I’m fairly certain that it is parsing the LTspice files correctly, I just need to edit the output.

@paulvdh there are a couple formatting things in your personal copy that should be changed. If you have an editable version send it and I’ll give it a quick polish.

My personal copy is just that, and it’s old too.
The version on launchpad was probably an attempt to upload a newer version.
Possibly the latest version now resides on gitlab, and the KiCad website is not up to date.

For me it does not matter to have an updated version. If you want to contribute, then try to get your mods’ into the official documentation.

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