skidl
skidl copied to clipboard
How to code a new part and footprint?
I'm wanting to create a simple pcb containing a very simple part - a cherry mx switch, which has only two pins (and some mounting holes). I'm mucking around with custom kicad libraries/modules and trying to search from within those since the basic kicad library doesn't seem to include it, but I'm also interested in defining the part by just using skidl and bypassing the need for kicad entirely.
Just messing around, I try to make a child class of Part:
class mx(Part):
def __init__(self):
pr = Pin(num=1, name='pr')
pc = Pin(num=1, name='pc')
r1 = Pin(num=1, name='r1')
r2 = Pin(num=1, name='r2')
c1 = Pin(num=1, name='c1')
c2 = Pin(num=1, name='c2')
d1 = Pin(num=1, name='d1')
d2 = Pin(num=1, name='d2')
self.pins = [pr, pc, r1, r2, c1, c2, d1, d2]
Is this the right approach? I'm already getting errors trying to instantiate it (needs "fields") and I know I'll have to define the footprint somehow.
"How do I ...?" questions usually get more exposure if they're posted in the discussions.
As an example, I created a SKiDL module for a PMOD plug here.
You could also do it like this:
class mx(Part):
def __init__(self, *args, **kwargs):
Part.__init__(self, name="MX_SWITCH", tool=SKIDL, ref_prefix="SW", footprint="<something>", **kwargs)
self += Pin(num=1, name='pr')
self += Pin(num=2, name='pc')
...
After defining the mx
class, you can instantiate it like so:
mx_a = mx()
Is there a reason why each of your pins was assigned pin number 1?
'pin number 1'....Hmm not sure how I determined that...I took it out.
Do you have an example of a Python defined footprint? Or is that still external and we're still tied to importing existing footprints from another source? Are the footprints organic to kicad, in general?
Thanks for the reply - if I can get this working I'll definitely share in the discussions and elsewhere!
On Mon, Oct 4, 2021 at 3:35 PM Dave Vandenbout @.***> wrote:
"How do I ...?" questions usually get more exposure if they're posted in the discussions https://github.com/xesscorp/skidl/discussions.
As an example, I created a SKiDL module for a PMOD plug here https://devbisme.github.io/circuitsascode/api/html/_modules/circuitsascode/interfaces/pmod.html#pmod_plug_12 .
You could also do it like this:
class mx(Part): def init(self, *args, **kwargs): Part.init(self, name="MX_SWITCH", tool=SKIDL, ref_prefix="SW", footprint="
", **kwargs) self += Pin(num=1, name='pr') self += Pin(num=2, name='pc') ... After defining the mx class, you can instantiate it like so:
mx_a = mx()
Is there a reason why each of your pins was assigned pin number 1?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/xesscorp/skidl/issues/135#issuecomment-933793213, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACRPRYWNLSXL2GJD2XY6D2DUFH6ZHANCNFSM5FJ77XCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
SKiDL doesn't have any features for defining footprints. Right now, all footprints are fetched from KiCad.
The pcbnew
package that's associated with KiCad's PCBNEW application can be used to create footprints. I've used it to make a plugin: xess_fp_wizard. You could do something similar to make a Python library to make footprints.