4 # PCB, interactive printed circuit board design
5 # Copyright (C) 2003 Dan McMahill
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 # $6: pad pitch (1/100 mm)
31 # $7: PCB pad width (1/100 mm)
32 # $8: Package pad length (1/100 mm)
33 # $9: Exposed paddle size, 0 for no exposed paddle (1/100 mm)
35 define(`PKG_GENERIC_QFN',
37 # number of pins on left/right sides (pin1 is upper pin on left side)
38 define(`LRPINS', `eval($4 / 4)')
39 # number of pins on top/bottom sides
40 define(`TBPINS', `eval(`$4' / 2 - LRPINS)')
41 # pin pitch (1/1000 mil)
42 define(`PITCH',`eval(`$6'*100000/254)')
43 # y-coordinate for upper pin on left/right sides (1/1000 mil)
44 define(`LRYMAX', `eval((LRPINS-1)*PITCH/2)')
45 # x-coordinate for right pin on top/bottom sides (1/1000 mil)
46 define(`TBXMAX', `eval((TBPINS-1)*PITCH/2)')
47 # total horizontal package width (1/1000 mil)
48 define(`LRWIDTHMM', `ifelse(0,`$5',`787',`eval($5)')')
49 define(`LRWIDTH', `ifelse(0,`$5',`787',`eval(`$5'*10000000/254)')')
50 # total vertical package width (1/1000 mil)
51 define(`TBWIDTH',`ifelse(0,`$5',`551',`eval(`$5'*10000000/254)')')
52 # how much pads extend beyond the package edge (1/1000 mil) (the 25 is 0.25 mm)
53 define(`EXTOUT', eval(25*100000/254))
54 # how much pads extend inward from the package pad edge (1/1000 mil)
55 define(`EXTIN', eval(5*100000/254))
56 # pad length/width (1/1000 mil)
57 define(`PADLENGTH', `eval(`$8'*100000/254)')
58 define(`PADWIDTH', `eval(`$7'*100000/254)')
60 define(`PADWIDTHMIL100', `eval(PADWIDTH/10)')
61 # min/max x coordinates for the pads on the left/right sides of the package (mil/100)
62 define(`LRXMAX',`eval((LRWIDTH/2 + EXTOUT - PADWIDTH/2)/10)')
63 define(`LRXMIN',`eval((LRWIDTH/2 -PADLENGTH - EXTIN + PADWIDTH/2)/10)')
64 # min/max y coordinates for the pads on the top/bottom sides of the package (mil/100)
65 define(`TBYMAX',`eval((TBWIDTH/2 + EXTOUT - PADWIDTH/2)/10)')
66 define(`TBYMIN',`eval((TBWIDTH/2 -PADLENGTH - EXTIN + PADWIDTH/2)/10)')
68 # silkscreen width (mils/100)
70 # how much the silk screen is moved away from the package (1/1000 mil)
71 define(`SILKEXT', `eval(EXTOUT + SILKW*10/2 + 5*1000)')
72 # upper right corner for silk screen (mil/100)
73 define(`SILKX', `eval((LRWIDTH/2 + SILKEXT )/10)')
74 define(`SILKY', `eval((TBWIDTH/2 + SILKEXT )/10)')
75 # refdes text size (mil/100)
76 define(`TEXTSIZE', 100)
77 # x,y coordinates for refdes label (mil/100)
78 define(`TEXTX', -SILKX)
79 define(`TEXTY', `eval(-SILKY - 1000 - TEXTSIZE/2)')
80 # square exposed paddle size (mil/100)
81 define(`EPSIZE', `eval(`$9'*10000/254)')
83 # pad clearance to polygons (1/100 mil)
84 define(`PADCLEAR', `2000')
86 # width of the pad solder mask relief (1/100 mil).
87 # grow by 1.5 mils on each side
88 define(`PADMASK', `eval(2*150 + PADWIDTHMIL100)')
90 # width of the paddle soldermask relief (1/100 mil)
91 # grow by 200 mils on each side
92 define(`EPMASK', `eval(2*200 + EPSIZE)')
94 # element_flags, description, pcb-name, value, mark_x, mark_y,
95 # text_x, text_y, text_direction, text_scale, text_flags
96 Element[0x00000000 "$1" "`$2'" "$3" 0 0 TEXTX TEXTY 0 TEXTSIZE 0x00000000]
100 # Pad[X1, Y1, X2, Y3, width, clearance,
101 # soldermask, "pin name", "pin number", flags]
106 forloop(`i', 1, LRPINS,
107 `define(`Y', `eval((-LRYMAX + PITCH*idx)/10)')'
108 `Pad[-LRXMAX Y -LRXMIN Y PADWIDTHMIL100 PADCLEAR PADMASK "CURPIN" "CURPIN" 0x00000100]'
109 `define(`CURPIN', incr(CURPIN))'
110 `define(`idx',incr(idx))'
115 forloop(`i', 1, TBPINS,
116 `define(`X', `eval((-TBXMAX + PITCH*idx)/10)')'
117 `Pad[X TBYMAX X TBYMIN PADWIDTHMIL100 PADCLEAR PADMASK "CURPIN" "CURPIN" 0x00000900]'
118 `define(`CURPIN', incr(CURPIN))'
119 `define(`idx',incr(idx))'
124 forloop(`i', 1, LRPINS,
125 `define(`Y', `eval(( LRYMAX - PITCH*idx)/10)')'
126 `Pad[LRXMAX Y LRXMIN Y PADWIDTHMIL100 PADCLEAR PADMASK "CURPIN" "CURPIN" 0x00000100]'
127 `define(`CURPIN', incr(CURPIN))'
128 `define(`idx',incr(idx))'
133 forloop(`i', 1, TBPINS,
134 `define(`X', `eval((TBXMAX - PITCH*idx)/10)')'
135 `Pad[X -TBYMAX X -TBYMIN PADWIDTHMIL100 PADCLEAR PADMASK "CURPIN" "CURPIN" 0x00000900]'
136 `define(`CURPIN', incr(CURPIN))'
137 `define(`idx',incr(idx))'
140 # Exposed paddle (if this is an exposed paddle part)
141 ifelse(1, eval(EPSIZE>0),
142 # Pad(X1, Y1, X2, Y3, width, clearance,
143 # soldermask, "pin name", "pin number", flags)
144 Pad[0 0 0 0 EPSIZE 0 EPMASK "CURPIN" "CURPIN" 0x00000100]
145 define(`CURPIN', incr(CURPIN))
148 # Silk screen around package
149 ElementLine[ SILKX SILKY SILKX -SILKY SILKW]
150 ElementLine[ SILKX -SILKY -SILKX -SILKY SILKW]
151 ElementLine[-SILKX -SILKY -SILKX SILKY SILKW]
152 ElementLine[-SILKX SILKY SILKX SILKY SILKW]
155 ElementLine[-SILKX -SILKY eval(-SILKX - 1500) eval(-SILKY - 1500) SILKW]
159 # -------------------------------------------------------------------
161 # The following macros take:
167 # $6: exposed paddle size (1/100 mm). 0 for no exposed paddle
170 # For an exposed paddle package, the paddle for an 'n' pin package is pin 'n+1'
173 define(`PKG_QFN_80', `PKG_GENERIC_QFN(`$1',`$2',`$3',`$4',`$5', `80',`42',`60', `$6')')
175 define(`PKG_QFN_65', `PKG_GENERIC_QFN(`$1',`$2',`$3',`$4',`$5', `65',`37',`60', `$6')')
176 # 0.50 mm pitch, 0.6 mm pad length
177 define(`PKG_QFN_50', `PKG_GENERIC_QFN(`$1',`$2',`$3',`$4',`$5', `50',`28',`60', `$6')')
178 # 0.50 mm pitch, 0.4 mm pad length
179 define(`PKG_QFN_50S',`PKG_GENERIC_QFN(`$1',`$2',`$3',`$4',`$5', `50',`28',`40', `$6')')
181 define(`PKG_QFN_40', `PKG_GENERIC_QFN(`$1',`$2',`$3',`$4',`$5', `40',`25',`60', `$6')')
190 # $6: pad pitch (1/100 mm)
191 # $7: PCB pad width (1/100 mm)
192 # $8: Package pad length (1/100 mm)
193 # $9: Exposed paddle size, 0 for no exposed paddle (1/100 mm)
194 # -------------------------------------------------------------------