-
Notifications
You must be signed in to change notification settings - Fork 17
/
pihat.py
148 lines (127 loc) · 3.33 KB
/
pihat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import cuflow as cu
import dip
import sot
__VERSION__ = "1.0.0"
"""
RPi dimensions:
https://www.raspberrypi.org/documentation/hardware/raspberrypi/mechanical/rpi_MECH_4b_4p0.pdf
| GPIO | pin | color | function |
| ---- | --- | ------ | ------------------- |
| 14 | 8 | yellow | C2C: RESET |
| 17 | 11 | green | C2D: C2D |
| 18 | 12 | yellow | VS: VCC sense |
| 12 | 32 | blue | 1K: 1khz reference |
| 6 | 31 | | relay control |
1 3v3 Power
2 5v Power
3 BCM 2 (SDA)
4 5v Power
5 BCM 3 (SCL)
6 Ground
7 BCM 4 (GPCLK0)
8 BCM 14 (TXD)
9 Ground
10 BCM 15 (RXD)
11 BCM 17
12 BCM 18 (PWM0)
13 BCM 27
14 Ground
15 BCM 22
16 BCM 23
17 3v3 Power
18 BCM 24
19 BCM 10 (MOSI)
20 Ground
21 BCM 9 (MISO)
22 BCM 25
23 BCM 11 (SCLK)
24 BCM 8 (CE0)
25 Ground
26 BCM 7 (CE1)
27 BCM 0 (ID_SD)
28 BCM 1 (ID_SC)
29 BCM 5
30 Ground
31 BCM 6
32 BCM 12 (PWM0)
33 BCM 13 (PWM1)
34 Ground
35 BCM 19 (MISO)
36 BCM 16
37 BCM 26
38 BCM 20 (MOSI)
39 Ground
40 BCM 21 (SCLK)
"""
def thermal(t, layer, d = 1.3):
t.setname(layer).thermal(d).wire(layer = layer)
if __name__ == "__main__":
brd = cu.Board(
(65, 56),
trace = 0.2,
space = cu.inches(1 / 20) - 0.2,
via_hole = 0.3,
via = 0.6,
via_space = cu.mil(5),
silk = cu.mil(6))
WW = 0.6 # wide wire width
dc = brd.DC((3.5 + 29, 56 - 3.5)).left(90)
j1 = dip.HDR40(dc)
for pin in "6 9 14 20 25 30 34 39".split():
thermal(j1.s(pin), "GBL")
for pin in "2 4".split():
thermal(j1.s(pin), "GTL")
route = (8, 12, 11, 32)
tt = [j1.s(str(i)) for i in route]
for t in tt:
pn = int(t.name)
if (pn % 2) == 0:
t.left(45).forward(cu.inches(.0707)).left(45)
else:
t.left(90)
t.forward(2)
cu.extend2(tt)
rv1 = brd.enriver90(tt, 90)
rv1.w("l 90")
rv1.wire()
j2 = dip.Screw2(brd.DC((60, 42)).left(90))
thermal(j2.s("1"), "GBL", 2)
thermal(j2.s("2"), "GTL", 2)
k1 = dip.ReedRelay(brd.DC((40, 36)).left(90))
thermal(k1.pads[1], "GTL")
r1 = dip.Res10W(brd.DC((34, 25)))
k1.pads[0].left(90).setwidth(WW).setlayer("GBL").goto(r1.pads[0]).wire()
rv = rv1
rv.w("f 3 l 90")
p = k1.pads[2].copy()
p.w("l 90 f 4.5 l 180")
t1 = sot.SOT23(p)
t1.s("2").w("r 90 f 1 .")
t1.s("3").goto(k1.pads[2]).wire()
p.w("l 90 f 4 l 90")
r = cu.R0402(p, "2K3")
r.pads[0].goto(t1.s("1")).wire()
p = r.pads[1]
p.w("o")
j1.s("31").left(90).goto(p).wire()
for x in (0, 58):
for y in (0, 49):
brd.hole((3.5 + x, 3.5 + y), 2.7, 6)
j3 = dip.Hdr_1_7(brd.DC((46, 5)).left(90))
for p,lbl in zip(j3.pads, ('GND', 'C2C', 'C2D', 'VS', '1K', 'L-', 'L+')):
for a in (-90, 90):
p.copy().right(a).forward(3.5).text(lbl)
thermal(j3.pads[0], "GBL")
[p.w("l 90 f 5") for p in j3.pads[1:]]
[p.setwidth(WW).forward(6) for p in j3.pads[-2:]]
rv3 = brd.enriver90(j3.pads[4:0:-1], -90)
rv.meet(rv3.wire())
j3.pads[5].goto(k1.pads[3]).wire()
j3.pads[6].goto(r1.pads[1]).wire()
brd.outline()
if 1:
brd.space = cu.mil(12) # XXX hack the
brd.fill_any("GTL", "GTL")
brd.fill_any("GBL", "GBL")
brd.save("pihat")
brd.postscript("pihat.ps")