I’ve made a script that makes the footprints for the TE Connectivity MICRO-MATCH SMD FTE connectors. As this is my first footprint creation script, I would like some feedback before I post it as a merge request.
#
# Parts script module for TE Connectivity MICRO-MATCH SMD FTE footprints for KicCad
#
# This module is built on top of the kicad-footprint-generator framework
# by Thomas Pointhuber, https://github.com/pointhi/kicad-footprint-generator
#
# This module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with kicad-footprint-generator. If not, see < http://www.gnu.org/licenses/ >.
#
# (C) 2020 Cedric de Wijs, <https://gitlab.com/Cedric5008>
#
#!/usr/bin/env python3
import sys
import os
import re
# load parent path of KicadModTree
sys.path.append(os.path.join(sys.path[0], "..", ".."))
# load scripts
sys.path.append(os.path.join(sys.path[0], ".."))
from KicadModTree import *
series = "MICRO-MATCH SMD FTE"
manufacturer = 'TE Connectivity'
orientation = 'H'
number_of_rows = 2
pitch_x = 2.54 #between pins in a single row
x_offset_betweens_rows = 1.27
pad_size_x = 1.5
pad_size_y = 3.0
y_offset_between_rows = pad_size_y+1.5
y_centerline_offset_from_pin1 = y_offset_between_rows/2
y_total_pin_size = pad_size_y + y_offset_between_rows
x_courtyard_clearance = 0.5 #see F5.3
y_courtyard_clearance = 0.5 #see F5.3
silkscreen_clearance = 0.25
y_courtyard_size = y_total_pin_size + 2*y_courtyard_clearance #ignores the clearance needed for the mating connector
y_silkscreen_size = y_total_pin_size + 2*silkscreen_clearance
x_overhang_from_middle_of_pin = 2.1 #B size in datasheet is rounded, this is the max value, taken from the 20 pin model
y_body_size = 5.2
y_component_value_offset = 7.3
datasheet = 'https://www.te.com/commerce/DocumentDelivery/DDEController?Action=showdoc&DocId=Customer+Drawing%7F188275%7FS4%7Fpdf%7FEnglish%7FENG_CD_188275_S4.pdf%7F2-188275-0'
myParameters = [[2,"0-188275-4"],
[3,"0-188275-6"],
[4,"0-188275-8"],
[5,"1-188275-0"],
[6,"1-188275-2"],
[7,"1-188275-4"],
[8,"1-188275-6"],
[9,"1-188275-8"],
[10,"2-188275-0"]]
numrows = len(myParameters)
def generate_one_footprint(number_of_pins,part_number):
footprint_name = part_number
x_centerline_offset_from_pin1 = (number_of_pins/2)*2.54 - x_offset_betweens_rows/2
# init kicad footprint
kicad_mod = Footprint(footprint_name)
kicad_mod.setDescription(part_number)
kicad_mod.setTags("connector top entry")
# set general values
kicad_mod.append(Text(type='reference', text='REF**', at=[x_centerline_offset_from_pin1, -3], layer='F.SilkS'))
# create silk screen
kicad_mod.append(RectLine(start=[-x_overhang_from_middle_of_pin-silkscreen_clearance, (y_centerline_offset_from_pin1-y_silkscreen_size/2)], end=[(number_of_pins-0.5)*pitch_x+x_overhang_from_middle_of_pin+silkscreen_clearance, (y_centerline_offset_from_pin1+y_silkscreen_size/2)], layer='F.SilkS'))
# pin 1 designator
kicad_mod.append(Polygon(nodes=[[0,-2.54], [1.27,-3.81], [-1.27,-3.81]], layer='F.SilkS'))
# create courtyard (see F5.3 - Courtyard layer requirements)
kicad_mod.append(RectLine(start=[-x_overhang_from_middle_of_pin-x_courtyard_clearance, (y_centerline_offset_from_pin1-y_courtyard_size/2)], end=[(number_of_pins-0.5)*pitch_x+x_overhang_from_middle_of_pin+x_courtyard_clearance, (y_centerline_offset_from_pin1+y_courtyard_size/2)], layer='F.CrtYd'))
# create fabrication layer
kicad_mod.append(RectLine(start=[-x_overhang_from_middle_of_pin, (y_centerline_offset_from_pin1-y_body_size/2)], end=[(number_of_pins-0.5)*pitch_x+x_overhang_from_middle_of_pin, (y_centerline_offset_from_pin1+y_body_size/2)], layer='F.Fab'))
kicad_mod.append(Text(type='value', text=footprint_name, at=[x_centerline_offset_from_pin1, y_component_value_offset], layer='F.Fab'))
kicad_mod.append(Text(type='user', text='%R', at=[x_centerline_offset_from_pin1, y_centerline_offset_from_pin1], layer='F.Fab'))
# create pads
for pinnr in list (range(number_of_pins)):
kicad_mod.append(Pad(number=(pinnr*2)+1, type=Pad.TYPE_SMT, shape=Pad.SHAPE_RECT,
at=[pinnr*pitch_x, 0], size=[pad_size_x, pad_size_y], layers=Pad.LAYERS_SMT))
kicad_mod.append(Pad(number=(pinnr*2)+2, type=Pad.TYPE_SMT, shape=Pad.SHAPE_RECT,
at=[pinnr*pitch_x+x_offset_betweens_rows, y_offset_between_rows], size=[pad_size_x, pad_size_y], layers=Pad.LAYERS_SMT))
# add model
wlrname = '{fp_name:s}.wrl'.format(fp_name=footprint_name)
kicad_mod.append(Model(filename=wlrname,
at=[0, 0, 0], scale=[1, 1, 1], rotate=[0, 0, 0]))
# output kicad model
filename = '{fp_name:s}.kicad_mod'.format(fp_name=footprint_name)
file_handler = KicadFileHandler(kicad_mod)
file_handler.writeFile(filename)
for i in list (range(numrows)):
number_of_pins = myParameters[i][0]
part_number = myParameters[i][1]
generate_one_footprint(number_of_pins,part_number)