Commit f02b211a authored by Sam Calisch's avatar Sam Calisch

added intial plug test

parent de26bedd
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 Plug(Component):
slot = rectangle(-.03,.03,-.125,.125)
#pad = rectangle(-.05,.05,-.15,.15) - rectangle(-.03,.03,-.125,.125)
pad = circle(0,0,.06)
hw = .25
pins = [
Pin(-hw-.22,-.1,pad),
Pin( hw+.22,-.1,pad)]
vias = [
Via(-hw,0,rectangle(-.03,.03,-.155,.155)),
Via(hw,0,rectangle(-.03,.03,-.125,.125))
]
class DRV5053(Component):
#nonstandard mounting of TO-92 hall effect sensor
pad = rectangle(-.1,0,-.016,.016)
pins = [
Pin(-.03,-.16,pad,'VCC'),
Pin(-.03,-.21,pad,'GND'),
Pin(-.03,-.26,pad,'SIG')
]
vias = [Via(0,0,rectangle(-.03,.03,-.28,0))]
class R_0805_small(Component):
''' 0805 Resistor
'''
_pad_0805 = s2d.rectangle(-.017,.017, -.026, .026)
pins = [Pin(-0.04, 0, _pad_0805), Pin(0.04, 0, _pad_0805)]
prefix = 'R'
vias = []
class Button(Component):
''' SW262CT-ND
'''
rect = rectangle(-.75/25.4,.75/25.4,-.5/25.4,.5/25.4)
pins = [
Pin(-2/25.4,.8/25.4,rect),
Pin( 2/25.4,.8/25.4,rect),
Pin(-2/25.4,-.8/25.4,rect),
Pin( 2/25.4,-.8/25.4,rect)
]
prefix = 'button'
vias = []
shadow = rectangle(-2.1/25.4,2.1/25.4,-1.4/25.4,1.4/25.4)
class TagConnectSWD(Component):
'''
'''
_pad = s2d.circle(0,0,.5*.031)
_via = s2d.circle(0,0,.5*.039)
pins = [
Pin(-.05,-.025,_pad,'GND',label_size=.012),
Pin( .00,-.025,_pad,'NC',label_size=.012),
Pin( .05,-.025,_pad,'VCC',label_size=.012),
Pin(-.05,.025,_pad,'GND',label_size=.012),
Pin( .00,.025,_pad,'SWDIO',label_size=.012),
Pin( .05,.025,_pad,'SWDCLK',label_size=.012)
]
vias = [
Via(-.1,0,_via),
Via(.1,0.04,_via),
Via(.1,-.04,_via),
]
class Regulator_SOT23(Component):
''' SOT23 voltage regulator
'''
_pad_SOT23 = s2d.rectangle(-.02,.02,-.012,.012)
pins = [
Pin(-0.045, -0.0375, _pad_SOT23,'IN'),
Pin(-0.045, 0.0375, _pad_SOT23,'OUT'),
Pin(0.045, 0, _pad_SOT23,'GND')
]
prefix = 'U'
vias = []
class Crystal_FC135(Component):
''' CRYSTAL 32.7680KHZ 12.5PF SMT
'''
_pad = s2d.rectangle(-.5/25.4,.5/25.4,-.9/25.4,.9/25.4)
pins = [
Pin(-1.25/25.4, 0, _pad),
Pin( 1.25/25.4, 0, _pad),
]
prefix = 'U'
vias = []
class Header_Watt(Component):
''' FTDI cable header
'''
_pad_header = chamfered_rectangle(-0.06, 0.08,-0.025, 0.025,.007)
pins = [
#Pin(0, -0.25, _pad_header, 'RTS'),
Pin(0, -0.15, _pad_header, 'V-'),
Pin(0, -0.05, _pad_header, 'VCC'),
Pin(0, 0.05, _pad_header, 'GND'),
Pin(0, 0.15, _pad_header, 'SIG'),
Pin(0, 0.25, _pad_header, 'V+')
]
prefix = 'J'
vias = []
shadow = s2d.rectangle(-.06,4/25.4,-.2,.3)
#shadow = s2d.rectangle(-.06,8/25.4,-.3,.2)
class Header_FTDI(Component):
''' FTDI cable header
'''
_pad_header = chamfered_rectangle(-0.06, 0.08,-0.025, 0.025,.007)
pins = [
#Pin(0, -0.25, _pad_header, 'RTS'),
Pin(0, -0.15, _pad_header, 'RX'),
Pin(0, -0.05, _pad_header, 'TX'),
Pin(0, 0.05, _pad_header, 'VCC'),
Pin(0, 0.15, _pad_header, 'CTS'),
Pin(0, 0.25, _pad_header, 'GND')
]
prefix = 'J'
vias = []
shadow = s2d.rectangle(-.06,8/25.4,-.3,.3)
#shadow = s2d.rectangle(-.06,8/25.4,-.3,.2)
class Header_Daughter(Component):
''' FTDI cable header
'''
_pad_header = chamfered_rectangle(-0.03, 0.03,-0.015, 0.015,.002)
labels=['SDA','SCL','A4','A5']
pins = [ Pin(0,.05*(i-1.5),_pad_header,l) for i,l in enumerate(labels)]
prefix = 'J'
vias = [Via(p.x,p.y,circle(0,0,.017)) for p in pins]
shadow = s2d.rectangle(-.03,.03,-.1,.1)
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 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 MDBT42(Component):
#Raytach nrf52 module
p = .7/25.4
pad_hw = .15/25.4
pad_hh = .8/25.4
_padv = rectangle(-pad_hw,pad_hw,-pad_hh,pad_hh)
_padh = rectangle(-pad_hh,pad_hh,-pad_hw,pad_hw)
_padg = rectangle(-pad_hh,pad_hh,-.35/25.4,.4/25.4)
c= 5/25.4
start_y = 11.8/25.4
start_x = .8/25.4
y_os = .25
names = [
'GND1','SDA','SCL','P27','A4','A5','A6','A7','DEC4','DCC','VDD',
'GND2','XL1','XL2','P2','P3','P4','P5','P6','P7','P8','P9','P10','GND3',
'P11','P12','P13','P14','P15','P16','P17','P18','P19','P20','RESET','SWDCLK','SWDIO','P22','GND4'
]
pins = [Pin(-c,start_y-y_os,_padg,n,label_size=.018) for i,n in enumerate(names[:1])]
pins += [Pin(-c,start_y-3./25.4-i*p-y_os,_padh,n,label_size=.018) for i,n in enumerate(names[1:11])]
pins += [Pin(-c+start_x+i*p,-y_os,_padv,n,label_size=.018,label_rot=-90) for i,n in enumerate(names[11:24])]
pins += [Pin(c,start_y-.9/25.4-i*p-y_os,_padh,n,label_size=.018) for i,n in enumerate(names[24:38][::-1])]
pins += [Pin(c,start_y-y_os,_padg,n,label_size=.018) for i,n in enumerate(names[38:])]
vias = []
shadow = rectangle(-c,c,-y_os,start_y+4.2/25.4-y_os)
class BT832(Component):
#Fanstel BT832 nrf52 module
p = 1.1/25.4
pad_hw = .7/25.4
pad_hh = .35/25.4
_pad = rectangle(-pad_hw,pad_hw,-pad_hh,pad_hh)
c= 7/25.4
start_y = 1.1/25.4
y_os = .25
names = [
'SDA','SCL','XL1','XL2','AIN0','AIN1','NFC1','NFC2',
'VCC','GND','P13','P18','P20','RESET','SWDCLK','SWDIO'
]
pins = [Pin(-c,start_y+i*p-y_os,_pad,n,label_size=.018) for i,n in enumerate(names[:8][::-1])]
pins += [Pin(c,start_y+i*p-y_os,_pad,n,label_size=.018) for i,n in enumerate(names[8:16])]
vias = []
shadow = rectangle(-c,c,-y_os,16/25.4-y_os)
class BC832(Component):
#Fanstel BC832 micro nrf52 module
p = 1.1/25.4
pad_hw = .7/25.4
pad_hh = .34/25.4
_pad_lga = circle(0,0,.32/25.4)
_pad = rectangle(-pad_hw,pad_hw,-pad_hh,pad_hh)
c= 3.9/25.4
start_y = .618/25.4
y_os = .18
names = [
'GND','DFU','SWDIO','SWDCLK','P18','P13','P11','P12',
'A1','RESET','XL1','XL2','A0','P27','P26','VDD',
]
pins = [Pin(-c,start_y+i*p-y_os,_pad,n,label_size=.018) for i,n in enumerate(names[:8][::-1])]
pins += [Pin(c,start_y+i*p-y_os,_pad,n,label_size=.018) for i,n in enumerate(names[8:16])]
pins += [
Pin(-c+2.15/25.4,-y_os+.519/25.4,_pad_lga,'P8',label_size=.01),
Pin(-c+2.15/25.4,-y_os+(1.2+.519)/25.4,_pad_lga,'P6',label_size=.01)
]
vias = []
shadow = rectangle(-c,c,-y_os,8.8/25.4-y_os)
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.1
height = 1.1
pcb = PCB(0,0,width,height,chamfer_distance=.15)
def connectG(pin,dx,dy,width=.012):
'''
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=.012):
pcb.connectD(pin,[pin.x+dx+.0001,pin.y+dy],width=width)
def connectM(pin1,pin2,dx,width=.012):
pcb.connectD(pin1,[pin1.x+dx,pin1.y],pin2,width=width)
plug = Plug(.55,.7,0)
pcb += plug
header = Header_Watt(plug.x,0.15,-90)
pcb += header
pcb.connectD(header['V-'],[header['V-'].x-.1,header['V-'].y],plug[1])
pcb.connectD(header['V+'],[header['V+'].x+.1,header['V+'].y],plug[0])
core_w = .132
core_gap = .029
drv = DRV5053(plug.x+.25,plug.y-.125-core_gap,0,'drv3035')
pcb += drv
pcb.connectH(drv['SIG'],header['SIG'])
pcb.connectH(drv['GND'],header['GND'])
pcb.connectH(drv['VCC'],header['VCC'])
core_r = filleted_rectangle(-.03-core_gap-core_w,.03+core_gap+core_w,-.125-core_gap-core_w,.125+core_gap+core_w,core_w)
core_r -= rectangle(-.03-core_gap,.03+core_gap,-.125-core_gap,.125+core_gap)
core_l = filleted_rectangle(-.03-core_gap-core_w,.03+core_gap+core_w,-.155-core_gap-core_w,.155+core_gap+core_w,core_w)
core_l -= rectangle(-.03-core_gap,.03+core_gap,-.155-core_gap,.155+core_gap)
#mag = rectangle(-.03,.03,-.065,.065)
#core_r += move(mag,0,-.125-core_gap-core_w)
pocket = move(core_r,plug.x+.25,plug.y)
pocket += move(core_l,plug.x-.25,plug.y)
'''
ftdi = Header_FTDI(.2,.33,180,'ftdi')
pcb += ftdi
reg = Regulator_SOT23(ftdi.x+.13,ftdi['GND'].y+.03,-90,'3.3v')
pcb += reg
pcb.connectV(ftdi['GND'],reg['GND'],width=.02)
pcb.connectD(reg['IN'],[reg['IN'].x,ftdi['VCC'].y-.03],ftdi['VCC'],width=.02)
C_in = C_0805(reg.x-.01,reg.y+.165,180,'Cin\n.1uF',label_size=.02)
pcb += C_in
C_out = C_0805(reg.x+.09,reg.y-.01,90,'Cout\n.1uF',label_size=.02)
pcb += C_out
pcb.connectD(C_in[1],[C_in[1].x,C_in[1].y-.02],reg['GND'])
pcb.connectV(reg['IN'],C_in[0],width=.02)
pcb.connectH(reg['OUT'],C_out[0],width=.02)
pcb.connectH(reg['GND'],C_out[1],width=.02)
mdb = BC832(ftdi.x+.5,ftdi.y+.1,-90,'Fanstel\nBC832\nNRF52')
pcb += mdb
pcb.connectD(mdb['P8'],[mdb['P8'].x-.01,mdb['P8'].y],[ftdi['TX'].x+.31,ftdi['TX'].y+.03],[ftdi['TX'].x+.03,ftdi['TX'].y-.019],ftdi['TX'],width=.014)
pcb.connectD(mdb['P6'],[mdb['P6'].x,mdb['P6'].y+.02],[mdb['P6'].x-.07,mdb['P6'].y+.035],[ftdi['RX'].x+.28,ftdi['RX'].y-.043],[ftdi['RX'].x+.1,ftdi['RX'].y-.088],[ftdi['RX'].x+.09,ftdi['RX'].y-.03],ftdi['RX'],width=.012)
swd = TagConnectSWD(ftdi.x+.17,mdb.y+.1,-90,'swd')
pcb += swd
pcb.connectD(swd['SWDCLK'],[swd['SWDCLK'].x+.02,swd['SWDCLK'].y],[mdb['SWDCLK'].x-.24,mdb['SWDCLK'].y+.01],[mdb['SWDCLK'].x-.02,mdb['SWDCLK'].y+.05],mdb['SWDCLK'],width=.012)
pcb.connectD(swd['SWDIO'],[swd['SWDIO'].x+.02,swd['SWDIO'].y],[mdb['SWDIO'].x-.32,mdb['SWDIO'].y+.04],[mdb['SWDIO'].x-.03,mdb['SWDIO'].y+.079],mdb['SWDIO'],width=.012)
#pcb.connectD(ftdi['RTS'],[ftdi['RTS'].x,ftdi['RTS'].y+.03],[mdb['DFU'].x-.05,mdb['DFU'].y+.12],mdb['DFU'],width=.014)
button = Button(ftdi.x-.01,ftdi.y+.26,0)
pcb += button
pcb.connectH(ftdi['GND'],[button[1].x-.07,button[1].y],button[1])
pcb.connectV(mdb['RESET'],[ftdi.x-.11,ftdi['TX'].y-.05],button[3],width=.014)
pcb.connectV(button[3],button[0])
pcb.connectV(button[1],button[2])
pcb.connectD(mdb['GND'],[mdb['GND'].x,mdb['GND'].y+.03],[button.x+.15,mdb['GND'].y+.108],button[2],width=.012)
C2 = C_0805(C_out.x,C_out.y+.13,-90,'C2\n10uF',label_size=.02)
pcb += C2
pcb.connectV(C2[1],C_in[1],width=.02)
pcb.connectH(C2[0],C_out[0],width=.02)
x1 = Crystal_FC135(mdb['XL1'].x+.03,mdb.y-.32,90,'X1\n32.768',label_size=.025)
pcb += x1
cx1 = C_0805(x1.x-.1,x1[0].y-.022,0,'CX1\n22pF',label_size=.02)
cx2 = C_0805(x1.x-.1,x1[1].y+.005,180,'CX2\n22pF',label_size=.02)
pcb += cx1
pcb += cx2
pcb.connectD(x1[0],mdb['XL1'])
pcb.connectD(mdb['XL2'],[mdb['XL2'].x,mdb['XL2'].y-.052],[mdb['XL2'].x+.03,mdb['XL2'].y-.052],[x1[1].x+.06,x1[1].y+.02],x1[1])
pcb.connectV(cx2[0],cx1[1])
pcb.connectV(x1[0],cx1[0])
pcb.connectV(x1[1],cx2[1])
pcb.connectD(cx1[1],[C2[1].x+.091,C2[1].y-.03],C2[1],width=.012)
pcb.connectD(mdb['VDD'],[mdb['VDD'].x,mdb['VDD'].y-.22],[cx2.x-.075,cx2.y-.052],[C_out[0].x+.051,C_out[0].y-.04],C_out[0])
led = R_0805(mdb['P26'].x+.01,mdb['P26'].y-.2,0,'led',label_size=.03)
pcb += led
R_led = R_0805(led[1].x,led.y+.09,90,'1k',label_size=.03)
pcb += R_led
pcb.connectV(led[1],R_led[1])
pcb.connectV(mdb['VDD'],led[0])
pcb.connectV(mdb['P27'],R_led[0])
pcb.connectH(swd[4],swd[1])
pcb.connectD(swd[1],button[2])
R1 = R_0805_small(mdb['RESET'].x-.076,mdb['RESET'].y-.07,0,'10k',label_size=.03)
pcb += R1
pcb.connectV(mdb['RESET'],R1[0])
pcb.connectH(C2[0],R1[1])
'''
#test = rectangle(-.19,.0,-.185,.06)
#test = move(test,plug.x-.25,plug.y)
#for top
topside=0
if topside:
pocket += circle(plug[1].x,plug[1].y,.06)
pocket += circle(plug[0].x,plug[0].y,.06)
pocket += rectangle(header.x-.21,header.x+.31,0,header.y+.07)
pocket += rectangle(drv.x-.15, drv.x+.05, drv[2].y-.12, drv[2].y+.12)
pcb.add_custom_layer("pocket",pocket,(250,0,100))
#pcb.add_custom_layer("test",test,(0,250,100))
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['pocket']['layer']+(pcb.traces-pcb.traces)+(pcb.cutout-pcb.cutout)
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