impact-logger.ko 12 KB
Newer Older
Sam Calisch's avatar
Sam Calisch committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from koko.lib.pcb import *
from koko.lib.sam import *

class TagConnectPDI(Component):
    '''
    '''
    _pad = s2d.circle(0,0,.5*.031)
    _via = s2d.circle(0,0,.5*.039)
    pins = [
        Pin(-.05,-.025,_pad,'CLK',label_size=.02),
        Pin( .00,-.025,_pad,'NC',label_size=.02),
        Pin( .05,-.025,_pad,'DAT',label_size=.02),
        Pin(-.05,.025,_pad,'VCC',label_size=.02),
        Pin( .00,.025,_pad,'NC',label_size=.02),
        Pin( .05,.025,_pad,'GND',label_size=.02)
    ]
    vias = [
        Via(-.1,0,_via),
        Via(.1,0.04,_via),
        Via(.1,-.04,_via),

    ]

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

class feather(Component):
    _pad = rectangle(-.05,.05,-.03,.03)
    names = [
                'RST','3V3','VREFA','GND','A0','A1','A2','A3','A4','A5','SCK','MOSI','MISO','RXD0','TXD0','GND2'
                'SDA','SCL','5','6','9','10','11','12','13','VBUS','EN','VBAT'
            ]
    pins = [Pin(-.4,.75-.1*i,_pad,names[i]) for i in range(16)]
    pins += [Pin(.4,-.75+.1*i,_pad,names[16+i]) for i in range(11)]
    shadow = filleted_rectangle(-.45,.45,-1,1,.08)
    vias = [
        Via(-.35, .9,circle(0,0,.05)),
        Via( .35, .9,circle(0,0,.05)),
        Via(-.35,-.9,circle(0,0,.05)),
        Via( .35,-.9,circle(0,0,.05))
        ]

Sam Calisch's avatar
Sam Calisch committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def bot_chamfered_rectangle(x0,x1,y0,y1,c):
    r = rectangle(x0,x1,y0,y1)
    c1 = triangle(x0,y0,x0,y0+c,x0+c,y0)
    c2 = triangle(x1,y1, x1, y1-c, x1-c, y1)
    c3 = triangle(x0,y1, x0+c, y1, x0, y1-c)
    c4 = triangle(x1,y0, x1-c, y0, x1, y0+c)
    return r-c2-c3

class cap_UWT(Component):
    '''UWT series aluminum smd cap
    http://nichicon-us.com/english/products/pdfs/e-uwt.pdf
    '''
    _d = 8 #mm, diameter
    _h = 10.5 #mm, height
    _a = 2.9/25.4
    _e = 3.1/25.4
    _h = 1./25.4 + 2/25.4
    _pad = rectangle(-_h/2,_h/2,-_a/2-.03,_a/2+.03)
59
    pins = [Pin(0,-(_e+_a)/2-.01,_pad,'-',label_size=.08),Pin(0,(_e+_a)/2+.01,_pad,'+',label_size=.08)]
Sam Calisch's avatar
Sam Calisch committed
60
61
62
63
64
65
66
67
68
69
70
71
72
    vias = []
    shadow = bot_chamfered_rectangle(-4/25.4,4/25.4,-4/25.4,4/25.4,1/25.4)

class CR20XX(Component):
    #coin cell battery, e.g. 2032
    pins = [
        Pin(0,0,circle(0,0,5./25.4),'-')
    ]
    shadow = circle(0,0,10./25.4)
    vias = []

class AAA(Component):
    #AAA battery smd holder
73
    pad = chamfered_rectangle(-.125,.125,-.12,.12,.05)
Sam Calisch's avatar
Sam Calisch committed
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
    pins = [
        Pin(1.21-.125,0,pad,'+',label_size=.08),
        Pin(-1.21+.125,0,pad,'-',label_size=.08),
    ]
    shadow = rectangle(-1.07,1.07,-.25,.25)
    vias = [
        Via(-1.21+.25,.209,circle(0,0,.039))
    ]

class ATxmegaE5(Component):
    _padh = chamfered_rectangle(-.025,.025,-.007,.007,.002)
    _padv = chamfered_rectangle(-.007,.007,-.025,.025,.002)
    c=.18
    d = 0.8/25.4
    names = [
        '1 GND','PA4','PA3','PA2','PA1','PA0','PDI/DATA','RST/CLK',
        'PC7','PC6','PC5','PC4','PC3','PC2','PC1','PC0',
        'VCC','GND','PR1','PR0','PD7','PD6','PD5','PD4',
        'PD3','PD2','PD1','PD0','PA7','PA6','PA5','AVCC'
    ]
    pins = [Pin(-c,(3.5-i)*d,_padh,n,label_size=.025) for i,n in enumerate(names[:8])]
    pins += [Pin((-3.5+i)*d,-c,_padv,n,label_size=.025,label_rot=-90) for i,n in enumerate(names[8:16])]
    pins += [Pin(c,(-3.5+i)*d,_padh,n,label_size=.025) for i,n in enumerate(names[16:24])]
    pins += [Pin((3.5-i)*d,c,_padv,n,label_size=.025,label_rot=-90) for i,n in enumerate(names[24:])]
    vias = []
    shadow = rectangle(-c+d,c-d,-c+d,c-d)

class ATxmega16A4U(Component):
    _padh = chamfered_rectangle(-.024,.024,-.007,.007,.003)
    _padv = chamfered_rectangle(-.007,.007,-.024,.024,.003)
    c= 11/25.4/2.
    d = 0.8/25.4
    names = [
        'PA5','PA6','PA7','PB0','PB1','PB2','PB3','GND','VCC','PC0','PC1',
        'PC2','PC3','PC4','PC5','PC6','PC7','GND2','VCC2','PD0','PD1','PD2',
        'PD3','PD4','PD5','PD6','PD7','PE0','PE1','GND3','VCC3','PE2','PE3',
        'PDI/DATA','RST/CLK','PR0','PR1','GND4','AVCC','PA0','PA1','PA2','PA3','PA4'
    ]
    n_side = 11
    pins = [Pin(-c,(5-i)*d,_padh,n,label_size=.025) for i,n in enumerate(names[:n_side])]
    pins += [Pin((-5+i)*d,-c,_padv,n,label_size=.025,label_rot=-90) for i,n in enumerate(names[n_side:2*n_side])]
    pins += [Pin(c,(-5+i)*d,_padh,n,label_size=.025) for i,n in enumerate(names[2*n_side:3*n_side])]
    pins += [Pin((5-i)*d,c,_padv,n,label_size=.025,label_rot=-90) for i,n in enumerate(names[3*n_side:])]
    vias = []
    shadow = rectangle(-c+d,c-d,-c+d,c-d)

class ADXL372Z_EVAL(Component):
121
    names = ['VS','VIO','GND','INT2','INT1','CS','MISO','MOSI','SCLK','GND2']
Sam Calisch's avatar
Sam Calisch committed
122
    w = .3
123
    pad = rectangle(-.05,.05,-.025,.025)
Sam Calisch's avatar
Sam Calisch committed
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
    pins = [Pin(-.5*w, .2-.1*i,pad,names[i]) for i in range(5)]
    pins += [Pin(.5*w,-.2+.1*i,pad,names[i+5]) for i in range(5)]
    vias = [
        Via(7.5/25.4,7.5/25.4,circle(0,0,.055)),
        Via(-7.5/25.4,7.5/25.4,circle(0,0,.055)),
        Via(7.5/25.4,-7.5/25.4,circle(0,0,.055)),
        Via(-7.5/25.4,-7.5/25.4,circle(0,0,.055))
    ]
    shadow = filleted_rectangle(-.405,.405,-.405,.405,.05)

class micro_sd_card(Component):
    #molex WM12834CT-ND
    names = ['X','CS','DI','VDD','CLK','VSS','DO','X']
    pad = rectangle(-.62/25.4,.62/25.4,-.4/25.4,.4/25.4)
    pitch = 1.1/25.4
    pins = [ Pin(.62/25.4, 4.82/25.4+pitch*i, pad,names[i],label_size=.02) for i in range(8) ]
    pins += [
        Pin( 1.24/25.4,.48/25.4,rectangle(-1.25/25.4,1.25/25.4,-.48/25.4,.48/25.4)),
        Pin( 1.1/25.4,14.84/25.4,rectangle(-1.1/25.4,1.1/25.4,-.6/25.4,.6/25.4)),
        Pin(12.58/25.4,.58/25.4, rectangle(-1.1/25.4,1.1/25.4,-.58/25.4,.58/25.4)),
        Pin(13.95/25.4-.62/25.4,4.88/25.4,rectangle(-.55/25.4,.55/25.4,-.75/25.4,.75/25.4)),
        Pin(13.95/25.4-.62/25.4,12.66/25.4,rectangle(-.55/25.4,.55/25.4,-.75/25.4,.75/25.4))
    ]
    vias = []
    w = 13.95/25.4; h = 15.44/25.4
    shadow = rectangle(-1.25/25.4,  w, 0., h)
    pins = [Pin(p.x-.5*w,p.y-.5*h,p.shape,p.name) for p in pins]
    shadow = move(shadow,-.5*w,-.5*h)


class Hole(Component):
    pins = [Pin(0,0,circle(0,0,0.01))]
    vias = [Via(0,0,circle(0,0,.5*2.1/25.4))]
    tap = circle(0,0,.5*1.9/25.5)


width = 1.5
height = 1.
pcb = PCB(0,0,width,height,chamfer_distance=.05)

board = circle(0,0,1.5)
holes = circle(0,1.5-.25,2.1/25.4)
holes += rotate(holes,120) + rotate(holes,-120)
pcb.custom_cutout = board-holes


def connectG(pin,dx,dy,width=.014):
    '''
    Convenience function for connecting to ground plane
    '''
    pcb.connectD(pin,[pin.x+dx,pin.y+dy],[pin.x+dx-.0001,pin.y+dy],width=width,sides=[0,1,1])
def connectS(pin,dx,dy,width=.014):
    pcb.connectD(pin,[pin.x+dx+.0001,pin.y+dy],width=width)
def connectM(pin1,pin2,dx,width=.014):
    pcb.connectD(pin1,[pin1.x+dx,pin1.y],pin2,width=width)

#pcb.custom_cutout = chamfered_rectangle(0,width,.5*height-.25,.5*height+.25,.05)
#pcb.custom_cutout += chamfered_rectangle(0,.6*width,0,height,.12)


184
185
186
f = feather(2,0,0,'feather')
pcb += f

Sam Calisch's avatar
Sam Calisch committed
187
188
189
xmega = ATxmega16A4U(-1.2,-.0,0,'Xmega\nA4U')
pcb += xmega

190
pdi = TagConnectPDI(xmega.x+.11,xmega.y+.4,0)
Sam Calisch's avatar
Sam Calisch committed
191
192
193
194
195
196
197
198
199
200
201
202
203
pcb += pdi


pcb.connectV(xmega['RST/CLK'],[pdi['CLK'].x,pdi['CLK'].y-.05],pdi['CLK'],width=.014)

#connectG(xmega['1 GND'],-.03,.05)
#connectG(xmega['GND'],.07,.05)

pcb.connectD(xmega['PDI/DATA'],pdi['DAT'],width=.014)


R1 = R_0805(pdi.x-.18,pdi.y,90,'R1\n10k',label_size=.03)
pcb += R1
204
C1 = C_0805(R1.x+.04,R1.y+.1,0,'C1 1uF',label_size=.03)
Sam Calisch's avatar
Sam Calisch committed
205
pcb += C1
206
C2 = C_0805(C1.x,C1.y+.07,0,'C2 .1uF',label_size=.03)
Sam Calisch's avatar
Sam Calisch committed
207
208
209
210
pcb += C2
#pcb.connectD(xmega['1 GND'],[xmega['1 GND'].x-.03,xmega['1 GND'].y-.04],[C2[0].x-.14,C2[0].y+.1],C2[0],width=.014)


211
212
213
214
215
pcb.connectD(pdi['GND'],[pdi['GND'].x,pdi['GND'].y+.05],C1[0])
pcb.connectD(pdi['GND'],[pdi['GND'].x,pdi['GND'].y+.05],C2[0])
pcb.connectV(C2[0],C1[0])
pcb.connectV(C2[1],C1[1])
pcb.connectV(R1[0],C1[1])
Sam Calisch's avatar
Sam Calisch committed
216
217
218
219
#pcb.connectH(pdi['GND'],C2[0])
#pcb.connectV(pdi['VCC'],C1[1])
#pcb.connectV(pdi['VCC'],C2[1])

220
pcb.connectH(xmega['RST/CLK'],[xmega['RST/CLK'].x,xmega['RST/CLK'].y+.11],R1[1],width=.014)
Sam Calisch's avatar
Sam Calisch committed
221
222
223
224
225
226
227
228
pcb.connectD(pdi['VCC'],[pdi['VCC'].x-.03,pdi['VCC'].y+.01],R1[0],width=.014)
#pcb.connectD(xmega['AVCC'],[xmega['AVCC'].x+.188,xmega['AVCC'].y-.1],xmega['PC5'],R1[0],width=.014)

#pcb.connectD(xmega['VCC'],[xmega.x-.105,xmega.y-.05],xmega['AVCC'],width=.014)



#SPI to microsd card
229
sd = micro_sd_card(0,-1.,-90,'MICRO SD')
Sam Calisch's avatar
Sam Calisch committed
230
231
pcb += sd

232
233
234
235
236
237
238

pcb.connectD(xmega['PC4'],[xmega['PC4'].x,xmega['PC4'].y-.18],[xmega['PC4'].x+.3,xmega['PC4'].y-.25],[sd['CS'].x,sd['CS'].y+.05],sd['CS'],width=.014)
pcb.connectD(xmega['PC5'],[xmega['PC5'].x,xmega['PC5'].y-.15],[xmega['PC5'].x+.3,xmega['PC5'].y-.2],[sd['DI'].x,sd['DI'].y+.1],sd['DI'],width=.014)
pcb.connectD(xmega['PC6'],[xmega['PC6'].x,xmega['PC6'].y-.12],[xmega['PC6'].x+.3,xmega['PC6'].y-.15],[sd['DO'].x,sd['DO'].y+.17],sd['DO'],width=.014).add_jumper([sd['CLK'].x, sd['CLK'].y+.18],0)
pcb.connectD(xmega['PC7'],[xmega['PC7'].x,xmega['PC7'].y-.09],[xmega['PC7'].x+.3,xmega['PC7'].y-.11],[sd['CLK'].x,sd['CLK'].y+.25],sd['CLK'],width=.014)


Sam Calisch's avatar
Sam Calisch committed
239
240
241
242
#ADXL372
adxl = ADXL372Z_EVAL(0,0,180,'adxl372')
pcb += adxl

243
244
245
246
pcb.connectD(xmega['PD4'],[xmega['PD4'].x+.18,xmega['PD4'].y],[adxl['CS'].x+.1,adxl['MOSI'].y-.05],[adxl['CS'].x+.1,adxl['CS'].y-.03],adxl['CS'],width=.014)
pcb.connectD(xmega['PD5'],[xmega['PD5'].x+.16,xmega['PD5'].y],adxl['MOSI'],width=.014)
pcb.connectD(xmega['PD6'],[xmega['PD6'].x+.14,xmega['PD6'].y],adxl['MISO'],width=.014)
#pcb.connectD(xmega['PD7'],[xmega['PD7'].x+.08,xmega['PD7'].y],adxl['SCLK'],width=.014)
Sam Calisch's avatar
Sam Calisch committed
247

248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
pcb.connectD(xmega['PD7'],[xmega['PD7'].x+.12,xmega['PD7'].y],[adxl['SCLK'].x+.05,adxl['SCLK'].y+.47],[adxl['SCLK'].x+.15,adxl['SCLK'].y],adxl['SCLK'],width=.014)
pcb.connectD(xmega['PE0'],[xmega['PE0'].x+.08,xmega['PE0'].y],[adxl['INT2'].x-.25,adxl['INT2'].y+.33],[adxl['INT2'].x-.1,adxl['INT2'].y+.05],adxl['INT2'],width=.014)
pcb.connectD(xmega['PE1'],[xmega['PE1'].x+.06,xmega['PE1'].y],[adxl['INT1'].x-.25,adxl['INT1'].y+.3],[adxl['INT1'].x-.05,adxl['INT1'].y+.05],adxl['INT1'],width=.014)


#pcb.connectD(adxl['GND2'],[adxl['GND2'].x-.1,adxl['GND2'].y],xmega['PD3'],width=.014)
#pcb.connectV(xmega['GND2'],xmega['PD3'],width=.014)
pcb.connectV(xmega['GND2'],xmega['GND3'],width=.014)

#pcb.connectD(xmega['GND4'],[xmega['GND4'].x,xmega['GND4'].y-.01],[xmega['GND3'].x+.1,xmega['GND3'].y+.2],[xmega['GND3'].x+.07,xmega['GND3'].y],xmega['GND3'],width=.014)
pcb.connectD(xmega['GND3'],[xmega['GND3'].x+.04,xmega['GND3'].y],[xmega['GND3'].x+.06,xmega['GND3'].y+.12],[xmega['GND3'].x+.0,xmega['GND3'].y+.15], [xmega['GND4'].x+.02,xmega['GND4'].y-.08], xmega['GND4'],width=.014)
pcb.connectD(xmega['GND3'],[xmega['GND3'].x+.04,xmega['GND3'].y],[xmega['GND3'].x+.06,xmega['GND3'].y+.12],[pdi['GND'].x+.1,pdi['GND'].y+.04],[pdi['GND'].x+.01,pdi['GND'].y+.05],pdi['GND'],width=.014)



pcb.connectV(xmega['AVCC'],xmega['VCC3'],width=.014)
pcb.connectV(xmega['AVCC'],[C2[1].x-.05,xmega['AVCC'].y+.08],C2[1],width=.014)

pcb.connectD(adxl['GND2'],[adxl['GND2'].x+.1,adxl['GND2'].y],sd['VSS'])
Sam Calisch's avatar
Sam Calisch committed
267
268
269
270
271
272


#battery
#batt = CR20XX(xmega.x,xmega.y-.5,0,"CR2032")
#pcb += batt

273
batt1 = AAA(-.6,0,90,'AAA1')
Sam Calisch's avatar
Sam Calisch committed
274
pcb += batt1
275
batt2 = AAA(.6,0,-90,'AAA2')
Sam Calisch's avatar
Sam Calisch committed
276
277
278
279
280
281
pcb += batt2

C_batt = cap_UWT(0,.8,90,'100uF')
pcb += C_batt
pcb.connectD(C_batt['+'],batt1['+'],width=.05)
pcb.connectD(C_batt['-'],batt2['-'],width=.05)
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
pcb.connectD(batt1['-'],[batt1['-'].x+.5,batt1['-'].y-.3],[batt2['+'].x-.4,batt2['+'].y-.3],batt2['+'],width=.04)


pcb.connectD(batt1['+'],[C2[1].x+.05,C2[1].y+.1],C2[1],width=.02)

#C_batt_2 = C_1206(C_batt.x,C_batt.y-.25,0,'.1uF')
#pcb += C_batt_2
#pcb.connectV(C_batt[0],C_batt_2[1])
#pcb.connectV(C_batt[1],C_batt_2[0])

pcb.connectD(adxl['GND'],[adxl['GND'].x+.1,adxl['GND'].y],batt2['-'],width=.03)
pcb.connectV(adxl['VIO'],adxl['VS'],width=.02)

#pcb.connectD(adxl['VIO'],[adxl['VIO'].x-.1,adxl['VIO'].y],[adxl['VIO'].x-.1,C_batt.y-.5], C_batt['+'])
#pcb.connectD(adxl['VS'],[adxl['VS'].x-.1,adxl['VS'].y],[adxl['VS'].x-.1,C_batt.y-.5], C_batt['+'])
#pcb.connectD(adxl['GND'],[adxl['GND'].x+.1,adxl['GND'].y-.0],[adxl['GND'].x+.1,adxl.y-.22],[adxl['GND2'].x+.1,adxl.y-.3],adxl['GND2'])
pcb.connectH(adxl['GND'],[adxl.x+.05,adxl['GND2'].y],adxl['GND2'],width=.02)

pcb.connectD(xmega['GND3'],[xmega['GND3'].x+.04,xmega['GND3'].y],[C_batt['-'].x-.1,C_batt['-'].y-.2],C_batt['-'],width=.014)


Sam Calisch's avatar
Sam Calisch committed
303
304
305
306
307
308
309
310
311
312

#soldering tails




cad.shapes = pcb.layout()
#cad.shape = pcb.traces+(pcb.cutout-pcb.cutout)
#cad.shape = pcb.cutout+(pcb.traces-pcb.traces)
#cad.shape = pcb.custom_layers['wj']['layer']