Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to code a new part and footprint? #135

Open
r4dr3fr4d opened this issue Oct 4, 2021 · 3 comments
Open

How to code a new part and footprint? #135

r4dr3fr4d opened this issue Oct 4, 2021 · 3 comments

Comments

@r4dr3fr4d
Copy link

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.

@devbisme
Copy link
Owner

devbisme commented Oct 4, 2021

"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?

@r4dr3fr4d
Copy link
Author

r4dr3fr4d commented Oct 4, 2021 via email

@devbisme
Copy link
Owner

devbisme commented Oct 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants