b9baf242c294ff025b8941fc8b788472154b42bf
[hw/altusmetrum] / packages / te-connectivity / micromatch-smt-v.py
1 #!/usr/bin/python2
2 # Copyright 2015 by Bdale Garbee <bdale@gag.com>.  GPLv2
3 #
4 # Program to emit PCB footprint for
5 #   Tyco/AMP Micro-MaTch vertical surface-mount female connectors
6 #
7 # Needs pin count on command line, in range of 4..20 even numbers only
8 #
9
10 # dimensions in mm from ENG_CD_188275_S3_c-188275_drw.pdf
11 PadWidth = 1.50
12 PadHeight = 3.00
13 PadSpacing = 1.27
14 RowGap = 1.50           # space between rows
15
16 Clearance = 0.006       # in mils
17
18 BoxY = 5.2
19 BoxXbase = 4.55
20 BoxXstep = 2.55
21
22 LineWidth = 600
23
24 import sys
25
26 # we're going to use the 1/100 of a mil fundamental unit form
27 def mm2mils100( mm ):
28         return int( mm / 25.4 * 1000.0 * 100.0 + 0.5 )
29
30 pins = int(sys.argv[1])
31
32 if pins < 4:
33         sys.stderr.write('Must be at least 4 pins\n')
34         sys.exit(1)
35 if pins > 20:
36         sys.stderr.write('Must be no more than 20 pins\n')
37         sys.exit(1)
38
39 if len(sys.argv) > 2:
40     if sys.argv[2] == "latch":
41         BoxXbase = 7.15
42
43 BoxXOffset = -((pins - 1) * PadSpacing)/2
44
45 print '# author: Bdale Garbee'
46 print '# email: bdale@gag.com'
47 print '# dist-license: GPL 2'
48 print '# use-license: unlimited'
49
50 print 'Element[0x0 "MicroMatch%i"' % pins,'"" "" 0 0 0 0 0 100 0x0]'
51 print "("
52 for col in range ((pins+1)/2):
53     for row in range (2):
54         if row == 1:
55             origin= (RowGap + PadHeight)/2
56         else:
57             origin= -(RowGap + PadHeight)/2
58         pinnum = (col * 2) + row + 1
59         Flags = '"square,nopaste"'
60
61         print '   Pad[', \
62             mm2mils100((pinnum-1)*PadSpacing + BoxXOffset), \
63             mm2mils100(origin + PadHeight/2 - PadWidth/2), \
64             mm2mils100((pinnum-1)*PadSpacing + BoxXOffset), \
65             mm2mils100(origin - PadHeight/2 + PadWidth/2), \
66             mm2mils100(PadWidth), \
67             0, \
68             mm2mils100(PadWidth)+Clearance*2, \
69             '"pin%i"' % pinnum, '"%i"' % pinnum, Flags, ']'
70             
71 BoxX = BoxXbase + pins/2 * BoxXstep
72 BoxX1 = -BoxX/2
73 BoxX2 = BoxX/2
74 BoxY1 = -BoxY/2
75 BoxY2 = BoxY/2
76
77 print '   ElementLine[', \
78         mm2mils100(BoxX1), \
79         mm2mils100(BoxY1), \
80         mm2mils100(BoxX1), \
81         mm2mils100(BoxY2), \
82         LineWidth, ']'
83
84 print '   ElementLine[', \
85         mm2mils100(BoxX1), \
86         mm2mils100(BoxY2), \
87         mm2mils100(BoxX2), \
88         mm2mils100(BoxY2), \
89         LineWidth, ']'
90
91 print '   ElementLine[', \
92         mm2mils100(BoxX2), \
93         mm2mils100(BoxY2), \
94         mm2mils100(BoxX2), \
95         mm2mils100(BoxY1), \
96         LineWidth, ']'
97
98 print '   ElementLine[', \
99         mm2mils100(BoxX2), \
100         mm2mils100(BoxY1), \
101         mm2mils100(BoxX1), \
102         mm2mils100(BoxY1), \
103         LineWidth, ']'
104   
105 print ")"