# # hello.txrx.45.cad # # step response transmit-receive # # Neil Gershenfeld # CBA MIT 11/5/11 # # (c) Massachusetts Institute of Technology 2011 # Permission granted for experimental and personal use; # license for commercial sale available from MIT. # # # uncomment for desired output: # output = "traces, labels, and exterior" #output = "traces and exterior" #output = "interior" #output = "exterior" #output = "traces" #output = "holes" #output = "solder mask" True = "1" False = "0" def color(color, part): part = '('+str(color)+'*(('+part+')!=0))' return part Red = (225 << 0) Green = (225 << 8) Blue = (225 << 16) Gray = (128 << 16) + (128 << 8) + (128 << 0) White = (255 << 16) + (255 << 8) + (255 << 0) Teal = (255 << 16) + (255 << 8) Pink = (255 << 16) + (255 << 0) Yellow = (255 << 8) + (255 << 0) Brown = (45 << 16) + (82 << 8) + (145 << 0) Navy = (128 << 16) + (0 << 8) + (0 << 0) Tan = (60 << 16) + (90 << 8) + (125 << 0) def circle(x0, y0, r): part = "(((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0))) <= (r*r))" part = replace(part,'x0',str(x0)) part = replace(part,'y0',str(y0)) part = replace(part,'r',str(r)) return part def cylinder(x0, y0, z0, z1, r): part = "(((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0)) <= (r*r)) & (Z >= (z0)) & (Z <= (z1)))" part = replace(part,'x0',str(x0)) part = replace(part,'y0',str(y0)) part = replace(part,'z0',str(z0)) part = replace(part,'z1',str(z1)) part = replace(part,'r',str(r)) return part def cone(x0, y0, z0, z1, r0): part = cylinder(x0, y0, z0, z1, r0) part = taper_xy_z(part, x0, y0, z0, z1, 1.0, 0.0) return part def sphere(x0, y0, z0, r): part = "(((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0)) + (Z-(z0))*(Z-(z0))) <= (r*r))" part = replace(part,'x0',str(x0)) part = replace(part,'y0',str(y0)) part = replace(part,'z0',str(z0)) part = replace(part,'r',str(r)) return part def torus(x0, y0, z0, r0, r1): part = "(((r0 - sqrt((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0))))*(r0 - sqrt((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0))) + (Z-(z0))*(Z-(z0))) <= (r1*r1))" part = replace(part,'x0',str(x0)) part = replace(part,'y0',str(y0)) part = replace(part,'z0',str(z0)) part = replace(part,'r0',str(r0)) part = replace(part,'r1',str(r1)) return part def rectangle(x0, x1, y0, y1): part = "((X >= (x0)) & (X <= (x1)) & (Y >= (y0)) & (Y <= (y1)))" part = replace(part,'x0',str(x0)) part = replace(part,'x1',str(x1)) part = replace(part,'y0',str(y0)) part = replace(part,'y1',str(y1)) return part def cube(x0, x1, y0, y1, z0, z1): part = "((X >= (x0)) & (X <= (x1)) & (Y >= (y0)) & (Y <= (y1)) & (Z >= (z0)) & (Z <= (z1)))" part = replace(part,'x0',str(x0)) part = replace(part,'x1',str(x1)) part = replace(part,'y0',str(y0)) part = replace(part,'y1',str(y1)) part = replace(part,'z0',str(z0)) part = replace(part,'z1',str(z1)) return part def right_triangle(x0, y0, l): part = "((X > x0) & (X < x0 + l - (Y-y0)) & (Y > y0))" part = replace(part,'x0',str(x0)) part = replace(part,'y0',str(y0)) part = replace(part,'l',str(l)) return part def triangle(x0, y0, x1, y1, x2, y2): # points in clockwise order part = "(((((y1)-(y0))*(X-(x0))-((x1)-(x0))*(Y-(y0))) >= 0) & ((((y2)-(y1))*(X-(x1))-((x2)-(x1))*(Y-(y1))) >= 0) & ((((y0)-(y2))*(X-(x2))-((x0)-(x2))*(Y-(y2))) >= 0))" part = replace(part,'x0',str(x0)) part = replace(part,'y0',str(y0)) part = replace(part,'x1',str(x1)) part = replace(part,'y1',str(y1)) part = replace(part,'x2',str(x2)) part = replace(part,'y2',str(y2)) return part def pyramid(x0, x1, y0, y1, z0, z1): part = cube(x0, x1, y0, y1, z0, z1) part = taper_xy_z(part, (x0+x1)/2., (y0+y1)/2., z0, z1, 1.0, 0.0) return part def function(Z_of_XY): part = '(Z <= '+Z_of_XY+')' return part def functions(upper_Z_of_XY,lower_Z_of_XY): part = '(Z <= '+upper_Z_of_XY+') & (Z >= '+lower_Z_of_XY+')' return part def add(part1, part2): part = "part1 | part2" part = replace(part,'part1',part1) part = replace(part,'part2',part2) return part def subtract(part1, part2): part = "(part1) & ~(part2)" part = replace(part,'part1',part1) part = replace(part,'part2',part2) return part def intersect(part1, part2): part = "(part1) & (part2)" part = replace(part,'part1',part1) part = replace(part,'part2',part2) return part def move(part,dx,dy): part = replace(part,'X','(X-('+str(dx)+'))') part = replace(part,'Y','(Y-('+str(dy)+'))') return part def translate(part,dx,dy,dz): part = replace(part,'X','(X-('+str(dx)+'))') part = replace(part,'Y','(Y-('+str(dy)+'))') part = replace(part,'Z','(Z-('+str(dz)+'))') return part def rotate(part, angle): angle = angle*pi/180 part = replace(part,'X','(cos(angle)*X+sin(angle)*y)') part = replace(part,'Y','(-sin(angle)*X+cos(angle)*y)') part = replace(part,'y','Y') part = replace(part,'angle',str(angle)) return part def rotate_x(part, angle): angle = angle*pi/180 part = replace(part,'Y','(cos(angle)*Y+sin(angle)*z)') part = replace(part,'Z','(-sin(angle)*Y+cos(angle)*z)') part = replace(part,'z','Z') part = replace(part,'angle',str(angle)) return part def rotate_y(part, angle): angle = angle*pi/180 part = replace(part,'X','(cos(angle)*X+sin(angle)*z)') part = replace(part,'Z','(-sin(angle)*X+cos(angle)*z)') part = replace(part,'z','Z') part = replace(part,'angle',str(angle)) return part def rotate_z(part, angle): angle = angle*pi/180 part = replace(part,'X','(cos(angle)*X+sin(angle)*y)') part = replace(part,'Y','(-sin(angle)*X+cos(angle)*y)') part = replace(part,'y','Y') part = replace(part,'angle',str(angle)) return part def rotate_90(part): part = reflect_y(part,0) part = reflect_xy(part) return part def rotate_180(part): part = rotate_90(part) part = rotate_90(part) return part def rotate_270(part): part = rotate_90(part) part = rotate_90(part) part = rotate_90(part) return part def reflect_x(part,x0): part = replace(part,'X','(x0-X)') part = replace(part,'x0',str(x0)) return part def reflect_y(part,y0): part = replace(part,'Y','(y0-Y)') part = replace(part,'y0',str(y0)) return part def reflect_z(part,z0): part = replace(part,'Z','(z0-Z)') part = replace(part,'z0',str(z0)) return part def reflect_xy(part): part = replace(part,'X','temp') part = replace(part,'Y','X') part = replace(part,'temp','Y') return part def reflect_xz(part): part = replace(part,'X','temp') part = replace(part,'Z','X') part = replace(part,'temp','Z') return part def reflect_yz(part): part = replace(part,'Y','temp') part = replace(part,'Z','Y') part = replace(part,'temp','Z') return part def scale_x(part, x0, sx): part = replace(part,'X','((x0) + (X-(x0))/(sx))') part = replace(part,'x0',str(x0)) part = replace(part,'sx',str(sx)) return part def scale_y(part, y0, sy): part = replace(part,'Y','((y0) + (Y-(y0))/(sy))') part = replace(part,'y0',str(y0)) part = replace(part,'sy',str(sy)) return part def scale_z(part, z0, sz): part = replace(part,'Z','((z0) + (Z-(z0))/(sz))') part = replace(part,'z0',str(z0)) part = replace(part,'sz',str(sz)) return part def scale_xy(part, x0, y0, sxy): part = replace(part,'X','((x0) + (X-(x0))/(sxy))') part = replace(part,'Y','((y0) + (Y-(y0))/(sxy))') part = replace(part,'x0',str(x0)) part = replace(part,'y0',str(y0)) part = replace(part,'sxy',str(sxy)) return part def scale_xyz(part, x0, y0, z0, sxyz): part = replace(part,'X','((x0) + (X-(x0))/(sxyz))') part = replace(part,'Y','((y0) + (Y-(y0))/(sxyz))') part = replace(part,'Z','((z0) + (Z-(z0))/(sxyz))') part = replace(part,'x0',str(x0)) part = replace(part,'y0',str(y0)) part = replace(part,'z0',str(z0)) part = replace(part,'sxyz',str(sxyz)) return part def coscale_x_y(part, x0, y0, y1, angle0, angle1, amplitude, offset): phase0 = pi*angle0/180. phase1 = pi*angle1/180. part = replace(part,'X','((x0) + (X-(x0))/((offset) + (amplitude)*cos((phase0) + ((phase1)-(phase0))*(Y-(y0))/((y1)-(y0)))))') part = replace(part,'x0',str(x0)) part = replace(part,'y0',str(y0)) part = replace(part,'y1',str(y1)) part = replace(part,'phase0',str(phase0)) part = replace(part,'phase1',str(phase1)) part = replace(part,'amplitude',str(amplitude)) part = replace(part,'offset',str(offset)) return part def coscale_x_z(part, x0, z0, z1, angle0, angle1, amplitude, offset): phase0 = pi*angle0/180. phase1 = pi*angle1/180. part = replace(part,'X','((x0) + (X-(x0))/((offset) + (amplitude)*cos((phase0) + ((phase1)-(phase0))*(Z-(z0))/((z1)-(z0)))))') part = replace(part,'x0',str(x0)) part = replace(part,'z0',str(z0)) part = replace(part,'z1',str(z1)) part = replace(part,'phase0',str(phase0)) part = replace(part,'phase1',str(phase1)) part = replace(part,'amplitude',str(amplitude)) part = replace(part,'offset',str(offset)) return part def coscale_xy_z(part, x0, y0, z0, z1, angle0, angle1, amplitude, offset): phase0 = pi*angle0/180. phase1 = pi*angle1/180. part = replace(part,'X','((x0) + (X-(x0))/((offset) + (amplitude)*cos((phase0) + ((phase1)-(phase0))*(Z-(z0))/((z1)-(z0)))))') part = replace(part,'Y','((y0) + (Y-(y0))/((offset) + (amplitude)*cos((phase0) + ((phase1)-(phase0))*(Z-(z0))/((z1)-(z0)))))') part = replace(part,'x0',str(x0)) part = replace(part,'y0',str(y0)) part = replace(part,'z0',str(z0)) part = replace(part,'z1',str(z1)) part = replace(part,'phase0',str(phase0)) part = replace(part,'phase1',str(phase1)) part = replace(part,'amplitude',str(amplitude)) part = replace(part,'offset',str(offset)) return part def taper_x_y(part, x0, y0, y1, s0, s1): part = replace(part,'X','((x0) + (X-(x0))*((y1)-(y0))/((s1)*(Y-(y0)) + (s0)*((y1)-Y)))') part = replace(part,'x0',str(x0)) part = replace(part,'y0',str(y0)) part = replace(part,'y1',str(y1)) part = replace(part,'s0',str(s0)) part = replace(part,'s1',str(s1)) return part def taper_x_z(part, x0, z0, z1, s0, s1): part = replace(part,'X','((x0) + (X-(x0))*((z1)-(z0))/((s1)*(Z-(z0)) + (s0)*((z1)-Z)))') part = replace(part,'x0',str(x0)) part = replace(part,'z0',str(z0)) part = replace(part,'z1',str(z1)) part = replace(part,'s0',str(s0)) part = replace(part,'s1',str(s1)) return part def taper_xy_z(part, x0, y0, z0, z1, s0, s1): part = replace(part,'X','((x0) + (X-(x0))*((z1)-(z0))/((s1)*(Z-(z0)) + (s0)*((z1)-Z)))') part = replace(part,'Y','((y0) + (Y-(y0))*((z1)-(z0))/((s1)*(Z-(z0)) + (s0)*((z1)-Z)))') part = replace(part,'x0',str(x0)) part = replace(part,'y0',str(y0)) part = replace(part,'z0',str(z0)) part = replace(part,'z1',str(z1)) part = replace(part,'s0',str(s0)) part = replace(part,'s1',str(s1)) return part def shear_x_y(part, y0, y1, dx0, dx1): part = replace(part,'X','(X - (dx0) - ((dx1)-(dx0))*(Y-(y0))/((y1)-(y0)))') part = replace(part,'y0',str(y0)) part = replace(part,'y1',str(y1)) part = replace(part,'dx0',str(dx0)) part = replace(part,'dx1',str(dx1)) return part def shear_x_z(part, z0, z1, dx0, dx1): part = replace(part,'X','(X - (dx0) - ((dx1)-(dx0))*(Z-(z0))/((z1)-(z0)))') part = replace(part,'z0',str(z0)) part = replace(part,'z1',str(z1)) part = replace(part,'dx0',str(dx0)) part = replace(part,'dx1',str(dx1)) return part def coshear_x_z(part, z0, z1, angle0, angle1, amplitude, offset): phase0 = pi*angle0/180. phase1 = pi*angle1/180. part = replace(part,'X','(X - (offset) - (amplitude)*cos((phase0) + ((phase1)-(phase0))*(Z-(z0))/((z1)-(z0))))') part = replace(part,'z0',str(z0)) part = replace(part,'z1',str(z1)) part = replace(part,'phase0',str(phase0)) part = replace(part,'phase1',str(phase1)) part = replace(part,'amplitude',str(amplitude)) part = replace(part,'offset',str(offset)) return part # # text classes and definitions # class text: # # text class # def __init__(self,text,x,y,z,line='',height='',width='',space='',align='CC',color=White,angle=0): # # parameters # if (line == ''): line = 1 if (height == ''): height = 6*line if (width == ''): width = 4*line if (space == ''): space = line/2.0 self.width = 0 self.height = 0 self.text = text # # construct shape dictionary # shapes = {} shape = triangle(0,0,width/2.0,height,width,0) cutout = triangle(0,-2.5*line,width/2.0,height-2.5*line,width,-2.5*line) cutout = subtract(cutout,rectangle(0,width,height/4-line/2,height/4+line/2)) shape = subtract(shape,cutout) shapes['A'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/4)) shape = add(shape,rectangle(width-line,width,0,height/3)) shapes['a'] = shape shape = rectangle(0,width-height/4,0,height) shape = add(shape,circle(width-height/4,height/4,height/4)) shape = add(shape,circle(width-height/4,3*height/4,height/4)) w = height/2-1.5*line shape = subtract(shape,rectangle(line,line+w/1.5,height/2+line/2,height-line)) shape = subtract(shape,circle(line+w/1.5,height/2+line/2+w/2,w/2)) shape = subtract(shape,rectangle(line,line+w/1.5,line,height/2-line/2)) shape = subtract(shape,circle(line+w/1.5,height/2-line/2-w/2,w/2)) shapes['B'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/4)) shape = add(shape,rectangle(0,line,0,height)) shapes['b'] = shape shape = circle(width/2,width/2,width/2) shape = add(shape,circle(width/2,height-width/2,width/2)) shape = add(shape,rectangle(0,width,line+w/2,height-line-w/2)) w = width-2*line shape = subtract(shape,circle(width/2,line+w/2,w/2)) shape = subtract(shape,circle(width/2,height-line-w/2,w/2)) shape = subtract(shape,rectangle(line,width,line+w/2,height-line-w/2)) shapes['C'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/4)) shape = subtract(shape,rectangle(width/2,width,width/2-line/1.5,width/2+line/1.5)) shapes['c'] = shape shape = circle(line,width-line,width-line) shape = subtract(shape,circle(line,width-line,width-2*line)) shape = subtract(shape,rectangle(-width,line,0,height)) shape = scale_y(shape,0,height/(2*(width-line))) shape = add(shape,rectangle(0,line,0,height)) shapes['D'] = shape shape = rectangle(width-line,width,0,height) shape = add(shape,circle(width/2,width/2,width/2)) shape = subtract(shape,circle(width/2,width/2,width/2-line)) shapes['d'] = shape shape = rectangle(0,line,0,height) shape = add(shape,rectangle(0,width,height-line,height)) shape = add(shape,rectangle(0,2*width/3,height/2-line/2,height/2+line/2)) shape = add(shape,rectangle(0,width,0,line)) shapes['E'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/2-line)) shape = subtract(shape,triangle(width,0,width/2,width/2-line/2,width,width/2-line/2)) shape = add(shape,rectangle(0,width,width/2-line/2,width/2+line/2)) shapes['e'] = shape shape = rectangle(0,line,0,height) shape = add(shape,rectangle(0,width,height-line,height)) shape = add(shape,rectangle(0,2*width/3,height/2-line/2,height/2+line/2)) shapes['F'] = shape shape = circle(width-line/2,height-width/2,width/2) shape = subtract(shape,circle(width-line/2,height-width/2,width/2-line)) shape = subtract(shape,rectangle(0,width-line/2,0,height-width/2)) shape = subtract(shape,rectangle(width-line/2,2*width,0,height)) shape = add(shape,rectangle(width/2-line/2,width/2+line/2,0,height-width/2)) shape = add(shape,rectangle(width/5,4*width/5,height/2-line/2,height/2+line/2)) shapes['f'] = shape shape = circle(width/2,width/2,width/2) shape = add(shape,circle(width/2,height-width/2,width/2)) shape = add(shape,rectangle(0,width,line+w/2,height-line-w/2)) w = width-2*line shape = subtract(shape,circle(width/2,line+w/2,w/2)) shape = subtract(shape,circle(width/2,height-line-w/2,w/2)) shape = subtract(shape,rectangle(line,width,line+w/2,height-line-w/2)) shape = add(shape,rectangle(width/2,width,line+w/2,2*line+w/2)) shapes['G'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/2-line)) w = height/3-width/2 shape = add(shape,rectangle(width-line,width,w,width)) shape = add(shape,subtract(subtract(circle(width/2,w,width/2),circle(width/2,w,width/2-line)),rectangle(0,width,w,height))) shapes['g'] = shape shape = rectangle(0,line,0,height) shape = add(shape,rectangle(width-line,width,0,height)) shape = add(shape,rectangle(0,width,height/2-line/2,height/2+line/2)) shapes['H'] = shape w = width/2 shape = circle(width/2,w,width/2) shape = subtract(shape,circle(width/2,w,width/2-line)) shape = subtract(shape,rectangle(0,width,0,w)) shape = add(shape,rectangle(0,line,0,height)) shape = add(shape,rectangle(width-line,width,0,w)) shapes['h'] = shape shape = rectangle(width/2-line/2,width/2+line/2,0,height) shape = add(shape,rectangle(width/5,4*width/5,0,line)) shape = add(shape,rectangle(width/5,4*width/5,height-line,height)) shapes['I'] = shape shape = rectangle(width/2-line/2,width/2+line/2,0,height/2) shape = add(shape,circle(width/2,3*height/4,.6*line)) shapes['i'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/2-line)) shape = subtract(shape,rectangle(0,width,width/2,height)) shape = add(shape,rectangle(width-line,width,width/2,height)) shapes['J'] = shape w = height/3-width/2 shape = rectangle(width/2-line/2,width/2+line/2,w,height/2) shape = add(shape,subtract(subtract(subtract(circle(width/4-line/2,w,width/2),circle(width/4-line/2,w,width/2-line)),rectangle(0,width,w,height)),rectangle(-width,width/4-line/2,-height/3,height))) shape = add(shape,circle(width/2,3*height/4,.6*line)) shapes['j'] = shape shape = rectangle(0,width,0,height) shape = subtract(shape,triangle(line,height,width-1.1*line,height,line,height/2+.5*line)) shape = subtract(shape,triangle(width,0,line+0.8*line,height/2,width,height)) shape = subtract(shape,triangle(line,0,line,height/2-.5*line,width-1.1*line,0)) shapes['K'] = shape shape = rectangle(0,width,0,height) shape = subtract(shape,rectangle(line,width,2*height/3,height)) shape = subtract(shape,triangle(line,2*height/3,width-1.3*line,2*height/3,line,height/3+.5*line)) shape = subtract(shape,triangle(width,0,line+0.8*line,height/3,width,2*height/3)) shape = subtract(shape,triangle(line,0,line,height/3-0.5*line,width-1.3*line,0)) shapes['k'] = shape shape = rectangle(0,line,0,height) shape = add(shape,rectangle(0,width,0,line)) shapes['L'] = shape shape = rectangle(width/2-line/2,width/2+line/2,0,height) shapes['l'] = shape shape = rectangle(0,width,0,height) shape = subtract(shape,triangle(line,0,line,height-3*line,width/2-line/3,0)) shape = subtract(shape,triangle(line,height,width-line,height,width/2,1.5*line)) shape = subtract(shape,triangle(width/2+line/3,0,width-line,height-3*line,width-line,0)) shapes['M'] = shape w = width/2 l = 1.3*line shape = circle(width/2,w,width/2) shape = subtract(shape,circle(width/2,w,width/2-l)) shape = subtract(shape,rectangle(0,width,0,w)) shape = add(shape,rectangle(width-l,width,0,w)) shape = add(shape,move(shape,width-l,0)) shape = add(shape,rectangle(0,l,0,width)) shape = scale_x(shape,0,width/(2*width-l)) shapes['m'] = shape shape = rectangle(0,width,0,height) shape = subtract(shape,triangle(line,height+1.5*line,width-line,height+1.5*line,width-line,1.5*line)) shape = subtract(shape,triangle(line,-1.5*line,line,height-1.5*line,width-line,-1.5*line)) shapes['N'] = shape w = width/2 shape = circle(width/2,w,width/2) shape = subtract(shape,circle(width/2,w,width/2-line)) shape = subtract(shape,rectangle(0,width,0,w)) shape = add(shape,rectangle(0,line,0,width)) shape = add(shape,rectangle(width-line,width,0,w)) shapes['n'] = shape shape = circle(width/2,width/2,width/2) shape = add(shape,circle(width/2,height-width/2,width/2)) shape = add(shape,rectangle(0,width,line+w/2,height-line-w/2)) w = width-2*line shape = subtract(shape,circle(width/2,line+w/2,w/2)) shape = subtract(shape,circle(width/2,height-line-w/2,w/2)) shape = subtract(shape,rectangle(line,width-line,line+w/2,height-line-w/2)) shapes['O'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/2-line)) shapes['o'] = shape shape = rectangle(0,line,0,height) w = 2*height/3 shape = add(shape,circle(width-w/2,height-w/2,w/2)) shape = add(shape,rectangle(0,width-w/2,height-w,height)) shape = subtract(shape,circle(width-w/2,height-w/2,w/2-line)) shape = subtract(shape,rectangle(line,width-w/2,height-w+line,height-line)) shapes['P'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/4)) shape = add(shape,rectangle(0,line,-height/3,width)) shapes['p'] = shape shape = subtract(circle(width/2,width/2,width/2),circle(width/2,width/2,width/2-.9*line)) shape = scale_y(shape,0,height/width) shape = add(shape,move(rotate(rectangle(-line/2,line/2,-width/4,width/4),30),3*width/4,width/4)) shapes['Q'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/2-line)) shape = add(shape,rectangle(width-line,width,-height/3,width)) shapes['q'] = shape shape = rectangle(0,line,0,height) w = 2*height/3 shape = add(shape,circle(width-w/2,height-w/2,w/2)) shape = add(shape,rectangle(0,width-w/2,height-w,height)) shape = subtract(shape,circle(width-w/2,height-w/2,w/2-line)) shape = subtract(shape,rectangle(line,width-w/2,height-w+line,height-line)) leg = triangle(line,0,line,height,width,0) leg = subtract(leg,triangle(line,-2.0*line,line,height-2.0*line,width,-2.0*line)) leg = subtract(leg,rectangle(0,width,height/3,height)) shape = add(shape,leg) shapes['R'] = shape shape = circle(width,0,width) shape = subtract(shape,circle(width,0,width-line)) shape = subtract(shape,rectangle(.8*width,2*width,-height,height)) shape = subtract(shape,rectangle(0,2*width,-height,0)) shape = add(shape,rectangle(0,line,0,width)) shapes['r'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/2-line)) shape = subtract(shape,rectangle(0,width/2,width/2,width)) shape = add(shape,move(reflect_y(reflect_x(shape,width),width),0,width-line)) shape = scale_y(shape,0,height/(2*width-line)) shapes['S'] = shape w = width/3 shape = circle(w,w,w) shape = subtract(shape,circle(w,w,w-.9*line)) shape = subtract(shape,rectangle(0,w,w,2*w)) shape = add(shape,move(reflect_y(reflect_x(shape,2*w),2*w),0,2*w-.9*line)) shape = scale_y(shape,0,(2*height/3)/(4*w-.9*line)) shape = move(shape,(width/2)-w,0) shapes['s'] = shape shape = rectangle(width/2-line/2,width/2+line/2,0,height) shape = add(shape,rectangle(0,width,height-line,height)) shapes['T'] = shape shape = circle(0,3*width/8,3*width/8) shape = subtract(shape,circle(0,3*width/8,3*width/8-line)) shape = subtract(shape,rectangle(-width,width,3*width/8,height)) shape = subtract(shape,rectangle(0,width,-height,height)) shape = move(shape,width/2-line/2+3*width/8,0) shape = add(shape,rectangle(width/2-line/2,width/2+line/2,width/4,3*height/4)) shape = add(shape,rectangle(width/5,4*width/5,height/2-line/2,height/2+line/2)) shapes['t'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/2-line)) shape = subtract(shape,rectangle(0,width,width/2,height)) shape = add(shape,rectangle(0,line,width/2,height)) shape = add(shape,rectangle(width-line,width,width/2,height)) shapes['U'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/2-line)) shape = subtract(shape,rectangle(0,width,width/2,height)) shape = add(shape,rectangle(0,line,width/2,2*height/3)) shape = add(shape,rectangle(width-line,width,0,2*height/3)) shapes['u'] = shape shape = triangle(0,height,width,height,width/2,0) shape = subtract(shape,triangle(0,height+3*line,width,height+3*line,width/2,3*line)) shapes['V'] = shape w = 2*height/3.0 shape = triangle(0,w,width,w,width/2,0) shape = subtract(shape,triangle(0,w+2*line,width,w+2*line,width/2,2*line)) shapes['v'] = shape shape = triangle(0,height,width,height,width/2,0) shape = add(shape,move(shape,.6*width,0)) cutout = triangle(0,height+4*line,width,height+4*line,width/2,4*line) cutout = add(cutout,move(cutout,.6*width,0)) shape = subtract(shape,cutout) shape = scale_x(shape,0,1/1.6) shapes['W'] = shape shape = scale_y(shapes['W'],0,width/height) shapes['w'] = shape shape = rectangle(0,width,0,height) shape = subtract(shape,triangle(0,0,0,height,width/2-.7*line,height/2)) shape = subtract(shape,triangle(width,0,width/2+.7*line,height/2,width,height)) shape = subtract(shape,triangle(1.1*line,height,width-1.1*line,height,width/2,height/2+line)) shape = subtract(shape,triangle(1.1*line,0,width/2,height/2-line,width-1.1*line,0)) shapes['X'] = shape w = 2*height/3.0 shape = rectangle(0,width,0,w) shape = subtract(shape,triangle(0,0,0,w,width/2-.75*line,w/2)) shape = subtract(shape,triangle(width,0,width/2+.75*line,w/2,width,w)) shape = subtract(shape,triangle(1.25*line,0,width/2,w/2-.75*line,width-1.25*line,0)) shape = subtract(shape,triangle(1.25*line,w,width-1.25*line,w,width/2,w/2+.75*line)) shapes['x'] = shape w = height/2 shape = rectangle(0,width,w,height) shape = subtract(shape,triangle(0,w,0,height,width/2-line/2,w)) shape = subtract(shape,triangle(width/2+line/2,w,width,height,width,w)) shape = subtract(shape,triangle(1.1*line,height,width-1.1*line,height,width/2,w+1.1*line)) shape = add(shape,rectangle(width/2-line/2,width/2+line/2,0,w)) shapes['Y'] = shape shape = rectangle(0,width,-height/3,width) shape = subtract(shape,triangle(0,-height/3,0,width,width/2-.9*line,0)) shape = subtract(shape,triangle(1.1*line,width,width-1.1*line,width,width/2-.2*line,1.6*line)) shape = subtract(shape,triangle(1.2*line,-height/3,width,width,width,-height/3)) shapes['y'] = shape shape = rectangle(0,width,0,height) shape = subtract(shape,triangle(0,line,0,height-line,width-1.4*line,height-line)) shape = subtract(shape,triangle(1.4*line,line,width,height-line,width,line)) shapes['Z'] = shape w = 2*height/3 shape = rectangle(0,width,0,w) shape = subtract(shape,triangle(0,line,0,w-line,width-1.6*line,w-line)) shape = subtract(shape,triangle(width,line,1.6*line,line,width,w-line)) shapes['z'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/2-.9*line)) shape = scale_y(shape,0,height/width) shapes['0'] = shape shape = rectangle(width/2-line/2,width/2+line/2,0,height) w = width/2-line/2 cutout = circle(0,height,w) shape = add(shape,rectangle(0,width/2,height-w-line,height)) shape = subtract(shape,cutout) shape = move(shape,(width/2+line/2)/4,0) shapes['1'] = shape shape = circle(width/2,height-width/2,width/2) shape = subtract(shape,circle(width/2,height-width/2,width/2-line)) shape = subtract(shape,rectangle(0,width/2,0,height-width/2)) shape = add(shape,rectangle(0,width,0,height-width/2)) shape = subtract(shape,triangle(0,line,0,height-width/2,width-line,height-width/2)) shape = subtract(shape,triangle(1.5*line,line,width,height-width/2-.5*line,width,line)) shapes['2'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/2-line)) shape = scale_y(shape,0,(height/2+line/2)/width) shape = add(shape,move(shape,0,height/2-line/2)) shape = subtract(shape,rectangle(0,width/2,height/4,3*height/4)) shapes['3'] = shape shape = rectangle(width-line,width,0,height) shape = add(shape,triangle(0,height/3,width-line,height,width-line,height/3)) shape = subtract(shape,triangle(1.75*line,height/3+line,width-line,height-1.5*line,width-line,height/3+line)) shapes['4'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/2-line)) shape = subtract(shape,rectangle(0,width/2,width/2,width)) shape = add(shape,rectangle(0,width/2,width-line,width)) shape = add(shape,rectangle(0,line,width-line,height)) shape = add(shape,rectangle(0,width,height-line,height)) shapes['5'] = shape shape = circle(width/2,height-width/2,width/2) shape = subtract(shape,circle(width/2,height-width/2,width/2-line)) shape = subtract(shape,rectangle(0,width,0,height-width/2)) shape = subtract(shape,triangle(width,height,width,height/2,width/2,height/2)) shape = add(shape,circle(width/2,width/2,width/2)) shape = subtract(shape,circle(width/2,width/2,width/2-line)) shape = add(shape,rectangle(0,line,width/2,height-width/2)) shapes['6'] = shape shape = rectangle(0,width,0,height) shape = subtract(shape,triangle(0,0,0,height-line,width-line,height-line)) shape = subtract(shape,triangle(line,0,width,height-line,width,0)) shapes['7'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/2-line)) shape = scale_y(shape,0,(height/2+line/2)/width) shape = add(shape,move(shape,0,height/2-line/2)) shapes['8'] = shape shape = circle(width/2,width/2,width/2) shape = subtract(shape,circle(width/2,width/2,width/2-line)) shape = subtract(shape,rectangle(0,width,width/2,height)) shape = subtract(shape,triangle(0,0,0,height/2,width/2,height/2)) shape = add(shape,circle(width/2,height-width/2,width/2)) shape = subtract(shape,circle(width/2,height-width/2,width/2-line)) shape = add(shape,rectangle(width-line,width,width/2,height-width/2)) shapes['9'] = shape w = width/2 shape = circle(w,w,w) shape = subtract(shape,circle(w,w,w-line)) shape = subtract(shape,rectangle(w,width,0,height)) shape = scale_y(shape,0,height/width) shape = move(shape,w/2,0) shapes['('] = shape shape = reflect_x(shape,width) shapes[')'] = shape shapes[' '] = False shape = rectangle(width/2-width/3,width/2+width/3,height/2-line/2,height/2+line/2) shape = add(shape,rectangle(width/2-line/2,width/2+line/2,height/2-width/3,height/2+width/3)) shapes['+'] = shape shape = rectangle(width/2-width/3,width/2+width/3,height/2-line/2,height/2+line/2) shapes['-'] = shape shape = circle(width/2,line,.75*line) shapes['.'] = shape shape = rectangle(0,width,0,height) d = .8*line shape = subtract(shape,triangle(d,0,width,height-d,width,0)) shape = subtract(shape,triangle(0,d,0,height,width-d,height)) shapes['/'] = shape # # to be done # shapes['~'] = shape shapes['!'] = shape shapes['@'] = shape shapes['#'] = shape shapes['$'] = shape shapes['%'] = shape shapes['^'] = shape shapes['&'] = shape shapes['&'] = shape shapes['_'] = shape shapes['='] = shape shapes['['] = shape shapes['{'] = shape shapes[']'] = shape shapes['}'] = shape shapes[';'] = shape shapes[':'] = shape shapes["'"] = shape shapes['"'] = shape shapes[','] = shape shapes['<'] = shape shapes['>'] = shape shapes['?'] = shape # # add a line to text shape # def addline(lineshape): # # LR align # if (align[0] == 'C'): lineshape = move(lineshape,-self.width/2.0,0) elif (align[0] == 'R'): lineshape = move(lineshape,-self.width,0) # # add # self.shape = add(self.shape,lineshape) # # loop over chars # dx = 0 dy = -height self.width = -space self.height = height lineshape = False self.shape = False for chr in text: if (chr == '\n'): addline(lineshape) dx = 0 dy -= 1.5*self.height self.width = -space self.height += 1.5*self.height lineshape = False else: lineshape = add(lineshape,move(shapes[chr],dx,dy)) self.width += space + width dx += width + space addline(lineshape) # # UD align # if (align[1] == 'C'): self.shape = move(self.shape,0,self.height/2.0) elif (align[1] == 'B'): self.shape = move(self.shape,0,self.height) # # rotate # if (angle == 90): self.shape = rotate_90(self.shape) elif (angle == 180): self.shape = rotate_180(self.shape) elif ((angle == 270) | (angle == -90)): self.shape = rotate_270(self.shape) elif (angle != 0): self.shape = rotate(self.shape,angle) # # translate # self.shape = move(self.shape,x,y) # # color # self.shape = '('+str(color)+'*(('+self.shape+')!=0))' # # PCB classes and definitions # class PCB: def __init__(self,x0,y0,width,height,mask): self.board = False self.labels = False self.interior = rectangle(x0,x0+width,y0,y0+height) self.exterior = subtract(True,rectangle(x0,x0+width,y0,y0+height)) self.mask = False def add(self,part): self.board = add(self.board,part) self.mask = add(self.mask,move(part,-mask,mask)) self.mask = add(self.mask,move(part,-mask,-mask)) self.mask = add(self.mask,move(part,mask,mask)) self.mask = add(self.mask,move(part,mask,-mask)) return self class point: def __init__(self,x,y,z=0): self.x = x self.y = y self.z = z class part: class text: def __init__(self,x,y,z=0,text='',line=0.006,angle=0): self.x = x self.y = y self.z = z self.text = text self.line = line self.angle = angle def add(self,pcb,x,y,z=0,angle=0,line=0.007): self.x = x self.y = y self.z = z self.angle = angle if (angle == 90): self.shape = rotate_90(self.shape) elif (angle == 180): self.shape = rotate_180(self.shape) elif ((angle == 270) | (angle == -90)): self.shape = rotate_270(self.shape) elif (angle != 0): self.shape = rotate(self.shape,angle) deg_angle = angle angle = pi*angle/180 self.shape = translate(self.shape,x,y,z) for i in range(len(self.pad)): xnew = cos(angle)*self.pad[i].x - sin(angle)*self.pad[i].y ynew = sin(angle)*self.pad[i].x + cos(angle)*self.pad[i].y self.pad[i].x = x + xnew self.pad[i].y = y + ynew self.pad[i].z += z pcb.labels = add(pcb.labels,text(self.value,x,y,z,line=line,color=Green).shape) for i in range(len(self.labels)): xnew = cos(angle)*self.labels[i].x - sin(angle)*self.labels[i].y ynew = sin(angle)*self.labels[i].x + cos(angle)*self.labels[i].y self.labels[i].x = x + xnew self.labels[i].y = y + ynew self.labels[i].z += z if ((-90 < deg_angle) & (deg_angle <= 90)): pcb.labels = add(pcb.labels,text(self.labels[i].text,self.labels[i].x,self.labels[i].y,self.labels[i].z,self.labels[i].line,color=Red,angle=deg_angle-self.labels[i].angle).shape) else: pcb.labels = add(pcb.labels,text(self.labels[i].text,self.labels[i].x,self.labels[i].y,self.labels[i].z,self.labels[i].line,color=Red,angle=(deg_angle-self.labels[i].angle-180)).shape) pcb = pcb.add(self.shape) return pcb def layer(self,pcb,z): pcb = pcb.add(translate(self.shape,0,0,z)) return pcb def wire(pcb,width,*points): for i in range(1,len(points)): x0 = points[i-1].x y0 = points[i-1].y z0 = points[i-1].z x1 = points[i].x y1 = points[i].y z1 = points[i].z if (x0 < x1): pcb.board = add(pcb.board,cube(x0-width/2,x1+width/2,y0-width/2,y0+width/2,z0,z0)) elif (x1 < x0): pcb.board = add(pcb.board,cube(x1-width/2,x0+width/2,y0-width/2,y0+width/2,z0,z0)) if (y0 < y1): pcb.board = add(pcb.board,cube(x1-width/2,x1+width/2,y0-width/2,y1+width/2,z0,z0)) elif (y1 < y0): pcb.board = add(pcb.board,cube(x1-width/2,x1+width/2,y1-width/2,y0+width/2,z0,z0)) return pcb # # PCB library # # # discretes # pad_SJ = cube(-.02,.02,-.03,.03,0,0) class SJ(part): # # solder jumper # def __init__(self,value=''): self.value = value self.labels = [] self.pad = [point(0,0,0)] self.shape = translate(pad_SJ,-.029,0,0) self.pad.append(point(-.029,0,0)) self.shape = add(self.shape,translate(pad_SJ,.029,0,0)) self.pad.append(point(.029,0,0)) pad_1206 = cube(-.032,.032,-.034,.034,0,0) class R_1206(part): # # 1206 resistor # def __init__(self,value=''): self.value = value self.labels = [] self.pad = [point(0,0,0)] self.shape = translate(pad_1206,-.06,0,0) self.pad.append(point(-.06,0,0)) self.shape = add(self.shape,translate(pad_1206,.06,0,0)) self.pad.append(point(.06,0,0)) class Pad_1206(part): # # 1206 single pad # def __init__(self,value=''): self.value = value self.labels = [] self.pad = [point(0,0,0)] self.shape = translate(pad_1206,.0,0,0) self.pad.append(point(.0,0,0)) class C_1206(part): # # 1206 capacitor # def __init__(self,value=''): self.value = value self.labels = [] self.pad = [point(0,0,0)] self.shape = translate(pad_1206,-.06,0,0) self.pad.append(point(-.06,0,0)) self.shape = add(self.shape,translate(pad_1206,.06,0,0)) self.pad.append(point(.06,0,0)) pad_1210 = cube(-.032,.032,-.048,.048,0,0) class L_1210(part): # # 1210 inductor # def __init__(self,value=''): self.value = value self.labels = [] self.pad = [point(0,0,0)] self.shape = translate(pad_1210,-.06,0,0) self.pad.append(point(-.06,0,0)) self.shape = add(self.shape,translate(pad_1210,.06,0,0)) self.pad.append(point(.06,0,0)) pad_choke = cube(-.06,.06,-.06,.06,0,0) class choke(part): # # Panasonic ELLCTV # def __init__(self,value=''): self.value = value self.labels = [] self.pad = [point(0,0,0)] self.shape = translate(pad_choke,-.177,-.177,0) self.pad.append(point(-.177,-.177,0)) self.shape = add(self.shape,translate(pad_choke,.177,.177,0)) self.pad.append(point(.177,.177,0)) pad_header = cube(-.05,.05,-.025,.025,0,0) class header_4(part): # # 4-pin header # fci 95278-101a04lf bergstik 2x2x0.1" # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1 # self.shape = translate(pad_header,-.107,.05,0) self.shape = add(self.shape,cylinder(-.157,.05,0,0,.025)) self.pad.append(point(-.107,.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'1')) # # pin 2 # self.shape = add(self.shape,translate(pad_header,.107,.05,0)) self.pad.append(point(.107,.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'2')) # # pin 3 # self.shape = add(self.shape,translate(pad_header,-.107,-.05,0)) self.pad.append(point(-.107,-.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'3')) # # pin 4 # self.shape = add(self.shape,translate(pad_header,.107,-.05,0)) self.pad.append(point(.107,-.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'4')) class header_power(part): # # power header # FCI 95278-101A04LF Bergstik 2x2x0.1" # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: Gnd # self.shape = translate(pad_header,.107,-.05,0) self.shape = add(self.shape,cylinder(.157,-.05,0,0,.025)) self.pad.append(point(.107,-.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND')) # # pin 2 # self.shape = add(self.shape,translate(pad_header,-.107,-.05,0)) self.pad.append(point(-.107,-.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'')) # # pin 3: V # self.shape = add(self.shape,translate(pad_header,.107,.05,0)) self.pad.append(point(.107,.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'V')) # # pin 4: # self.shape = add(self.shape,translate(pad_header,-.107,.05,0)) self.pad.append(point(-.107,.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'')) class header_serial(part): # # serial comm header # FCI 95278-101A04LF Bergstik 2x2x0.1" # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: Gnd # self.shape = translate(pad_header,.107,-.05,0) self.shape = add(self.shape,cylinder(.157,-.05,0,0,.025)) self.pad.append(point(.107,-.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND')) # # pin 2:DTR # self.shape = add(self.shape,translate(pad_header,-.107,-.05,0)) self.pad.append(point(-.107,-.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'DTR')) # # pin 3: Tx # self.shape = add(self.shape,translate(pad_header,.107,.05,0)) self.pad.append(point(.107,.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Tx')) # # pin 4: Rx # self.shape = add(self.shape,translate(pad_header,-.107,.05,0)) self.pad.append(point(-.107,.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Rx')) class header_6(part): # # 6-pin header # FCI 95278-101A06LF Bergstik 2x3x0.1" # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1 # self.shape = translate(pad_header,.107,-.1,0) self.shape = add(self.shape,cylinder(.157,-.1,0,0,.025)) self.pad.append(point(.107,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'')) # # pin 2 # self.shape = add(self.shape,translate(pad_header,-.107,-.1,0)) self.pad.append(point(-.107,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'')) # # pin 3 # self.shape = add(self.shape,translate(pad_header,.107,0,0)) self.pad.append(point(.107,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'')) # # pin 4 # self.shape = add(self.shape,translate(pad_header,-.107,0,0)) self.pad.append(point(-.107,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'')) # # pin 5 # self.shape = add(self.shape,translate(pad_header,.107,.1,0)) self.pad.append(point(.107,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'')) # # pin 6 # self.shape = add(self.shape,translate(pad_header,-.107,.1,0)) self.pad.append(point(-.107,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'')) class header_ISP(part): # # in-circuit programming header # FCI 95278-101A06LF Bergstik 2x3x0.1" # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: MISO # self.shape = translate(pad_header,.107,-.1,0) self.shape = add(self.shape,cylinder(.157,-.1,0,0,.025)) self.pad.append(point(.107,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'MISO')) # # pin 2: V # self.shape = add(self.shape,translate(pad_header,-.107,-.1,0)) self.pad.append(point(-.107,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'V')) # # pin 3: SCK # self.shape = add(self.shape,translate(pad_header,.107,0,0)) self.pad.append(point(.107,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'SCK')) # # pin 4: MOSI # self.shape = add(self.shape,translate(pad_header,-.107,0,0)) self.pad.append(point(-.107,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'MOSI')) # # pin 5: RST # self.shape = add(self.shape,translate(pad_header,.107,.1,0)) self.pad.append(point(.107,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'RST')) # # pin 6: GND # self.shape = add(self.shape,translate(pad_header,-.107,.1,0)) self.pad.append(point(-.107,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND')) class header_FTDI(part): # # FTDI cable header # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: GND (black) # self.shape = translate(pad_header,0,.25,0) self.shape = add(self.shape,cylinder(-.05,.25,0,0,.025)) self.pad.append(point(0,.25,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'G (blk)')) # # pin 2: CTS (brown) # self.shape = add(self.shape,translate(pad_header,0,.15,0)) self.pad.append(point(0,.15,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'CTS')) # # pin 3: VCC (red) # self.shape = add(self.shape,translate(pad_header,0,.05,0)) self.pad.append(point(0,.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'VCC')) # # pin 4: Tx (orange) # self.shape = add(self.shape,translate(pad_header,0,-0.05,0)) self.pad.append(point(0,-.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Tx')) # # pin 5: Rx (yellow) # self.shape = add(self.shape,translate(pad_header,0,-.15,0)) self.pad.append(point(0,-.15,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Rx')) # # pin 6: RTS (green) # self.shape = add(self.shape,translate(pad_header,0,-.25,0)) self.pad.append(point(0,-.25,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'RTS')) pad_MTA = cube(-.021,.021,-.041,.041,0,0) pad_MTA_solder = cube(-.071,.071,-.041,.041,0,0) class MTA_2(part): # # AMP 1445121-2 # MTA .050 SMT 2-pin vertical # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1 # self.shape = translate(pad_MTA,-.025,-.1,0) self.pad.append(point(-.025,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'1')) # # pin 2 # self.shape = add(self.shape,translate(pad_MTA,.025,.1,0)) self.pad.append(point(.025,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'2')) # # solder pads # self.shape = add(self.shape,translate(pad_MTA_solder,-.187,0,0)) self.shape = add(self.shape,translate(pad_MTA_solder,.187,0,0)) class MTA_power(part): # # AMP 1445121-2 # MTA .050 SMT 2-pin vertical # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: Gnd # self.shape = translate(pad_MTA,-.025,-.1,0) self.pad.append(point(-.025,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'1\nGND')) # # pin 2: Vcc # self.shape = add(self.shape,translate(pad_MTA,.025,.1,0)) self.pad.append(point(.025,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Vcc')) # # solder pads # self.shape = add(self.shape,translate(pad_MTA_solder,-.187,0,0)) self.shape = add(self.shape,translate(pad_MTA_solder,.187,0,0)) class MTA_3(part): # # AMP 1445121-3 # MTA .050 SMT 3-pin vertical # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: GND # self.shape = translate(pad_MTA,.05,.1,0) self.pad.append(point(.05,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'1')) # # pin 2: power # self.shape = add(self.shape,translate(pad_MTA,-.05,.1,0)) self.pad.append(point(-.05,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'2')) # # pin 3: data # self.shape = add(self.shape,translate(pad_MTA,0,-.1,0)) self.pad.append(point(0,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'3')) # # solder pads # self.shape = add(self.shape,translate(pad_MTA_solder,-.212,0,0)) self.shape = add(self.shape,translate(pad_MTA_solder,.212,0,0)) class MTA_i0(part): # # AMP 1445121-3 # MTA .050 SMT 3-pin vertical # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: GND # self.shape = translate(pad_MTA,.05,.1,0) self.pad.append(point(.05,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'1\nGND')) # # pin 2: power # self.shape = add(self.shape,translate(pad_MTA,-.05,.1,0)) self.pad.append(point(-.05,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'V')) # # pin 3: data # self.shape = add(self.shape,translate(pad_MTA,0,-.1,0)) self.pad.append(point(0,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'data')) # # solder pads # self.shape = add(self.shape,translate(pad_MTA_solder,-.212,0,0)) self.shape = add(self.shape,translate(pad_MTA_solder,.212,0,0)) class MTA_4(part): # # AMP 1445121-4 # MTA .050 SMT 4-pin vertical # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1 # self.shape = translate(pad_MTA,-.075,-.1,0) self.pad.append(point(-.075,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'1')) # # pin 2 # self.shape = add(self.shape,translate(pad_MTA,.025,-.1,0)) self.pad.append(point(.025,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'2')) # # pin 3 # self.shape = add(self.shape,translate(pad_MTA,.075,.1,0)) self.pad.append(point(.075,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'3')) # # pin 4 # self.shape = add(self.shape,translate(pad_MTA,-.025,.1,0)) self.pad.append(point(-.025,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'4')) # # solder pads # self.shape = add(self.shape,translate(pad_MTA_solder,-.237,0,0)) self.shape = add(self.shape,translate(pad_MTA_solder,.237,0,0)) class MTA_serial(part): # # AMP 1445121-4 # MTA .050 SMT 4-pin vertical # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: Gnd # self.shape = translate(pad_MTA,-.075,-.1,0) self.pad.append(point(-.075,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'1')) # # pin 2: Tx # self.shape = add(self.shape,translate(pad_MTA,.025,-.1,0)) self.pad.append(point(.025,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Tx')) # # pin 3: Rx # self.shape = add(self.shape,translate(pad_MTA,.075,.1,0)) self.pad.append(point(.075,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Rx')) # # pin 4: DTR # self.shape = add(self.shape,translate(pad_MTA,-.025,.1,0)) self.pad.append(point(-.025,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'DTR')) # # solder pads # self.shape = add(self.shape,translate(pad_MTA_solder,-.237,0,0)) self.shape = add(self.shape,translate(pad_MTA_solder,.237,0,0)) class MTA_PS2(part): # # AMP 1445121-4 # MTA .050 SMT 4-pin vertical # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: GND # self.shape = translate(pad_MTA,-.075,-.1,0) self.pad.append(point(-.075,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'1\nGND')) # # pin 2: data # self.shape = add(self.shape,translate(pad_MTA,.025,-.1,0)) self.pad.append(point(.025,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'data')) # # pin 3: clock # self.shape = add(self.shape,translate(pad_MTA,.075,.1,0)) self.pad.append(point(.075,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'clock')) # # pin 4: 5V # self.shape = add(self.shape,translate(pad_MTA,-.025,.1,0)) self.pad.append(point(-.025,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'5V')) # # solder pads # self.shape = add(self.shape,translate(pad_MTA_solder,-.237,0,0)) self.shape = add(self.shape,translate(pad_MTA_solder,.237,0,0)) class MTA_5(part): # # AMP 1445121-5 # MTA .050 SMT 5-pin vertical # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1 # self.shape = translate(pad_MTA,-.1,-.1,0) self.pad.append(point(-.1,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'1')) # # pin 2 # self.shape = add(self.shape,translate(pad_MTA,0,-.1,0)) self.pad.append(point(0,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'2')) # # pin 3 # self.shape = add(self.shape,translate(pad_MTA,.1,-.1,0)) self.pad.append(point(.1,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'3')) # # pin 4 # self.shape = add(self.shape,translate(pad_MTA,.05,.1,0)) self.pad.append(point(.05,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'4')) # # pin 5 # self.shape = add(self.shape,translate(pad_MTA,-.05,.1,0)) self.pad.append(point(-.05,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'5')) # # solder pads # self.shape = add(self.shape,translate(pad_MTA_solder,-.262,0,0)) self.shape = add(self.shape,translate(pad_MTA_solder,.262,0,0)) class MTA_ICP(part): # # AMP 1445121-5 # MTA .050 SMT 5-pin vertical # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: MISO # self.shape = translate(pad_MTA,-.1,-.1,0) self.pad.append(point(-.1,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'MISO')) # # pin 2: GND # self.shape = add(self.shape,translate(pad_MTA,0,-.1,0)) self.pad.append(point(0,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND')) # # pin 3: MOSI # self.shape = add(self.shape,translate(pad_MTA,.1,-.1,0)) self.pad.append(point(.1,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'MOSI')) # # pin 4: -RESET # self.shape = add(self.shape,translate(pad_MTA,.05,.1,0)) self.pad.append(point(.05,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'-RESET')) # # pin 5: SCK # self.shape = add(self.shape,translate(pad_MTA,-.05,.1,0)) self.pad.append(point(-.05,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'SCK')) # # solder pads # self.shape = add(self.shape,translate(pad_MTA_solder,-.262,0,0)) self.shape = add(self.shape,translate(pad_MTA_solder,.262,0,0)) # # switches # pad_button_6mm = cube(-.04,.04,-.03,.03,0,0) class button_6mm(part): # # Omron 6mm pushbutton # B3SN-3112P # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # left 1 # self.shape = translate(pad_button_6mm,-.125,.08,0) self.pad.append(point(-.125,.08,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'L1')) # # right 1 # self.shape = add(self.shape,translate(pad_button_6mm,-.125,-.08,0)) self.pad.append(point(-.125,-.08,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'R1')) # # right 2 # self.shape = add(self.shape,translate(pad_button_6mm,.125,-.08,0)) self.pad.append(point(.125,-.08,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'R2')) # # left 2 # self.shape = add(self.shape,translate(pad_button_6mm,.125,.08,0)) self.pad.append(point(.125,.08,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'L2')) # # crystals and resonators # pad_XTAL_EFOBM = cube(-.016,.016,-.085,.085,0,0) class XTAL_EFOBM(part): # # Panasonic EFOBM series # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # left # self.shape = translate(pad_XTAL_EFOBM,-.053,0,0) self.pad.append(point(-.053,0,0)) # # ground # self.shape = add(self.shape,translate(pad_XTAL_EFOBM,0,0,0)) self.pad.append(point(0,0,0)) # # right # self.shape = add(self.shape,translate(pad_XTAL_EFOBM,.053,0,0)) self.pad.append(point(.053,0,0)) pad_XTAL_NX5032GA = cube(-.039,.039,-.047,.047,0,0) .079 class XTAL_NX5032GA(part): # # NDK NX5032GA # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # left # self.shape = translate(pad_XTAL_NX5032GA,-.079,0,0) self.pad.append(point(-.079,0,0)) # # right # self.shape = add(self.shape,translate(pad_XTAL_NX5032GA,.079,0,0)) self.pad.append(point(.079,0,0)) pad_XTAL_CSM_7 = cube(-.108,.108,-.039,.039,0,0) class XTAL_CSM_7(part): # # ECS CSM-7 series # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # left # self.shape = translate(pad_XTAL_CSM_7,-.187,0,0) self.pad.append(point(-.187,0,0)) # # right # self.shape = add(self.shape,translate(pad_XTAL_CSM_7,.187,0,0)) self.pad.append(point(.187,0,0)) # # diodes, transistors, regulators # class D_1206(part): # # 1206 diode # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # anode # self.shape = translate(pad_1206,-.06,0,0) self.pad.append(point(-.055,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'A')) # # cathode # self.shape = add(self.shape,translate(pad_1206,.06,0,0)) self.pad.append(point(.055,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'C')) class LED_1206(part): # # 1206 LED # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # anode # self.shape = translate(pad_1206,-.06,0,0) self.pad.append(point(-.055,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'A')) # # cathode # self.shape = add(self.shape,translate(pad_1206,.06,0,0)) self.pad.append(point(.055,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'C')) pad_SOD_123 = cube(-.02,.02,-.024,.024,0,0) class D_SOD_123(part): # # SOD-123 diode # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # anode # self.shape = translate(pad_SOD_123,-.07,0,0) self.pad.append(point(-.07,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'A')) # # cathode # self.shape = add(self.shape,translate(pad_SOD_123,.07,0,0)) self.pad.append(point(.07,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'C')) class regulator_SOT23(part): def __init__(self,value=''): self.value = value self.x = 0 self.y = 0 self.z = 0 self.pad = [point(0,0,0)] self.labels = [] # # pin 1: output # self.shape = translate(pad_SOT23,-.045,.0375,0) self.pad.append(point(-.045,.0375,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'out')) # # pin 2: input # self.shape = add(self.shape,translate(pad_SOT23,-.045,-.0375,0)) self.pad.append(point(-.045,-.0375,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'in')) # # pin 3: ground # self.shape = add(self.shape,translate(pad_SOT23,.045,0,0)) self.pad.append(point(.045,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'gnd')) pad_SOT223 = cube(-.02,.02,-.03,.03,0,0) pad_SOT223_ground = cube(-.065,.065,-.03,.03,0,0) class regulator_SOT223(part): def __init__(self,value=''): self.value = value self.x = 0 self.y = 0 self.z = 0 self.pad = [point(0,0,0)] self.labels = [] # # pin 1: input # self.shape = translate(pad_SOT223,-.09,-.12,0) self.pad.append(point(-.09,-.12,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'1I')) # # pin 2: ground # self.shape = add(self.shape,translate(pad_SOT223,0,-.12,0)) self.pad.append(point(0,-.12,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'G')) # # pin 3: output # self.shape = add(self.shape,translate(pad_SOT223,.09,-.12,0)) self.pad.append(point(.09,-.12,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'O')) # # pin 4: ground # self.shape = add(self.shape,translate(pad_SOT223_ground,0,.12,0)) self.pad.append(point(0,.12,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'G')) # # ICs # pad_SOIC = cube(-.041,.041,-.015,.015,0,0) class ATtiny45_SOIC(part): def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: PB5/dW/ADC0/-RESET/PCINT5 # self.shape = translate(pad_SOIC,-.14,.075,0) self.shape = add(self.shape,cylinder(-.183,.075,0,0,.015)) self.pad.append(point(-.14,.075,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'RST')) # # pin 2: PB3/ADC3/-OC1B/CLKI/XTAL1/PCINT3 # self.shape = add(self.shape,translate(pad_SOIC,-.14,.025,0)) self.pad.append(point(-.14,.025,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB3')) # # pin 3: PB4/ADC2/OC1B/CLKO/XTAL2/PCINT4 # self.shape = add(self.shape,translate(pad_SOIC,-.14,-.025,0)) self.pad.append(point(-.14,-.025,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB4')) # # pin 4: GND # self.shape = add(self.shape,translate(pad_SOIC,-.14,-.075,0)) self.pad.append(point(-.14,-.075,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND')) # # pin 5: PB0/MOSI/DI/SDA/AIN0/OC0A/-OC1A/AREF/PCINT0 # self.shape = add(self.shape,translate(pad_SOIC,.14,-.075,0)) self.pad.append(point(.14,-.075,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB0')) # # pin 6: PB1/MISO/DO/AIN1/OC0B/OC1A/PCINT1 # self.shape = add(self.shape,translate(pad_SOIC,.14,-.025,0)) self.pad.append(point(.14,-.025,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB1')) # # pin 7: PB2/SCK/USCK/SCL/ADC1/T0/INT0/PCINT2 # self.shape = add(self.shape,translate(pad_SOIC,.14,.025,0)) self.pad.append(point(.14,.025,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB2')) # # pin 8: VCC # self.shape = add(self.shape,translate(pad_SOIC,.14,.075,0)) self.pad.append(point(.14,.075,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'VCC')) pad_SOICN = cube(-.035,.035,-.015,.015,0,0) class ATtiny44_SOICN(part): def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: VCC # self.shape = translate(pad_SOICN,-.12,.15,0) self.shape = add(self.shape,cylinder(-.155,.15,0,0,.015)) self.pad.append(point(-.12,.15,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'VCC')) # # pin 2: PB0/XTAL1/PCINT8 # self.shape = add(self.shape,translate(pad_SOICN,-.12,.1,0)) self.pad.append(point(-.12,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB0')) # # pin 3: PB1/XTAL2/PCINT9 # self.shape = add(self.shape,translate(pad_SOICN,-.12,.050,0)) self.pad.append(point(-.12,.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB1')) # # pin 4: PB3/dW/-RESET/PCINT11 # self.shape = add(self.shape,translate(pad_SOICN,-.12,0,0)) self.pad.append(point(-.12,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB3')) # # pin 5: PB2/CKOUT/OC0A/INT0/PCINT10 # self.shape = add(self.shape,translate(pad_SOICN,-.12,-.05,0)) self.pad.append(point(-.12,-.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB2')) # # pin 6: PA7/ADC7/OC0B/ICP/PCINT7 # self.shape = add(self.shape,translate(pad_SOICN,-.12,-.1,0)) self.pad.append(point(-.12,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA7')) # # pin 7: PA6/ADC6/MOSI/SDA/OC1A/PCINT6 # self.shape = add(self.shape,translate(pad_SOICN,-.12,-.15,0)) self.pad.append(point(-.12,-.15,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA6')) # # pin 8: PA5/ADC5/DO/MISO/OC1B/PCINT5 # self.shape = add(self.shape,translate(pad_SOICN,.12,-.15,0)) self.pad.append(point(.12,-.15,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA5')) # # pin 9: PA4/ADC4/USCK/SCL/T1/PCINT4 # self.shape = add(self.shape,translate(pad_SOICN,.12,-.1,0)) self.pad.append(point(.12,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA4')) # # pin 10: PA3/ADC3/T0/PCINT3 # self.shape = add(self.shape,translate(pad_SOICN,.12,-.05,0)) self.pad.append(point(.12,-.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA3')) # # pin 11: PA2/ADC2/AIN1/PCINT2 # self.shape = add(self.shape,translate(pad_SOICN,.12,0,0)) self.pad.append(point(.12,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA2')) # # pin 12: PA1/ADC1/AIN0/PCINT1 # self.shape = add(self.shape,translate(pad_SOICN,.12,.050,0)) self.pad.append(point(.12,.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA1')) # # pin 13: PA0/ADC0/AREF/PCINT0 # self.shape = add(self.shape,translate(pad_SOICN,.12,.1,0)) self.pad.append(point(.12,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA0')) # # pin 14: GND # self.shape = add(self.shape,translate(pad_SOICN,.12,.15,0)) self.pad.append(point(.12,.15,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND')) class header_txrx(part): # # 4-pin header for txrx # fci 95278-101a04lf bergstik 2x2x0.1" # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1 # self.shape = translate(pad_header,-.107,.05,0) self.shape = add(self.shape,cylinder(-.157,.05,0,0,.025)) self.pad.append(point(-.107,.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Rx')) # # pin 2 # self.shape = add(self.shape,translate(pad_header,.107,.05,0)) self.pad.append(point(.107,.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND')) # # pin 3 # self.shape = add(self.shape,translate(pad_header,-.107,-.05,0)) self.pad.append(point(-.107,-.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND')) # # pin 4 # self.shape = add(self.shape,translate(pad_header,.107,-.05,0)) self.pad.append(point(.107,-.05,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Tx')) class header_rx(part): # # header for 6 recieves # # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: # self.shape = translate(pad_header,.107,-.1,0) #self.shape = add(self.shape,cylinder(.157,-.1,0,0,.025)) self.pad.append(point(.107,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Rx1')) # # pin 2: # self.shape = add(self.shape,translate(pad_header,-.107,-.1,0)) self.pad.append(point(-.107,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Rx2')) # # pin 3: # self.shape = add(self.shape,translate(pad_header,.107,0,0)) self.pad.append(point(.107,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Rx3')) # # pin 4: # self.shape = add(self.shape,translate(pad_header,-.107,0,0)) self.pad.append(point(-.107,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Rx4')) # # pin 5: # self.shape = add(self.shape,translate(pad_header,.107,.1,0)) self.pad.append(point(.107,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Rx5')) # # pin 6: # self.shape = add(self.shape,translate(pad_header,-.107,.1,0)) self.pad.append(point(-.107,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Rx6')) class header_txg(part): # # header for 4 transmits and ground # # def __init__(self,value=''): self.value = value self.pad = [point(0,0,0)] self.labels = [] # # pin 1: # self.shape = translate(pad_header,.107,-.1,0) self.shape = add(self.shape,cylinder(.157,-.1,0,0,.025)) self.pad.append(point(.107,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Tx1')) # # pin 2: # self.shape = add(self.shape,translate(pad_header,-.107,-.1,0)) self.pad.append(point(-.107,-.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Tx2')) # # pin 3: # self.shape = add(self.shape,translate(pad_header,.107,0,0)) self.pad.append(point(.107,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Tx3')) # # pin 4: # self.shape = add(self.shape,translate(pad_header,-.107,0,0)) self.pad.append(point(-.107,0,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Tx4')) # # pin 5: # self.shape = add(self.shape,translate(pad_header,.107,.1,0)) self.pad.append(point(.107,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'gnd')) # # pin 6: # self.shape = add(self.shape,translate(pad_header,-.107,.1,0)) self.pad.append(point(-.107,.1,0)) self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'gnd')) # # define board # x0 = 1 y0 = 1 width = 1.18 height = 1.1 z = -.005 w = .018 mask = .004 pcb = PCB(x0,y0,width,height,mask) IC1 = ATtiny44_SOICN('IC1\nt44') pcb = IC1.add(pcb,x0+.62,y0+.77,z,angle=-90) R1 = R_1206('R1\n10k') pcb = R1.add(pcb,IC1.pad[1].x+.1,IC1.pad[1].y+.02,z,angle=-90) pcb = wire(pcb,w, IC1.pad[1], point(IC1.pad[1].x,R1.pad[1].y,z), R1.pad[1]) pcb = wire(pcb,w, IC1.pad[4], point(IC1.pad[4].x,IC1.pad[3].y-.065,z), R1.pad[2]) C1 = C_1206('C1\n1uF') pcb = C1.add(pcb,R1.x,R1.y-.2,z,angle=-90) pcb = wire(pcb,w, C1.pad[2],IC1.pad[14]) J2 = header_FTDI('J2 FTDI') pcb = J2.add(pcb,x0+width-.15,R1.y-.12,z) pcb = wire(pcb,w, R1.pad[1], point(R1.x+.07,J2.pad[3].y,z), J2.pad[3]) pcb = wire(pcb,w, C1.pad[1], point(C1.x+.07,J2.pad[3].y,z), J2.pad[3]) pcb = wire(pcb,w, point(J2.pad[5].x,J2.pad[5].y+.02,z), #point(J2.x,J2.pad[5].y-.05,z), point(J2.x-.075,IC1.pad[13].y+.06,z), IC1.pad[13]) J3 = header_rx('J3\nRx') pcb = J3.add(pcb,IC1.x-.41,IC1.y-.32,z,angle=0) J4 = header_txg('J4\ntxg') pcb = J4.add(pcb,J3.x,IC1.y+.17,z,angle=0) pcb = wire(pcb,w,J4.pad[5],J4.pad[6]) pcb = wire(pcb,w,J4.pad[5],point(J4.x,J2.pad[1].y,z),J2.pad[1]) pcb = wire(pcb,w, IC1.pad[2], point(IC1.pad[2].x,J4.pad[4].y+.05,z), J4.pad[4]) pcb = wire(pcb,w, IC1.pad[3], point(IC1.pad[3].x,J4.pad[4].y+.01,z), J4.pad[3]) pcb = wire(pcb,w, IC1.pad[6], point(IC1.pad[6].x,J4.pad[1].y-.01,z), J4.pad[1]) pcb = wire(pcb,w, IC1.pad[5], point(IC1.pad[5].x,J4.pad[2].y-.05,z), J4.pad[2]) x = J3.x+.35 y = J3.y+.07 iic = [] rr = [] #J3pads = for i in range(6): icp = Pad_1206('') pcb = icp.add(pcb,x-.12,y,z) icp2 = Pad_1206('') pcb = icp2.add(pcb,x+.185,y,z) R = R_1206('R%d\n1M'%(2*i+2)) pcb = R.add(pcb,x+.06,y,z,angle=0) RR = R_1206('R%d\n1M'%(2*i+1+2)) pcb = RR.add(pcb,R.x+.25,R.pad[1].y,z,angle=0) pcb = wire(pcb,w,R.pad[2],RR.pad[1]) rr.append([R,RR]) iic.append([icp,icp2]) y -= .085 pcb = wire(pcb,w,rr[0][1].pad[2],rr[-1][1].pad[2]) pcb = wire(pcb,w,rr[0][0].pad[1],rr[-1][0].pad[1]) #ic to array pcb = wire(pcb,w, IC1.pad[12], point(IC1.pad[12].x, IC1.pad[12].y-.07,z), point(rr[0][1].x, rr[4][0].pad[2].y,z), rr[4][1].pad[1]) pcb = wire(pcb,w, IC1.pad[11], point(IC1.pad[11].x, IC1.pad[11].y-.07,z), point(rr[1][0].x, rr[1][0].pad[2].y,z), rr[1][0].pad[2]) pcb = wire(pcb,w, IC1.pad[7], point(J3.pad[2].x-.08,J3.pad[2].y,z), J3.pad[2]) pcb = wire(pcb,w, IC1.pad[10], point(IC1.pad[10].x,IC1.pad[10].y-.07,z), point(iic[2][0].x+.06,iic[2][0].y,z), iic[2][0]) pcb = wire(pcb,w, J3.pad[5], point(IC1.pad[8].x-.01,IC1.pad[8].y,z), IC1.pad[8]) pcb = wire(pcb,w, J3.pad[6], point(J3.pad[6].x,IC1.pad[9].y+.07,z), IC1.pad[9]) #j3 to array pcb = wire(pcb,w, J3.pad[2], point(J3.pad[2].x+.04,iic[5][0].y,z), iic[5][0]) pcb = wire(pcb,w, J3.pad[6], point(J3.x+.02,iic[3][0].pad[1].y,z), iic[3][0]) pcb = wire(pcb,w, J3.pad[4], point(J3.x-.02,iic[4][0].pad[1].y,z), iic[4][0]) pcb = wire(pcb,w, J3.pad[1], point(J3.pad[1].x,iic[2][0].y,z), iic[2][0]) pcb = wire(pcb,w, J3.pad[3], point(J3.pad[3].x+.08,iic[1][0].y,z), iic[1][0]) pcb = wire(pcb,w, J3.pad[5], point(iic[0][0].x,iic[0][0].y,z), iic[0][0]) #rails pcb = wire(pcb,w, point(C1.pad[2].x,C1.pad[2].y-.03,z), rr[0][1].pad[2]) J1 = R_1206('J1') pcb = J1.add(pcb,J2.x,rr[2][0].y,z,angle=90) pcb = wire(pcb,w, rr[-1][0].pad[1], point(rr[-1][0].pad[1].x,rr[-1][0].pad[1].y-.07,z), point(J1.pad[1].x,rr[-1][0].pad[1].y-.07,z), J1.pad[1]) pcb = wire(pcb,w, J1.pad[2], point(J2.pad[3].x+.08,J2.pad[3].y,z), J2.pad[3]) pcb = wire(pcb,w, rr[2][1].pad[2], point(J2.pad[3].x+.12,J2.pad[1].y,z), J2.pad[1]) # # select output # #output ='solder mask' if (output == "traces, labels, and exterior"): cad.function = add(add(color(Tan,pcb.board),pcb.labels),color(White,pcb.exterior)) elif (output == "traces and exterior"): cad.function = color(White,add(pcb.board,pcb.exterior)) elif (output == "interior"): cad.function = color(White,pcb.interior) elif (output == "exterior"): cad.function = color(White,pcb.exterior) elif(output == "traces"): cad.function = color(White,pcb.board) elif (output == "holes"): z = z-z cad.function = color(White,add(pcb.exterior,subtract(pcb.interior,pcb.board))) elif (output == "solder mask"): #cad.function = color(White,pcb.mask) thing = pcb.interior for i in iic: for j in i: thing = subtract(thing,j.shape) cad.function = color(White,thing) else: print "oops -- don't recognize output" # # set limits and parameters # d = 0.05 cad.xmin = x0-d # min x to render cad.xmax = x0+width+d # max x to render cad.ymin = y0-d # min y to render cad.ymax = y0+height+d # max y to render cad.zmin = cad.zmax = z # z to zender cad.mm_per_unit = 25.4 # use inch units cad.type = "RGB" # use RGB color