impact-logger-adalogger.ko 7.57 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 24 25 26 27 28 29 30
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'
            ]
31
    os=.05
Sam Calisch's avatar
Sam Calisch committed
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
    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))
    ]

84 85 86 87 88 89 90 91 92 93 94 95 96 97
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)]
Sam Calisch's avatar
Sam Calisch committed
98 99

    vias = []
100
    shadow = rectangle(-1.75/25.4, 1.75/25.4, -1.68/25.4, 1.68/25.4)
Sam Calisch's avatar
Sam Calisch committed
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 149 150 151 152

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

153
pcb.custom_cutout = filleted_rectangle(-.8,1.2,-.5,.5,.15)
Sam Calisch's avatar
Sam Calisch committed
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168

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)


169
f = feather(0.2,0,90)
Sam Calisch's avatar
Sam Calisch committed
170 171 172 173
pcb += f


#ADXL372
174
#adxl = ADXL372Z_EVAL(0,0,0,'adxl372')
Sam Calisch's avatar
Sam Calisch committed
175
#pcb.custom_cutout = adxl.shadow
176
#pcb += adxl
Sam Calisch's avatar
Sam Calisch committed
177

178 179
adxl = ADXL372Z(0,0,90,'adxl372')
pcb += adxl
Sam Calisch's avatar
Sam Calisch committed
180

181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
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
Sam Calisch's avatar
Sam Calisch committed
200 201 202 203 204

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']