2014-09-14 16:29:10 +00:00
|
|
|
# This program 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 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program 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 this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
# MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
|
2014-04-23 16:36:31 +00:00
|
|
|
from __future__ import division
|
2013-08-28 16:14:39 +00:00
|
|
|
import pcbnew
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
import FootprintWizardBase
|
2014-04-23 16:36:31 +00:00
|
|
|
import PadArray as PA
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
class QFPWizard(FootprintWizardBase.FootprintWizard):
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
def GetName(self):
|
|
|
|
return "QFP"
|
|
|
|
|
|
|
|
def GetDescription(self):
|
2017-01-03 15:01:47 +00:00
|
|
|
return "Quad Flat Package (QFP) footprint wizard"
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
def GenerateParameterList(self):
|
2017-01-03 15:01:47 +00:00
|
|
|
self.AddParam("Pads", "n", self.uInteger, 100, multiple=4, min_value=4)
|
|
|
|
self.AddParam("Pads", "pitch", self.uMM, 0.5, designator='e')
|
|
|
|
self.AddParam("Pads", "width", self.uMM, 0.25, designator='X1')
|
|
|
|
self.AddParam("Pads", "length", self.uMM, 1.5, designator='Y1')
|
|
|
|
self.AddParam("Pads", "horizontal spacing", self.uMM, 15, designator='C1')
|
|
|
|
self.AddParam("Pads", "vertical spacing", self.uMM, 15, designator='C2')
|
2014-04-23 16:36:31 +00:00
|
|
|
self.AddParam("Pads", "oval", self.uBool, True)
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
self.AddParam("Package", "width", self.uMM, 14, designator='D1')
|
|
|
|
self.AddParam("Package", "height", self.uMM, 14, designator='E1')
|
|
|
|
self.AddParam("Package", "courtyard margin", self.uMM, 0.25, min_value=0.2)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def pads(self):
|
|
|
|
return self.parameters['Pads']
|
|
|
|
|
|
|
|
@property
|
|
|
|
def package(self):
|
|
|
|
return self.parameters['Package']
|
2013-08-28 16:14:39 +00:00
|
|
|
|
|
|
|
def CheckParameters(self):
|
2017-01-03 15:01:47 +00:00
|
|
|
# todo - custom checking
|
|
|
|
pass
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
def GetValue(self):
|
2017-01-03 15:01:47 +00:00
|
|
|
return "QFP-{n}_{x:g}x{y:g}_Pitch{p:g}mm".format(
|
|
|
|
n = self.pads['n'],
|
|
|
|
x = pcbnew.ToMM(self.package['width']),
|
|
|
|
y = pcbnew.ToMM(self.package['height']),
|
|
|
|
p = pcbnew.ToMM(self.pads['pitch'])
|
|
|
|
)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
def BuildThisFootprint(self):
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
pad_pitch = self.pads["pitch"]
|
|
|
|
pad_length = self.pads["length"]
|
|
|
|
pad_width = self.pads["width"]
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
v_pitch = self.pads["vertical spacing"]
|
|
|
|
h_pitch = self.pads["horizontal spacing"]
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
pads_per_row = int(self.pads["n"] // 4)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
row_len = (pads_per_row - 1) * pad_pitch
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
pad_shape = pcbnew.PAD_SHAPE_OVAL if self.pads["oval"] else pcbnew.PAD_SHAPE_RECT
|
2014-07-02 13:08:28 +00:00
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
h_pad = PA.PadMaker(self.module).SMDPad( pad_length, pad_width,
|
|
|
|
shape=pad_shape, rot_degree=90.0)
|
2015-09-05 12:10:54 +00:00
|
|
|
v_pad = PA.PadMaker(self.module).SMDPad( pad_length, pad_width, shape=pad_shape)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
#left row
|
2014-09-14 16:29:10 +00:00
|
|
|
pin1Pos = pcbnew.wxPoint(-h_pitch / 2, 0)
|
2015-09-05 12:10:54 +00:00
|
|
|
array = PA.PadLineArray(h_pad, pads_per_row, pad_pitch, True, pin1Pos)
|
2014-04-23 16:36:31 +00:00
|
|
|
array.SetFirstPadInArray(1)
|
2014-09-14 16:29:10 +00:00
|
|
|
array.AddPadsToModule(self.draw)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
#bottom row
|
2014-09-14 16:29:10 +00:00
|
|
|
pin1Pos = pcbnew.wxPoint(0, v_pitch / 2)
|
2015-10-31 11:54:48 +00:00
|
|
|
array = PA.PadLineArray(v_pad, pads_per_row, pad_pitch, False, pin1Pos)
|
2014-04-23 16:36:31 +00:00
|
|
|
array.SetFirstPadInArray(pads_per_row + 1)
|
2014-09-14 16:29:10 +00:00
|
|
|
array.AddPadsToModule(self.draw)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
#right row
|
2014-09-14 16:29:10 +00:00
|
|
|
pin1Pos = pcbnew.wxPoint(h_pitch / 2, 0)
|
|
|
|
array = PA.PadLineArray(h_pad, pads_per_row, -pad_pitch, True,
|
|
|
|
pin1Pos)
|
2014-04-23 16:36:31 +00:00
|
|
|
array.SetFirstPadInArray(2*pads_per_row + 1)
|
2014-09-14 16:29:10 +00:00
|
|
|
array.AddPadsToModule(self.draw)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
#top row
|
2014-09-14 16:29:10 +00:00
|
|
|
pin1Pos = pcbnew.wxPoint(0, -v_pitch / 2)
|
|
|
|
array = PA.PadLineArray(v_pad, pads_per_row, -pad_pitch, False,
|
|
|
|
pin1Pos)
|
2014-04-23 16:36:31 +00:00
|
|
|
array.SetFirstPadInArray(3*pads_per_row + 1)
|
2014-09-14 16:29:10 +00:00
|
|
|
array.AddPadsToModule(self.draw)
|
2013-08-28 16:14:39 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
offset = pcbnew.FromMM(0.15)
|
|
|
|
|
|
|
|
x = self.parameters["Package"]["width"] / 2 + offset
|
|
|
|
y = self.parameters["Package"]["height"] / 2 + offset
|
2014-04-23 16:36:31 +00:00
|
|
|
inner = (row_len / 2) + pad_pitch
|
2013-08-28 16:14:39 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
# Add outline to F_Fab layer
|
|
|
|
self.draw.SetLayer(pcbnew.F_Fab)
|
2018-12-10 11:13:12 +00:00
|
|
|
thick = self.draw.GetLineThickness()
|
2017-01-03 15:01:47 +00:00
|
|
|
|
|
|
|
bevel = min( pcbnew.FromMM(1.0), self.package['width']/2, self.package['height']/2 )
|
|
|
|
|
|
|
|
w = self.package['width']
|
|
|
|
h = self.package['height']
|
|
|
|
|
|
|
|
# outermost limits of pins
|
|
|
|
right_edge = (h_pitch + pad_length) / 2
|
|
|
|
left_edge = -right_edge
|
|
|
|
|
|
|
|
bottom_edge = (v_pitch + pad_length) / 2
|
|
|
|
top_edge = -bottom_edge
|
|
|
|
|
2018-12-10 11:13:12 +00:00
|
|
|
self.draw.SetLineThickness( pcbnew.FromMM( 0.1 ) ) #Default per KLC F5.2 as of 12/2018
|
2017-01-03 15:01:47 +00:00
|
|
|
self.draw.BoxWithDiagonalAtCorner(0, 0, w, h, bevel)
|
|
|
|
|
|
|
|
# Draw silkscreen
|
2018-12-10 11:13:12 +00:00
|
|
|
self.draw.SetLayer( pcbnew.F_SilkS )
|
|
|
|
self.draw.SetLineThickness( pcbnew.FromMM( 0.12 ) ) #Default per KLC F5.1 as of 12/2018
|
2017-01-03 15:01:47 +00:00
|
|
|
|
|
|
|
#top left - as per IPC-7351C
|
|
|
|
self.draw.Polyline([(-inner, -y), (-x, -y), (-x, -inner), (left_edge, -inner)])
|
2014-04-23 16:36:31 +00:00
|
|
|
# top right
|
2017-01-03 15:01:47 +00:00
|
|
|
self.draw.Polyline([(inner, -y), (x, -y), (x, -inner)])
|
2014-04-23 16:36:31 +00:00
|
|
|
# bottom left
|
2017-01-03 15:01:47 +00:00
|
|
|
self.draw.Polyline([(-inner, y), (-x, y), (-x, inner)])
|
2014-04-23 16:36:31 +00:00
|
|
|
# bottom right
|
2017-01-03 15:01:47 +00:00
|
|
|
self.draw.Polyline([(inner, y), (x, y), (x, inner)])
|
2014-09-14 16:29:10 +00:00
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
# Courtyard
|
|
|
|
cmargin = self.parameters["Package"]["courtyard margin"]
|
2018-12-10 11:13:12 +00:00
|
|
|
self.draw.SetLayer( pcbnew.F_CrtYd )
|
|
|
|
sizex = ( right_edge + cmargin ) * 2
|
|
|
|
sizey = ( bottom_edge + cmargin ) * 2
|
2016-02-18 17:53:39 +00:00
|
|
|
# round size to nearest 0.1mm, rectangle will thus land on a 0.05mm grid
|
2018-12-10 11:13:12 +00:00
|
|
|
sizex = pcbnew.PutOnGridMM( sizex, 0.1 )
|
|
|
|
sizey = pcbnew.PutOnGridMM( sizey, 0.1 )
|
|
|
|
|
|
|
|
self.draw.SetLineThickness( pcbnew.FromMM( 0.05 ) ) #Default per KLC F5.3 as of 12/2018
|
|
|
|
self.draw.Box( 0, 0, sizex, sizey )
|
2016-02-09 09:10:17 +00:00
|
|
|
# restore line thickness to previous value
|
2016-02-11 15:02:37 +00:00
|
|
|
self.draw.SetLineThickness(pcbnew.FromMM(thick))
|
2015-10-31 11:54:48 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
#reference and value
|
2015-10-29 17:35:52 +00:00
|
|
|
text_size = self.GetTextSize() # IPC nominal
|
2014-09-14 16:29:10 +00:00
|
|
|
text_offset = v_pitch / 2 + text_size + pad_length / 2
|
|
|
|
|
2015-10-29 17:35:52 +00:00
|
|
|
self.draw.Value(0, text_offset, text_size)
|
|
|
|
self.draw.Reference(0, -text_offset, text_size)
|
2013-08-28 16:14:39 +00:00
|
|
|
|
2016-02-18 14:29:30 +00:00
|
|
|
# set SMD attribute
|
|
|
|
self.module.SetAttributes(pcbnew.MOD_CMS)
|
|
|
|
|
2013-11-01 15:29:50 +00:00
|
|
|
QFPWizard().register()
|