Commit ea0a4fb6 authored by Sam Calisch's avatar Sam Calisch

added pcb draft

parents
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),
]
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,'-'),Pin(0,(_e+_a)/2+.01,_pad,'+')]
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 = rectangle(-.125,.125,-.1,.1)
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):
names = ['VS','VIO','GND','INT2','INT1','CS','MISO','MOSI','SCLK','GND']
w = .3
pad = rectangle(-.05,.05,-.03,.03)
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)
xmega = ATxmega16A4U(-1.2,-.0,0,'Xmega\nA4U')
pcb += xmega
pdi = TagConnectPDI(xmega.x+.11,xmega.y+.35,0)
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
C1 = C_0805(R1.x-.07,R1.y,90,'C1\n1uF',label_size=.03)
pcb += C1
C2 = C_0805(C1.x-.07,C1.y,90,'C2\n.1uF',label_size=.03)
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)
pcb.connectD(pdi['GND'],[pdi['GND'].x,pdi['GND'].y+.05],[C1[0].x+.02,C1[0].y+.05],C1[0])
pcb.connectD(pdi['GND'],[pdi['GND'].x,pdi['GND'].y+.05],[C2[0].x+.02,C2[0].y+.05],C2[0])
#pcb.connectH(pdi['GND'],C2[0])
#pcb.connectV(pdi['VCC'],C1[1])
#pcb.connectV(pdi['VCC'],C2[1])
pcb.connectH(xmega['RST/CLK'],[xmega['RST/CLK'].x,xmega['RST/CLK'].y+.06],R1[1],width=.014)
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
sd = micro_sd_card(0,-1.1,-90,'MICRO SD')
pcb += sd
#ADXL372
adxl = ADXL372Z_EVAL(0,0,180,'adxl372')
pcb += adxl
pcb.connectD(xmega['PD4'],[xmega['PD4'].x+.14,xmega['PD4'].y],adxl['CS'],width=.014)
pcb.connectD(xmega['PD5'],[xmega['PD5'].x+.12,xmega['PD5'].y],adxl['MOSI'],width=.014)
pcb.connectD(xmega['PD6'],[xmega['PD6'].x+.10,xmega['PD6'].y],adxl['MISO'],width=.014)
pcb.connectD(xmega['PD7'],[xmega['PD7'].x+.08,xmega['PD7'].y],adxl['SCLK'],width=.014)
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+.2],sd['DO'],width=.014)
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+.15],sd['CLK'],width=.014)
#battery
#batt = CR20XX(xmega.x,xmega.y-.5,0,"CR2032")
#pcb += batt
batt1 = AAA(-.7,0,90,'AAA1')
pcb += batt1
batt2 = AAA(.7,0,-90,'AAA2')
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)
#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']
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment