000e024ecce117b42a69843a72d6a064dbd5f59e
[hw/bdale] / pkg / newlib / tyco / micromatch-th-v.py
1 #!/usr/bin/python
2 # Copyright 2009 by Bdale Garbee <bdale@gag.com>.  GPLv2
3 #
4 # Program to emit PCB footprint for
5 #   Tyco/AMP Micro-MaTch vertical through-hole 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 C_215079_v.pdf datasheet
11 PinDiam = 0.8
12 PinSpacing = 1.27
13 RowSpacing = 2.54
14
15 MntX = 1.4
16 MntY = 1.8
17 MntDiam = 1.5
18
19 BoxY = 5.1
20 BoxXbase = 4.79
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 == 22:
36         sys.stderr.write('There is no 22 pin version!\n')
37         sys.exit(1)
38 if pins > 24:
39         sys.stderr.write('Must be no more than 24 pins\n')
40         sys.exit(1)
41
42 if len(sys.argv) > 2:
43     if sys.argv[2] == "latch":
44         BoxXbase = 5.89
45         if pins == 24:
46                 sys.stderr.write('There is no 24 pin latching version!\n')
47                 sys.exit(1)
48
49 print '# author: Bdale Garbee'
50 print '# email: bdale@gag.com'
51 print '# dist-license: GPL 2'
52 print '# use-license: unlimited'
53
54 print 'Element[0x0 "MicroMatch%i"' % pins,'"" "" 0 0 0 0 0 100 0x0]'
55 print "("
56 for col in range ((pins+1)/2):
57     for row in range (2):
58         if row == 1:
59             spacing=0
60         else:
61             spacing=RowSpacing
62         pinnum = (col * 2) + row + 1
63         if pinnum == 1:
64             Flags = '0x0101'
65         else:
66             Flags = '0x0001'
67         print '   Pin[', \
68             mm2mils100((pinnum-1)*PinSpacing), \
69             mm2mils100(spacing), \
70             mm2mils100(PinDiam*2), \
71             600, \
72             mm2mils100(PinDiam*2)+1000, \
73             mm2mils100(PinDiam), \
74             '"pin%i"' % pinnum, '"%i"' % pinnum, Flags, ']'
75
76 print '   Pin[', \
77     mm2mils100(-MntX), \
78     mm2mils100(RowSpacing-MntY), \
79     mm2mils100(MntDiam), \
80     2000, \
81     mm2mils100(MntDiam), \
82     mm2mils100(MntDiam), \
83     '"mnt" "0"', '0x0008', ']'
84
85 BoxX = (pins - 1) * PinSpacing + BoxXbase
86 BoxX1 = -(BoxXbase/2)
87 BoxX2 = BoxX1 + BoxX
88 BoxY1 = -(BoxY - RowSpacing)/2
89 BoxY2 = BoxY1 + BoxY
90
91 print '   ElementLine[', \
92         mm2mils100(BoxX1), \
93         mm2mils100(BoxY1), \
94         mm2mils100(BoxX1), \
95         mm2mils100(BoxY2), \
96         LineWidth, ']'
97
98 print '   ElementLine[', \
99         mm2mils100(BoxX1), \
100         mm2mils100(BoxY2), \
101         mm2mils100(BoxX2), \
102         mm2mils100(BoxY2), \
103         LineWidth, ']'
104
105 print '   ElementLine[', \
106         mm2mils100(BoxX2), \
107         mm2mils100(BoxY2), \
108         mm2mils100(BoxX2), \
109         mm2mils100(BoxY1), \
110         LineWidth, ']'
111
112 print '   ElementLine[', \
113         mm2mils100(BoxX2), \
114         mm2mils100(BoxY1), \
115         mm2mils100(BoxX1), \
116         mm2mils100(BoxY1), \
117         LineWidth, ']'
118   
119 print ")"