############################################################################### # Copyright (C) 2007 Stephen Morss # # pcblander macros # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. # # 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., 675 Mass Ave, Cambridge, MA 02139, USA. ############################################################################### ifdef("footprints_dot_inc_deFined", {exit()}, \ {define("footprints_dot_inc_deFined")}) teaser_declare_revision("0.0.1") ############################################################################## # footprint include file for pcblander ############################################################################### include("landutils.inc") # useful scripts # define some useful variables for macros define("num_pads", 0) # total number of pads - all but BGA, QFP define("num_pads_x",0) # horizontal number of pads - QFP, BGA define("num_pads_y",0) # vertical number of pads - QFP, BGA define("padgap_x", 0) # horizontal gap between pads - all but BGA, DIP, SIP define("padgap_y", 0) # vertical gap between pads - QFP define("tab_width",0) # width of center pad - QFP (0 if no pad) define("tab_height",0) # height of center pad - QFP (0 if no pad) # these vars are part of pcblander - used by the array() function # pad_width # width of pad - all but SIP, DIP # pad_height # height of pad - all but SIP, DIP # drill_diameter # diameter of drill holes - SIP, DIP # pad_diameter # diameter of pad around holes - SIP, DIP # pitch_x # horiz, center-to-center pad distance - QFP, BGA, DIP # pitch_y # vertical center-to-center pad distance # all footprints have a silk outline # use either keepout (distance from silk to pad) or # silkbox_width/silkbox_height to size the outline. Don't use both. # The one you don't use should be set to 0 (default setting) define("keepout", 0) # min silk to pad distance define("silkbox_width", 0) # width of silkbox define("silkbox_height", 0) # height of silkbox define("silk_location", "inside") # location of silk(or "outside") - QFP only #macro definitions ############################################################################### # BGA footprint macro # Builds a BGA with pin A1 in the upper left corner, a silk box around # the pads, and a tick mark in the upper left corner (near A1). ############################################################################### scriptstart("BGA") # get input parameters # allow macro to be placed anywhere loadparams("x", "y") move_origin(x, y) # set environment variables pad_shape = "circular" pad_type = "pad" mydefine("mywidth", (num_pads_x - 1) * pitch_x + pad_width) mydefine("myheight", (num_pads_y - 1) * pitch_y + pad_height) silkbox_width = max(silkbox_width, mywidth+2*keepout) silkbox_height = max(silkbox_height, myheight+2*keepout) # build the pads array(0,0,{A1:genpad(num_pads_x, 1)},{A1:genpad(1,num_pads_y)} ) # draw the silk around pads (box or brackets, uncomment one) #silkbox_brackets(0,0,silkbox_width,silkbox_height) silkbox(0,0,silkbox_width,silkbox_height) # silk has a diagonal line at the upper left hand corner silksegment(-silkbox_width/2, silkbox_height/2,\ -1.07 * silkbox_width/2, 1.07 * silkbox_height/2) "done:BGA macro" scriptend() ############################################################################### # Dual inline package footprint macro # Builds a DIP with pin 1 in upper left corner, with pin 1 a square pad - all # other pads are round. Puts a silk box around the part and silk # box around pin 1. ############################################################################### scriptstart("DIP") # get input parameters # allow macro to be placed anywhere loadparams("x", "y") move_origin(x, y) # set environment variables pad_shape = "circular" pad_type = "hole" # build the pads # for all round pads ... #array( -pitch_x/2, 0, {}, {1:num_pads/2}) #array( pitch_x/2, 0, {}, {num_pads:num_pads/2+1}) # pads with squar pin 1 ... pad_shape = "rectangular" # first shape for twoshapescolumn() # gracefully handle the two pad case ifgt(num_pads, 2, \ {twoshapescolumn( -pitch_x/2, 0, {1}, {2:num_pads/2})}, \ {twoshapescolumn( -pitch_x/2, 0, {1}, {})}, \ ) twoshapescolumn( pitch_x/2, 0, {}, {num_pads:num_pads/2+1}) # draw the silkscreen mydefine("mywidth", pitch_x + pad_diameter) mydefine("myheight",(num_pads/2 -1) * pitch_y + pad_diameter) silkbox_width = max(silkbox_width, mywidth + 2*keepout) silkbox_height = max(silkbox_height, myheight + 2*keepout) silkbox(0,0,silkbox_width,silkbox_height) # silk has a little box in the upper left corner define("bwidth", silkbox_width/2 - pitch_x/2 + pitch_y/2) define("bheight", silkbox_height/2 - (num_pads/2 -1) * pitch_y/2 + pitch_y/2) silkbox(-pitch_x/2 + pitch_y/2 - bwidth/2,\ (num_pads/2 - 1) * pitch_y/2 - pitch_y/2 + bheight/2,\ bwidth, bheight) "done:DIP macro" scriptend() ############################################################################### # Single inline package footprint macro # Makes a vertical string of pads with pin 1 at the top. Pin 1 is a square # pad and all others are round. Puts a silk box around all the pads and # a box around pin 1. ############################################################################### scriptstart("SIP") # get input parameters # allow macro to be placed anywhere loadparams("x", "y") move_origin(x, y) # set environment variables pad_shape = "circular" pad_type = "hole" # build the pads # for all round pads ... #array( 0, 0, {}, {1:num_pads}) # for square pin 1 ... pad_shape = "rectangular" # first shape for twoshapescolumn # gracefully handle the single pad case ifgt(num_pads, 1, \ {twoshapescolumn( 0, 0, {1}, {2:num_pads})}, \ {twoshapescolumn( 0, 0, {1}, {})}, \ ) # draw the silkscreen mydefine("mywidth", pad_diameter) mydefine("myheight", (num_pads - 1) * pitch_y + pad_diameter) silkbox_width = max(silkbox_width, mywidth + 2*keepout) silkbox_height = max(silkbox_height, myheight + 2*keepout) silkbox(0,0,silkbox_width,silkbox_height) # silk has a little square at the top define("bheight", silkbox_height/2 - (num_pads - 1) * pitch_y/2 + pitch_y/2) silkbox(0, (num_pads - 1) * pitch_y/2 - pitch_y/2 + bheight/2,\ silkbox_width, bheight) "done:SIP macro" scriptend() ############################################################################### # Quad flatpack footprint macro # Makes a QFP. Pin 1 is on the left side at the top. Optionally makes # a center pad in the middle of the footprint. Makes a silk box # either inside or outside the part. Make a silk tick mark in upper left # corner (next to pin 1). ############################################################################### scriptstart("QFP") # get input parameters loadparams("x","y") # allow macro to be placed anywhere move_origin(x,y) # set environment variables pad_shape = "rectangular" pad_type = "pad" # if a padgap not defined, define interms of other ifeq(padgap_x, 0, {padgap_x = padgap_y},{}) ifeq(padgap_y, 0, {padgap_y = padgap_x},{}) # figure out how many pads high and wide ifeq(num_pads_x, 0, \ {ifeq(num_pads_y,0,\ {num_pads_x = num_pads_y = num_pads/4}, \ {num_pads_x = (num_pads - num_pads_y * 2) / 2} \ )},\ {ifeq(num_pads_y, 0, \ {num_pads_y = (num_pads - num_pads_x * 2) / 2}, {} \ )} \ ) num_pads = 2 * (num_pads_x + num_pads_y) # build the columns array( -((padgap_x + pad_width)/2), 0, {}, {1:num_pads_y}) array( ((padgap_x + pad_width)/2), 0, {}, \ {(2*num_pads_y+num_pads_x):(num_pads_y+num_pads_x+1)}) #build the rows - swap pad height and width mydefine("tmp", pad_height) pad_height = pad_width pad_width = tmp array( 0, -((padgap_y + pad_height)/2), \ {(num_pads_y+1):(num_pads_y+num_pads_x)}, {}) array( 0, ((padgap_y + pad_height)/2),\ {num_pads:(2*num_pads_y+num_pads_x+1)}, {}) # draw the silkscreen - note pads are vertically oriented ifeq(silk_location, "inside", \ {x = padgap_x - 2*keepout,\ # inside, set initial values y = padgap_y - 2*keepout,\ ifeq(silkbox_width, 0, {}, {x = min(silkbox_width, x)}),\ ifeq(silkbox_height,0, {}, {y = min(silkbox_height, y)})},\ {x = max(silkbox_width, padgap_x + 2*pad_height + 2*keepout),\ y = max(silkbox_height, padgap_y + 2*pad_height + 2*keepout)}\ ) silkbox(0, 0, x, y) # silk has a little diagonal line in top left corner silksegment(-x/2, y/2, -x/2 - 1mm, y/2 + 1mm) # add exposed pad pad_height = tab_height pad_width = tab_width ifeq(0, tab_height, {}, {array(0,0,num_pads+1,{})}) "done:QFP macro" scriptend() ############################################################################### # SO footprint macro # Makes an SO footprint with pin 1 in the upper left corner. Can be used # to make 2 pad elements (like 603's, 0805's, etc). Puts silk brackets # around the part and a little "V" at the top. If a 2 pad'ed device, # doesn't add the "V". ############################################################################### scriptstart("SO") # get input parameters # allow macro to be placed anywhere loadparams("x","y") move_origin(x,y) # set environment variables pad_shape = "rectangular" pad_type = "pad" # build the pads array( -(padgap_x + pad_width)/2, 0, {}, {1:num_pads/2}) array( (padgap_x + pad_width)/2, 0, {}, {num_pads:num_pads/2+1}) # draw the silkscreen mydefine("mywidth", padgap_x + 2 * pad_width) mydefine("myheight", (num_pads/2 - 1) * pitch_y + pad_height) silkbox_width = max(silkbox_width, mywidth + 2*keepout) silkbox_height = max(silkbox_height,myheight + 2*keepout) # change this function to silkbox_brackets() to make brackets silkbox(0,0,silkbox_width,silkbox_height) # silk has a little "v" centered at the top (if more than 2 pads) ifgt(num_pads, 2, \ {silksegment(0, silkbox_height/2 - 20mil, -20mil, silkbox_height/2), \ silksegment(0, silkbox_height/2 - 20mil, 20mil, silkbox_height/2)}, \ {} \ ) "done:SO macro" scriptend() "done: footprint_macros.inc"