Kicad schematics and PCB Python scripting

Поделиться
HTML-код
  • Опубликовано: 8 янв 2025

Комментарии • 84

  • @PsychogenicTechnologies
    @PsychogenicTechnologies  11 месяцев назад +2

    The repo is: github.com/psychogenic/kicad-skip -- show me what you do with it! Would love to see, and can link in README or put in examples. Issues, pull-requests, comments through github more than welcome :)
    Also, as @norm1124 pointed out, I just did a regularplex in the video, but the sample now has the option to generate either that or a (I think!?) valid charlieplex: github.com/psychogenic/kicad-skip/blob/main/src/skip/examples/charlieplex.py
    In addition to the docs, I put up a blog post with more discussion about function and internals: inductive-kickback.com/2024/02/scripting-for-kicad-schematics-in-python/

  • @jamesb1559
    @jamesb1559 7 месяцев назад +4

    I am amazed at the Python scripting capabilities with KiCad, and your library looks very promising. Thank you for this work and contribution.

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  7 месяцев назад +2

      Yes! It's crazy what you can do with scripting on the layout side. Though the uses may be more niche/restricted, I wanted to bring some of that power over to the schematic side as well: I hope you find some use out of it :) Cheers

    • @jamesb1559
      @jamesb1559 7 месяцев назад

      @@PsychogenicTechnologies I have done extensive EDA programming with both Python and now Rust through the years, but am finding that the functionality of KiCad with Python is quite powerful. There are other tools out there such JITX which is quite interesting, and am currently giving it a try. I will evaluate your program from github, and really appreciate your efforts.
      👍

    • @jamesb1559
      @jamesb1559 7 месяцев назад

      @@PsychogenicTechnologies 👍 Will definitely test out the github repo and send any comments or pull requests. Awesome !

  • @dimassetiaji2911
    @dimassetiaji2911 2 месяца назад +2

    BEST of Kicad.....we really need to automate the boring stuff...

  • @marksminis
    @marksminis 10 месяцев назад +1

    Hey there! You're in our P24 group "2023 Sneakers" - so I just popped in to take a peek, and BAM! Your channel has grown, your videos are slick and it looks like everything is bangin' on all cylinders! Bravo!

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  10 месяцев назад +1

      Hey Mark! Yes indeed, though I haven't been present in the forum I have been busy on the project. Many thanks for the feedback: I've been trying to improve how I can improve both how I get information across and reach--so that the info actually makes it to those who can use it. It seems to have paid off, in terms of growth, but more importantly in terms of people seeming to appreciate both the content and container. Everytime I get positive feedback for one of my vids, it spurs me to try and make even better ones, and sooner :)

  • @michalt.4243
    @michalt.4243 3 месяца назад

    Great example how to start with Kicad scripting by testing in the REPL and perfect idea to automate boring stuff. Thanks a lot! I am voting for more. Making the script is also the only way to add the functionality which not exists in Kicad.

  • @_-martin-_
    @_-martin-_ 11 месяцев назад +6

    I'm a hardware and software engineer and I love Kicad. I'm looking forward to the soon to be released Kicad v8.0! For Kicad v9.0 the devs are working on improving and stabilizing their APIs which should improve everything including the script interfaces.

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  11 месяцев назад +4

      Hello Martin! Yes, 8 looks like it's going to rock--the pace of kicad's progress in the past few years has been astounding. Didn't know about the 9.0 details, curious about that for sure. Cheers!

    • @_-martin-_
      @_-martin-_ 11 месяцев назад +6

      @@PsychogenicTechnologies FYI, the Kicad team leader just gave a status update on Kicad at Fosdem. The video was released a few hours ago.

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  11 месяцев назад +3

      @@_-martin-_ oh, that's great--I'd seen announcements when it was happening but not for the video yet. Thanks!

  • @BeefIngot
    @BeefIngot 9 месяцев назад

    Heckin cool.
    As a beginner non ee hobbyist I could have used this not too long ago where just to get ball rolling I added a SK9822 EC20 5x7 array just for a 1 char display on a board where I would have added more if it wasnt so painful and tedious.
    I was using Fusion Electronics then, but have since switched to Kicad which has been much _much_ better.
    This would have been great for that and Im sure will be useful in the future.
    BTW, That easyeda Python library you recommended has been great, only requuring a few things adjusted like courtyards text placement and pin types.

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  9 месяцев назад +1

      Thanks!! :-D I'm glad to hear it'll be of use. The thing about the lib is that it's a different mindset for different problems, to me, than general purpose schematic design--easy if you've got programmer mind, but a bit off the deep end for complete beginners. For me, it's great--a little like using openscad vs freecad: I use both, but I turn to openscad most of the time because most of what I need is more symmetrical and based on engineering drawings rather than anything near "sculpted".
      Also thanks for the feedback on the easyeda lib--I haven't actually tried it yet, so great to hear it's workable.
      Cheers!

  • @Juanpavz
    @Juanpavz 11 месяцев назад

    I remember using python in the past to automate reports in LTSpice...doing the same for Kicad will increase my productivity. Please continue with your amazing work.

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  11 месяцев назад +1

      Thanks Juan, that's great to hear! I feel the same, love when I can automate all the drudgery away and concentrate on the human stuff. Also, though this may just be a programmer bent, there are so many times when I can think of how I'd solve some problem sorting/filtering/editing/whatever in a simple loop and the hardest part is getting the data in or out--so I'm hoping this lib will handle that part for others as well :)

  • @mateuszpasternak5360
    @mateuszpasternak5360 10 месяцев назад

    PT thank You very much for this tutorial - I always wondered how those guys in IC design companies are using CAD tools run by scripts - now I've catched a glimpse.

  • @jamesross3939
    @jamesross3939 2 месяца назад

    You type faster than i can think!! Very nice informative video.

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  2 месяца назад +2

      Thanks a lot, James :-D I'll admit, I chop out some of the boring with the magic of editing, heh.

  • @HoanNguyen-kh7wr
    @HoanNguyen-kh7wr 2 месяца назад

    Hello sir. According to my understanding of this industry, which field is more complex, the design of electronic circuit diagrams (schematic) and PCB layout for products? For new engineers, should they start with schematic pcb or layout pcb, sir?

  • @evildoctorbluetooth
    @evildoctorbluetooth 6 месяцев назад

    Thanks

  • @Timpot05
    @Timpot05 4 месяца назад +1

    Very cool. Can I add new components from my library to the schematic as well?

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  4 месяца назад +1

      Yes. The system is kinda dumb, since components are very involved and bring in lots of bits from lots of places, but the easiest way to do something like that is start a sheet as a starting template, stick whichever component you want to play with in it, and then clone it as many times as you like and/or play around with it (move it etc).

    • @Timpot05
      @Timpot05 4 месяца назад

      @@PsychogenicTechnologies Thanks! If you ever get to that feature, adding components from the CLI would be pretty cool!

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  4 месяца назад

      @@Timpot05 Yes :) There are some pretty big and interesting changes coming to all forms of scripting in KiCad 9. I'm going to dive into that in the near future and will be doing some work on the lib--AFAIK this will allow more than just working on dead files, so we can have true interactive scripting while in the program, as we've had on the layout side for a long time now.

  • @johnpomaro1731
    @johnpomaro1731 11 месяцев назад

    Wow, your work is very much appreciated!

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  11 месяцев назад

      Many thanks, John! If you do anything interesting with it--whether something generally useful or just a timesaving hack--I'd love to hear about it. Cheers

  • @AjinkyaKohokade
    @AjinkyaKohokade 9 месяцев назад

    I came across a problem where when i write a file in kicad version 8.0.1, it gives offset error

  • @ozzloy
    @ozzloy 11 месяцев назад +1

    this is like openscad, but for schematics! that's neat!

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  11 месяцев назад +1

      Oh, yeah, that's a great analogy! And just like for mechanical CAD, there are a lot of cases where it's something unique or irregular and there I'll turn to FreeCAD. Even when you want to parameterize FreeCAD is pretty awesome. But when it's repetitive, regular or just well described in an algorithmic way, then I reach for OpenSCAD, and it's the same thing here.
      On top of that, there are cases where you just want a quick mod--I used to reach for command line sed or perl to do a quick search and replace through the raw file but with (the (later (lisp-type "format"))) this isn't as easy... but with a REPL? Even better than a regexp :)

  • @evildoctorbluetooth
    @evildoctorbluetooth 6 месяцев назад

    Fantastic!
    Does this work with the current version of kicad as of now?
    This library could be just what I need for generating a test PCB. PCB.

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  6 месяцев назад

      Thanks! Yes, it should (though I may have some minor updates to do, been rather hectic). The fact is some pretty major changes are coming on the scripting front with kicad 9, but from my chat with Wayne Stambaugh a couple of weeks ago, I think I'll wind-up retrofitting this system to talk through the thin scripting layer that will be provided to add in the extra functions while finally getting *live* interaction with the schem (currently happens through the file itself).

  • @ml1186
    @ml1186 11 месяцев назад

    That's awesome! Thank you for sharing!

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  11 месяцев назад

      And thank you for the feedback! That's it's useful makes the effort worthwhile :D Cheers

  • @_a_x_s_
    @_a_x_s_ 10 месяцев назад

    Nice project! Maybe a good module used for git diff. Let me dig into the doc and find out what I can use.
    Are you going to get this working with KiCad 8? It will be released this month I believe.

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  10 месяцев назад +1

      Thanks! Yes, the plan is def to ensure it works with 8. Have tried it with 8RC3 and, other than a small change needed for PCB layout files, it's looking like a pretty smooth path. Also, I have a feeling 8 will be out by the end of this week (but I dunno)!
      Let me know if you find some interesting use for it or hit any problems. Cheers

  • @khangau4844
    @khangau4844 10 месяцев назад

    Like it s cool and all to be able to use Python to draw schematics, but I wonder how much utility value we are getting here tho. Its use case is very limited to a few mundane and repetitive tasks.

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  10 месяцев назад

      Exactly! If you tried doing an entire schematic this way, would likely be a whole lot more work, and less intuitive/fun. The use case is basically the schematic equivalent of the layout plugins--all the repetitive stuff, so LED arrays, or selective renames or whatever, like I use via fencing and arrays in layout.

  • @kentswan3230
    @kentswan3230 11 месяцев назад

    this is ultra cool. Fussy because it's very detailed oriented because it has to be but cool none the less. I wonder. Is there a similar capability for pcb layout?

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  11 месяцев назад

      Actually, the PCB stuff has had really good scripting for a while already (it's what all the plugins are based on, but you can also use it from a shell in kicad layout). A sample cheatsheet: www.atomic14.com/2022/10/24/kicad-python-scripting-cheat-sheet-copy.html
      Also, the fact is that the basics of this lib are pretty agnostic in terms of what's in the file, as long as its s-expressions, and the kicad layout files work fine. I *could* make extra functions/wrappers, but not sure it's worth it with the existing support.

    • @kentswan3230
      @kentswan3230 11 месяцев назад

      @@PsychogenicTechnologies Actually I was thinking along the lines of a form of helper auto-placement automation using a mathematical mesh connection clustered patterning that I worked with some years ago. This clustering helper process would typically occur at the rat's nest pre-routing stage. This would automate the placement clustering technique that I already use manually in Altium Designer.
      The overarching concept for this form of auto-placement assist concept is that components are associated into routing groups on a schematic meaning that they are generally intended to be grouped on the PCB. The first step uses an algorithm that accepts these schematics component groupings to generate clustered islands of non-overlapping component footprints as well as roughly arranging the relative orientation and placement of those components to minimize the pin-to-pin wire distance between associated pins. My normal assumption is a 4 layer board so power and grounds are simple drop vias to the power planes. The clustering algorithm would also have to honor the courtyard aspects of each component. In any case, these component group islands are then plopped down on the rats' nest form of the PCB during the initial component transfer to the PCB layout. The idea is that you should be able to move and rotate them as a group as well as rearrange and reposition individual components within a group. There is also a possibility of using auto-routing for the intra-group pin-to-pin connections though those should be easily handled with manual routing. A consequential extension of this concept is to be able to move completely routed groups around on the PCB both for mechanical positioning as well as trying to minimize the remaining inter-group rats' net wire connection lengths.
      As you can see, I've been thinking about this for a while but couldn't come up with a decent way to extract the information out to be auto-placement processed and then reinject the results transparently back into the PCB layout subsystem.

  • @deadeye1982a
    @deadeye1982a 2 месяца назад

    Nice project and thank you.

  • @MrLareneon
    @MrLareneon 6 месяцев назад

    I feel like an idiot after trying out this library. I've spent like 6 hours now just trying to delete a property from a specific component. I think it's not working because I'm deleting a copy created in Namedelementcollection instead of the underlying element collection. Seems like namedelementcollection creates a new dict called _named and I can use elementRemove on that... but it leaves the underlying list of elements unchanged. Simialar problem trying to use delete(). I'm sure I'm just missing something obvious but it seems impossible to actually delete anything.

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  6 месяцев назад

      hm, I'll have to check this out... have a few pending TODOs and issues to process. Pretty sure I had *delete()* working though... however properties are weird in the sch file, maybe there's a pending bug.

    • @MrLareneon
      @MrLareneon 6 месяцев назад

      @@PsychogenicTechnologies Thanks for the reply I didn't expect that! I'm going to keep trying and if I figure out a fix I'll submit a PR

    • @MrLareneon
      @MrLareneon 6 месяцев назад

      @@PsychogenicTechnologies I did end up figuring it out. Deletions aren't reflected in python besides setting _deleted for removed objects. They still show up in the REPL and you can still do operations against them in a script. They just aren't written back to the tree/file when you pass the object back to write.

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  6 месяцев назад

      @@MrLareneon oh! So if you'd write it out and read it back, they'd be gone, but otherwise they hang around in Python? Hm. I really can't remember why that might be the case

    • @MrLareneon
      @MrLareneon 6 месяцев назад

      @@PsychogenicTechnologies I can submit an issue with an example script if it would be helpful. But my use case now works fine so only if you consider this a bug.

  • @EmulationOnline
    @EmulationOnline 3 месяца назад

    Lifesaver. I foolishly selected components before my morning coffee, and used footprints based on metric instead of the imperial sizes all the component vendors use. So I had about 100 passives where I needed to update ex: Resistor_SMD:R_0201_0603Metric (really 0201 not 0603 as I had selected for the part) to Resistor_SMD:R_0603_1608Metric

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  2 месяца назад +1

      This! This is exactly the kind of thing that was driving me nuts... I had, in the past, done some raw search and replace in the files, but that's annoying and risky and you can only get so far before you have to start scripting stuff or decide it isn't worth it and do it manually. Really glad it was useful :)

  • @HoanNguyen-kh7wr
    @HoanNguyen-kh7wr 5 месяцев назад

    I would like to know what software are you programming python on?

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  5 месяцев назад

      Hello Hoan: I sometimes use geany or even vi but mostly use eclipse (with PyDev), as I like the project management, code completion, etc and I can write in all my fave languages.

    • @HoanNguyen-kh7wr
      @HoanNguyen-kh7wr 5 месяцев назад

      @@PsychogenicTechnologies yes, thanks you!

    • @HoanNguyen-kh7wr
      @HoanNguyen-kh7wr 5 месяцев назад

      @@PsychogenicTechnologies but can you tell me if it is possible to write python script for Allegro pcb? thanks a lot!

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  5 месяцев назад

      @@HoanNguyen-kh7wr oh, actually I can't--I know nothing about this... it's a cadence thing? I've been a pure kicad guy for many years now, so I don't know. But, they make powerful software, I assume there's a way to script things. Just def not with my libraries! heh

    • @HoanNguyen-kh7wr
      @HoanNguyen-kh7wr 5 месяцев назад

      @@PsychogenicTechnologies Thank you

  • @crimpers5543
    @crimpers5543 11 месяцев назад

    reminds me of the "automation" xkcd

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  11 месяцев назад +1

      haha, ok, some truth to that. I have to say, even if doing "automation" for stuff like this takes 10% longer, when it's dull (like hundreds of wires) or when I might learn something, or when there's the slightest chance I'll want to make a change, or do this again in the future, then to me, it's worth it.
      I mean, writing the library was a killer and all because I didn't want to go in and edit the source file manually. Would've taken me 2 minutes compared to hours--but now it's done, and I won't ever have to look into a kicad_sch file again, and maybe this is now also true for a others who'll be able to do more with their time. Eh, I can always dream :)

  • @bobweiram6321
    @bobweiram6321 7 месяцев назад

    Are you on speed or was this scripted?

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  7 месяцев назад +1

      Both? Well, if caffeine counts. I take extensive (extensive) notes prior and sometimes write-up tough bits... and then there's editing, and a then good deal more editing. I try to keep it snappy.

  • @norm1124
    @norm1124 11 месяцев назад

    Isn't this good old multiplexing rather than charlieplexing?
    But: Great tool ❤

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  11 месяцев назад

      lol, pretty certain you're right... charlie's supposed to give you more magic per pin--had it in mind because of a bitluni led thing but only implemented an xy array, think it'd only be called that if we tie ROW_N with the corresponding COL_N. Will have to correct the sample name, or make a mod, but the video... well the gaffe is for the history books now ;-)
      Thanks for the comment and feedback!

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  11 месяцев назад

      Ok, have made an update that (unless I'm too buzzed after this long week) actually gives us the opportunity to charlieplex
      github.com/psychogenic/kicad-skip/blob/main/src/skip/examples/charlieplex.py :)

  • @gerardodafonseca7909
    @gerardodafonseca7909 9 месяцев назад

    excelente, excellent

  • @ShamrockCircuits
    @ShamrockCircuits Месяц назад

    This is awesome!!! I started using it just this weekend to get some sort of project variant support in KiCad. So far I'm just adding "Variant_" properties to EVERY part then using that as a DNP flag for the variant... The only road block I've found is it seems like there's no (quick?) way to delete a property. Nonetheless, this is superb! Thanks for sharing :)

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  Месяц назад

      Thanks! I actually have a PR that's been lingering (github.com/psychogenic/kicad-skip/pull/12) that might address the issue. I've been heads down doing the TT SDK v2 release to ship out with TT06 boards, but I'm hoping to get to it shortly (as soon as I release this next video). Thanks a lot for your awesome feedback :D

  • @Dexter101x
    @Dexter101x 10 месяцев назад

    A lot of typing needed

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  10 месяцев назад +2

      Ya, I can't deny it: a case of TANSTAAFL... you're gonna pay somehow.
      So, a question of tradeoffs. If it's something you'll only ever need once, or it's hard to describe algorthimically or if clicketyclicking wire connections relaxes you more than sudoku does for others, then it's not time for this tool.
      If it's repetitive, boring, will be needed often, or you can see the algorithm in your mind like a beautiful tapestry, well maybe the lib is perfect there.
      I mostly like having options. This is one.

    • @Dexter101x
      @Dexter101x 6 месяцев назад

      @@PsychogenicTechnologies I've gotten wiser with coding over the last 6 months, I see that Kicad has a console for the python on Windows computers, but need to know how to use it

  • @TomLeg
    @TomLeg 11 месяцев назад

    Very nice!

  • @BlueyMcPhluey
    @BlueyMcPhluey 11 месяцев назад

    interesting, I may have to convert to KiCad after all... 🤔

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  11 месяцев назад

      Hello Josh, yeah, give it a go! I really get a lot done and v8 is coming out very shortly and looks to be rockin' :) Barrier to entry re: price is impossible to beat of course but even the learning curve isn't too steep. I remember, hardest part to me way back was the decoupling between symbols and footprints (which I now appreciate). What do you use currently?

    • @BlueyMcPhluey
      @BlueyMcPhluey 11 месяцев назад

      @@PsychogenicTechnologies I use EasyEDA because I like how easily it connects to JLCPCB/LCSC

  • @inhed
    @inhed 11 месяцев назад

    Awesome

  • @8Junio76
    @8Junio76 10 месяцев назад

    Subscribed

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  10 месяцев назад

      Welcome! I hope I'll have stuff to make it worth your while in the near future. Cheers

  • @NNNILabs
    @NNNILabs 10 месяцев назад

    Although I'm not a fan of the "software approach to electrical engineering" (software is an offshoot of computer science and computer science is an offshoot of electrical engineering, so it always annoys me when software people come back to us and tell us how to do and what to do🤣), I love the snappiness of your videos and your typing speed and coherent narration always makes me chuckle!

    • @PsychogenicTechnologies
      @PsychogenicTechnologies  10 месяцев назад +1

      hah, am with you there. There's a reason a we use drawings tools like this: a schematic is a lot more human brain friendly than a spice netlist, even if they represent exactly the same thing. I mostly just refuse to do repetitive things--be it via shielding or "swapping out all the 10ks in this section here for 50k" or anything else like it. Life is too short, and that's what I wanted with this tool.
      Thanks for the feedback and comment! Will keep it snappy, heh.