I’m trying to add schematic generation to SKiDL for Kicad v8. I’ve got some of the logic working by copying a blank Kicad project and inserting parts.
Kiutils didn’t work for me to create components so I’m trying to make the logic myself, which is going well except I ran into an issue of inserting NCP1117-3.3_SOT223 as it is an extended part of AP1117-15. My logic doesn’t work well with extended parts and I’ve been struggling through trying to figure it out.
Can anyone point me towards the code in the Kicad repo which generates schematic components? I’d like to study that code.
Or if anyone has other tips please feel free to let me know. Here’s my draft PR if anyone is interested in taking a look or helping. Look at the files in src/skidl/tools/kicad8 for the business logic, everything else is documents to help me figure out this feature.
Generic tip for this kind of thing:
Make the change you want your generator to do manually and look at the resulting file. Then make your generator output the same thing. Rinse and repeat with all the features, do it bit by bit, not a whole chunk at once.
This is not specific enough. What does it mean “doesn’t work well”? Is the generated file unreadable by kicad? Is it readable but not what you expect? Have you isolated the issue? Have you compared your output to what manual edit in kicad does?
That’s basically half of schematic editor. I would start with the parser and symbol definitions
Thank you @qu1ck for the response. I have a small manually file (3v3 linear regulator circuit) I’ve used as a reference for testing and comparing to generated output. But I think I can break down that file into the components and make even more granular tests of generating each component. Great idea.
I purposely didn’t include much detail in the first post so it’s easier to read; I hate walls of texts in forum posts. All the parts I’m trying to use without the extend attribute are generating properly: ESP32, resistors, capacitors, etc. The problem I’m having is with the extended parts that are derived from a parent part. The schematic files generated with non-extened parts are able to opened in Kicad without error.
I’ll take a look at those Kicad source files, thank you so much for pointing me in the right direction!
Do you want to create a full schematic from the SKiDL output?
SKiDL is a bit of an oddball project, and I like it quite a lot. I have not used it myself, because it does not work well for the type of schematics I make, but it may work very well for FPGA stuff (where a schematic is mostly a long list of net labels) or repetitive circuits such as keyboard or LED matrices. And for those, a schematic is not a very terrible useful thing.
Creating a complete schematic from what you create with SKiDL would be difficult, or at least time consuming. How would you determine schematic symbol locations? How do you route the wiring without it becoming a big mess?
I guess it would be a more logical way to combine SKiDL with a schematic. So, instead of creating a schematic of the whole SKiDL output, you combine the two in some way. The connection could be made with net name labels, a hierarchical sheet connector, or a schematic symbol that is created by SKiDL. In this way, you can use SKiDL where it works best, (big matrix) and amend it with a schematic for the parts where the schematic works best (for example microcontroller section or power supply).
It’s just an Idea though, I have not worked out any details myself.
@paulvdh yes, I want to create full schematics with SKiDL.
I originally developed schematic generation a few years ago, and then the SKiDL creator continued the work for 2 more years. It is not an easy problem to generate beautiful schematics. See the blog post here: SKiDL — SKiDL Has Schematics!
I agree that generating entire schematics in human readable and eye-pleasing format will be difficult. Your thought about combining SKiDL with the schematic editor sounds close to my plan.
My plan is for allowing for useful SKiDL schematic generation into Kicad projects:
If you generate a project completely through SKIDL then all parts will have labels and power symbols connected to their pins, no wires. This should allow for electrically correct Kicad projects generated by SKIDL. But will be difficult to read. Connected parts can be shifted towards each other with force directed placement (see blog post above), which will make the schematics slightly less chaotic at first
Ability to import a kicad project to a SKIDL project, allowing for current Kicad projects to easily be integrated with SKIDL. Also setting up for the next feature:
When generating a SKIDL project directed at a current Kicad project then SKIDL will need to determine which parts are already in the schematic and leave those alone. This will allow the user to move schematic parts around and connect them with wires and allow continuous updates from SKIDL while maintaining the Kicad schematic formatting the user has done.