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), ] 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' ] os=.05 pins = [Pin(-.4-os*(-1)**i,.75-.1*i,_pad,names[i]) for i in range(16)] pins += [Pin(.4-os*(-1)**i,-.75+.1*i,_pad,names[16+i]) for i in range(12)] 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)) ] 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) pins = [Pin(0,-(_e+_a)/2-.01,_pad,'-',label_size=.08),Pin(0,(_e+_a)/2+.01,_pad,'+',label_size=.08)] 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 pad = chamfered_rectangle(-.125,.125,-.12,.12,.05) 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 ADXL372Z(Component): names = ['VIO','NC','RES','SCLK','RES2','MOSI','MISO','CS','INT2','RES3','INT1','GND','GND2','VS','NC2','GND3'] p = .5/25.4 w = 2.5/25.4 h = 2.5/25.4 padhw = .125/25.4 pad1 = rectangle(-.7/25.4,.36/25.4,-padhw,padhw) pad2 = rectangle(-padhw,padhw,-.7/25.4,.4/25.4,) pad3 = rectangle(-.36/25.4,.7/25.4,-padhw,padhw) pad4 = rectangle(-padhw,padhw,-.4/25.4,.7/25.4,) pins = [Pin(-.5*w, p*(2-i),pad1,names[i],label_size=.01) for i in range(5)] pins += [Pin(p*(-1+i),-.5*h,pad2,names[i+5],label_size=.01,label_rot=90) for i in range(3)] pins += [Pin(.5*w, p*(-2+i),pad3,names[i+8],label_size=.01) for i in range(5)] pins += [Pin(p*(1-i),.5*h,pad4,names[i+13],label_size=.01,label_rot=90) for i in range(3)] vias = [] shadow = rectangle(-1.75/25.4, 1.75/25.4, -1.68/25.4, 1.68/25.4) class ADXL372Z_EVAL(Component): names = ['VS','VIO','GND','INT2','INT1','CS','MISO','MOSI','SCLK','GND2'] w = .3 pad = rectangle(-.05,.05,-.025,.025) 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)) ] vias = [Via(p.x,p.y,circle(0,0,.017)) for p in pins] 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,90) + rotate(holes,180) + rotate(holes,-90) holes = rotate(holes,45) pcb.custom_cutout = board-holes pcb.custom_cutout = filleted_rectangle(-.8,1.2,-.5,.5,.15) 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) f = feather(0.2,0,90) pcb += f #ADXL372 #adxl = ADXL372Z_EVAL(0,0,0,'adxl372') #pcb.custom_cutout = adxl.shadow #pcb += adxl adxl = ADXL372Z(0,0,90,'adxl372') pcb += adxl pcb.connectH(adxl['VIO'],[adxl['VS'].x-.05,adxl['VS'].y],adxl['VS'],width=.01) pcb.connectH(adxl['GND3'],[adxl['GND'].x+.0005,adxl['GND'].y],adxl['GND'],width=.009) pcb.connectH(adxl['GND2'],adxl['GND'],width=.01) pcb.connectH(adxl['NC'],[adxl['GND'].x+.0005,adxl['GND'].y],adxl['GND'],width=.009) pcb.connectD(adxl['SCLK'],[adxl['SCLK'].x,adxl['SCLK'].y-.06],[adxl['SCLK'].x+.05,adxl['SCLK'].y-.06],[f['SCK'].x-.05,f['SCK'].y+.2],f['SCK'],width=[.01,.01,.02,.02,.02,.02,.02,.02]) pcb.connectD(adxl['MOSI'],[adxl['MOSI'].x+.05,adxl['MOSI'].y],[f['MOSI'].x-.08,f['MOSI'].y+.16],f['MOSI'],width=[.01,.01,.02,.02,.02,.02]) pcb.connectD(adxl['MISO'],[adxl['MISO'].x+.1,adxl['MISO'].y],[f['MISO'].x-.15,f['MISO'].y+.32],f['MISO'],width=[.01,.01,.02,.02,.02,.02]) pcb.connectD(adxl['CS'],[adxl['CS'].x+.05,adxl['CS'].y],f['11'],width=[.01,.01,.02,.02]) pcb.connectD(adxl['INT2'],[adxl['INT2'].x,adxl['INT2'].y+.05],f['12'],width=[.01,.01,.02,.02]) pcb.connectD(adxl['INT1'],[adxl['INT1'].x,adxl['INT1'].y+.08],f['13'],width=[.01,.01,.02,.02]) pcb.connectD(f['3V3'],[f['3V3'].x,f['3V3'].y+.15],[adxl['VIO'].x-.07,adxl['VIO'].y],adxl['VIO'],width=[.02,.02,.02,.02,.02,.01]) pcb.connectD(f['GND'],[f['GND'].x,f['GND'].y+.2],[adxl['NC'].x,adxl['NC'].y-.06],adxl['NC'],width=[.02,.02,.02,.02,.01,.01,.01]) C1 = C_1206(adxl.x-.14,adxl.y-.07,90,'C1\n.1uF',label_size=.04) pcb += C1 C2 = C_1206(C1.x-.1,C1.y,90,'C2\n1uF',label_size=.04) pcb += C2 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']