pointhi / kicad-footprint-generator

creating kicad footprints using python scripts
GNU General Public License v3.0
186 stars 176 forks source link

Add Traco DCDC parts in Single Inline Packages #579

Closed Werni2A closed 2 years ago

Werni2A commented 4 years ago

This script generates footprints for the following series: TBA 1, TBA 1E, TBA 1HI, TBA 2, TMA, TMAP, TME, TMR 1, TMR 2, TMR 2E, TMR 2WI, TMR 3, TMR 3E, TMR 3HI, TMR 3WI, TMR 6, TMR 6WI, TMR 9WI, TMV, TMV-EN, TMV-HI, TMV 2HI, TMW 2WIN, TRV 1M, TEC 2, TEC 2WI, TEC 3, TEC 3WI, TMH, TRA 3, TEA 1, TEA 1E, TEA 1HI.

If there is anything to change please let me know.

Todo:

cpresser commented 4 years ago

Hi,

Instead of having a python file where all the values are basically hard-coded could you please store the actual values in a config file. YAML or JSON, whatever you prefer. Lots of the other generators use .yaml files for that. Then code and config is separate and easier to review.

I know this is a lot of work, but it will also de-duplicate lots of code.

Werni2A commented 4 years ago

@cpresser thanks for your feedback I also considered that possibility in the beginning but haven't found a suitable config file. Do you suggest an existing script or should I modify the existing Python script to parse an YAML/JSON file? I don't have any preferences according the file type therefore I can use YAML to be consistent with the rest.

cpresser commented 4 years ago

There are quite a few .yaml examples in the repo already. Take a look at SMD_chip_package_rlc-etc.py. Or Capacitors_SMD/CP_Elec_round.py.

Werni2A commented 4 years ago

My question might be unclear, it was more meant as "which script can generate my footprints?". In my current approach I used the makeSIPVertical function to generate the footprints but it does not parse any YAML files. Am I supposed to modify the function or use an existing script with an existing YAML config file?

cpresser commented 4 years ago

Ah okay, sorry about that. The answer is none. You have to write a little code/edit your current script.

Glue the makeSIPVertical function together with the config-items from the yaml file. You need one loop for that:

Pseude-Code (taken from Capacitors_SMD/CP_Elec_round.py)

    with open(filepath, 'r') as stream:
        try:
            yaml_parsed = yaml.safe_load(stream)
            for footprint in yaml_parsed:
                print("generate {name}.kicad_mod".format(name=footprint))
                some_setting = yaml_parsed["pin_config"]
                another_setting = yaml_parsed["pin_skip"]
                ...
                makeSIPVertical(footprint, some_setting, another_setting)
Werni2A commented 4 years ago

Thanks! :+1: I try to set it up in the next days :)

codeclimate[bot] commented 4 years ago

Code Climate has analyzed commit 22178d2a and detected 0 issues on this pull request.

View more on Code Climate.

Werni2A commented 4 years ago

@cpresser I created the Yaml generator script and moved the footprints into the Yaml config file. Maybe you have time to review the files? :)

cpresser commented 4 years ago

Most likely I won't be able to do a full review soon. We are having two major milestones in the coming weeks that take precedence. Sorry. But I guess after that I will. Please remind me of this PR if I have not worked on it by mid of October.


Anyway, I now see a .yaml file, but no script load it to generate footprints. Did you forget to add that?

Werni2A commented 4 years ago

Thanks, take your time.

The generator is in a separate PR https://github.com/pointhi/kicad-footprint-generator/pull/624 I'm not sure if this was a good idea but I thought that it would be easier to merge the generator without any Yaml config file.

Franck78 commented 4 years ago

Hello Dominik,

This is in the generator. I would write this :

    if not 1 in missing_pins:
        kicad_mod.append(Pad(number=1, type=Pad.TYPE_THT, shape=Pad.SHAPE_RECT, at=[0, 0], size=pad, drill=ddrill,
                             layers=['*.Cu', '*.Mask']))
        keepout=keepout+addKeepoutRect(0,0,pad[0]+2*min_pad_distance+2*lw_slk, pad[1]+2*min_pad_distance+2*lw_slk)
    for x in range(2, pins + 1):
        if not x in missing_pins:
            kicad_mod.append(Pad(number=x, type=Pad.TYPE_THT, shape=Pad.SHAPE_OVAL, at=[(x - 1) * rm, 0], size=pad,
                                 drill=ddrill, layers=['*.Cu', '*.Mask']))
            if (padx/pady)<1.05 and (padx/pady)>.95:
                keepout=keepout+addKeepoutRect((x - 1) * rm,0,pad[0]+2*min_pad_distance+2*lw_slk, pad[1]+2*min_pad_distance+2*lw_slk)
            else:
                keepout=keepout+addKeepoutRound((x - 1) * rm,0,pad[0]+2*min_pad_distance+2*lw_slk, pad[1]+2*min_pad_distance+2*lw_slk)

like that

   # starts with rectangular pin
    useShape=Pad.SHAPE_RECT

    for x in range(1, pins + 1):
        if not x in missing_pins:
            kicad_mod.append(Pad(number=x, type=Pad.TYPE_THT, shape=useShape, at=[(x - 1) * rm, 0], size=pad,
                                 drill=ddrill, layers=['*.Cu', '*.Mask']))
            if (padx/pady)<1.05 and (padx/pady)>.95:
                keepout=keepout+addKeepoutRect((x - 1) * rm,0,pad[0]+2*min_pad_distance+2*lw_slk, pad[1]+2*min_pad_distance+2*lw_slk)
            else:
                keepout=keepout+addKeepoutRound((x - 1) * rm,0,pad[0]+2*min_pad_distance+2*lw_slk, pad[1]+2*min_pad_distance+2*lw_slk)
        # switch to oval shape
        useShape=Pad.SHAPE_OVAL

There is two occurrences for this 'simplification'

Someone also wrote it's easier to read

X += B instead of
X = X+B ( keepout=keepout+add....)

Franck

edit I (cpresser) was so bold to edit this comment to enable syntax highlight

cpresser commented 4 years ago

The generator is in a separate PR #624 I'm not sure if this was a good idea but I thought that it would be easier to merge the generator without any Yaml config file.

I would prefer the .yaml file is part of the generator PR. At least some kind of DCDC-SIP-test.yaml. Otherwise it is hard to verify its functionality.

Werni2A commented 4 years ago

@Franck78 Thank you for the input, I fully agree with your suggestions but this it not the right issue to keep track of it. I try to keep it in mind when I refactor the scripts but please remind me if I forget about it.

Not related to this issue but a reminder for myself:

@cpresser The generator PR already provides a small Yaml file with the basic functionality but I will add the Yaml from this PR additionally to provide broader testing possibilities.