Skip to content
Snippets Groups Projects
pcb.py 204 KiB
Newer Older
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529
      # pin 15: PB3/PCINT3/OC2A/MOSI
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,2.5*d,-c,0))
      self.pad.append(point(2.5*d,-c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB3',angle=90,line=s))
      #
      # pin 16: PB4/PCINT4/MISO
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,3.5*d,-c,0))
      self.pad.append(point(3.5*d,-c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB4',angle=90,line=s))
      #
      # pin 17: PB5/SCK/PCINT5
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,-3.5*d,0))
      self.pad.append(point(c,-3.5*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB5',line=s))
      #
      # pin 18: AVCC
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,-2.5*d,0))
      self.pad.append(point(c,-2.5*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'AVCC',line=s))
      #
      # pin 19: ADC6
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,-1.5*d,0))
      self.pad.append(point(c,-1.5*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'ADC6',line=s))
      #
      # pin 20: AREF
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,-.5*d,0))
      self.pad.append(point(c,-.5*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'AREF',line=s))
      #
      # pin 21: GND
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,.5*d,0))
      self.pad.append(point(c,.5*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND',line=s))
      #
      # pin 22: ADC7
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,1.5*d,0))
      self.pad.append(point(c,1.5*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'ADC7',line=s))
      #
      # pin 23: PC0/ADC0/PCINT8
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,2.5*d,0))
      self.pad.append(point(c,2.5*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC0',line=s))
      #
      # pin 24: PC1/ADC1/PCINT9
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,3.5*d,0))
      self.pad.append(point(c,3.5*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC1',line=s))
      #
      # pin 25: PC2/ADC2/PCINT10
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,3.5*d,c,0))
      self.pad.append(point(3.5*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC2',angle=90,line=s))
      #
      # pin 26: PC3/ADC3/PCINT11
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,2.5*d,c,0))
      self.pad.append(point(2.5*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC3',angle=90,line=s))
      #
      # pin 27: PC4/ADC4/SDA/PCINT12
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,1.5*d,c,0))
      self.pad.append(point(1.5*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC4',angle=90,line=s))
      #
      # pin 28: PC5/ADC5/SCL/PCINT13
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,.5*d,c,0))
      self.pad.append(point(.5*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC5',angle=90,line=s))
      #
      # pin 29: PC6/-RESET/PCINT14
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-.5*d,c,0))
      self.pad.append(point(-.5*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC6',angle=90,line=s))
      #
      # pin 30: PD0/RXD/PCINT16
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-1.5*d,c,0))
      self.pad.append(point(-1.5*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PD0',angle=90,line=s))
      #
      # pin 31: PD1/TXD/PCINT17
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-2.5*d,c,0))
      self.pad.append(point(-2.5*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PD1',angle=90,line=s))
      #
      # pin 32: PD2/INT0/PCINT18
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-3.5*d,c,0))
      self.pad.append(point(-3.5*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PD2',angle=90,line=s))

class ATmega644_TQFP(part):
   def __init__(self,value=''):
      c = .235
      d = .031
      self.value = value
      self.pad = [point(0,0,0)]
      self.labels = []
      #
      # pin 1: PB5/PCINT13/MOSI
      #
      self.shape = translate(pad_TQFP_h,-c,5*d,0)
      self.pad.append(point(-c,5*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'*MOSI (1)'))
      #
      # pin 2: PB6/PCINT14/MISO
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,-c,4*d,0))
      self.pad.append(point(-c,4*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'MISO'))
      #
      # pin 3: PB7/PCINT15/SCK
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,-c,3*d,0))
      self.pad.append(point(-c,3*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'SCK'))
      #
      # pin 4: -RESET
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,-c,2*d,0))
      self.pad.append(point(-c,2*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'-RESET'))
      #
      # pin 5: VCC
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,-c,d,0))
      self.pad.append(point(-c,d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'VCC'))
      #
      # pin 6: GND
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,-c,0,0))
      self.pad.append(point(-c,0,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND'))
      #
      # pin 7: XTAL2
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,-c,-d,0))
      self.pad.append(point(-c,-d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'XTAL2'))
      #
      # pin 8: XTAL1
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,-c,-2*d,0))
      self.pad.append(point(-c,-2*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'XTAL1'))
      #
      # pin 9: PD0/PCINT24/RXD0
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,-c,-3*d,0))
      self.pad.append(point(-c,-3*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'RXD0'))
      #
      # pin 10: PD1/PCINT25/TXD0
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,-c,-4*d,0))
      self.pad.append(point(-c,-4*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'TXD0'))
      #
      # pin 11: PD2/PCINT26/INT0
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,-c,-5*d,0))
      self.pad.append(point(-c,-5*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PD2'))
      #
      # pin 12: PD3/PCINT27/INT1
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-5*d,-c,0))
      self.pad.append(point(-5*d,-c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PD3'))
      #
      # pin 13: PD4/PCINT28/OC1B
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-4*d,-c,0))
      self.pad.append(point(-4*d,-c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PD4'))
      #
      # pin 14: PD5/PCINT28/OC1A
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-3*d,-c,0))
      self.pad.append(point(-3*d,-c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PD5'))
      #
      # pin 15: PD6/PCINT30/OC2B/ICP
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-2*d,-c,0))
      self.pad.append(point(-2*d,-c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PD6'))
      #
      # pin 16: PD7/PCINT31/OC2A
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-d,-c,0))
      self.pad.append(point(-d,-c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PD7'))
      #
      # pin 17: VCC
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,0,-c,0))
      self.pad.append(point(0,-c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'VCC'))
      #
      # pin 18: GND
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,d,-c,0))
      self.pad.append(point(d,-c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND'))
      #
      # pin 19: PC0/PCINT16/SCL
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,2*d,-c,0))
      self.pad.append(point(2*d,-c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC0'))
      #
      # pin 20: PC1/PCINT17/SDA
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,3*d,-c,0))
      self.pad.append(point(3*d,-c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC1'))
      #
      # pin 21: PC2/PCINT18/TCK
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,4*d,-c,0))
      self.pad.append(point(4*d,-c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC2'))
      #
      # pin 22: PC3/PCINT19/TMS
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,5*d,-c,0))
      self.pad.append(point(5*d,-c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC3'))
      #
      # pin 23: PC4/TDO/PCINT20
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,-5*d,0))
      self.pad.append(point(c,-5*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC4'))
      #
      # pin 24: PC5/TDI/PCINT21
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,-4*d,0))
      self.pad.append(point(c,-4*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC5'))
      #
      # pin 25: PC6/TOSC1/PCINT22
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,-3*d,0))
      self.pad.append(point(c,-3*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC6'))
      #
      # pin 26: PC7/TOSC2/PCINT23
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,-2*d,0))
      self.pad.append(point(c,-2*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PC7'))
      #
      # pin 27: AVCC
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,-d,0))
      self.pad.append(point(c,-d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'AVCC'))
      #
      # pin 28: GND
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,0,0))
      self.pad.append(point(c,0,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND'))
      #
      # pin 29: AREF
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,d,0))
      self.pad.append(point(c,d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'AREF'))
      #
      # pin 30: PA7/ADC7/PCINT7
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,2*d,0))
      self.pad.append(point(c,2*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA7'))
      #
      # pin 31: PA6/ADC6/PCINT6
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,3*d,0))
      self.pad.append(point(c,3*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA6'))
      #
      # pin 32: PA5/ADC5/PCINT5
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,4*d,0))
      self.pad.append(point(c,4*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA5'))
      #
      # pin 33: PA4/ADC4/PCINT4
      #
      self.shape = add(self.shape,translate(pad_TQFP_h,c,5*d,0))
      self.pad.append(point(c,5*d,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA4'))
      #
      # pin 34: PA3/ADC3/PCINT3
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,5*d,c,0))
      self.pad.append(point(5*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA3'))
      #
      # pin 35: PA2/ADC2/PCINT2
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,4*d,c,0))
      self.pad.append(point(4*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA2'))
      #
      # pin 36: PA1/ADC1/PCINT1
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,3*d,c,0))
      self.pad.append(point(3*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA1'))
      #
      # pin 37: PA0/ADC0/PCINT0
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,2*d,c,0))
      self.pad.append(point(2*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PA0'))
      #
      # pin 38: VCC
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,d,c,0))
      self.pad.append(point(d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'VCC'))
      #
      # pin 39: GND
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,0,c,0))
      self.pad.append(point(0,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND'))
      #
      # pin 40: PB0/XCK0/T0/PCINT8
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-d,c,0))
      self.pad.append(point(-d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB0'))
      #
      # pin 41: PB1/T1/CLKO/PCINT9
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-2*d,c,0))
      self.pad.append(point(-2*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB1'))
      #
      # pin 42: PB2/AIN0/INT2/PCINT10
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-3*d,c,0))
      self.pad.append(point(-3*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB2'))
      #
      # pin 43: PB3/AIN1/OC0A/PCINT11
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-4*d,c,0))
      self.pad.append(point(-4*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB2'))
      #
      # pin 44: PB4/-SS/OC0B/PCINT12
      #
      self.shape = add(self.shape,translate(pad_TQFP_v,-5*d,c,0))
      self.pad.append(point(-5*d,c,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'PB4'))

TSSOP_pad_width = 0.040
TSSOP_pad_height = 0.011
TSSOP_pad_dy = 0.026
TSSOP_pad_dx = 0.120
pad_TSSOP = cube(-TSSOP_pad_width/2.0,TSSOP_pad_width/2.0,-TSSOP_pad_height/2.0,TSSOP_pad_height/2.0,0,0)

class TRC102(part):
   #
   # RFM TRC102 ISM transceiver
   #
   def __init__(self,value=''):
      self.value = value
      self.pad = [point(0,0,0)]
      self.labels = []
      #
      # pin 1: SDI
      #
      self.shape = translate(pad_TSSOP,-TSSOP_pad_dx,3.5*TSSOP_pad_dy,0)
      self.pad.append(point(-TSSOP_pad_dx,3.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'1 SDI'))
      #
      # pin 2: SCK
      #
      self.shape = add(self.shape,translate(pad_TSSOP,-TSSOP_pad_dx,2.5*TSSOP_pad_dy,0))
      self.pad.append(point(-TSSOP_pad_dx,2.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'SCK'))
      #
      # pin 3: nCS
      #
      self.shape = add(self.shape,translate(pad_TSSOP,-TSSOP_pad_dx,1.5*TSSOP_pad_dy,0))
      self.pad.append(point(-TSSOP_pad_dx,1.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'nCS'))
      #
      # pin 4: SDO
      #
      self.shape = add(self.shape,translate(pad_TSSOP,-TSSOP_pad_dx,0.5*TSSOP_pad_dy,0))
      self.pad.append(point(-TSSOP_pad_dx,0.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'SDO'))
      #
      # pin 5: IRQ
      #
      self.shape = add(self.shape,translate(pad_TSSOP,-TSSOP_pad_dx,-0.5*TSSOP_pad_dy,0))
      self.pad.append(point(-TSSOP_pad_dx,-0.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'IRQ'))
      #
      # pin 6: DATA/nFSEL
      #
      self.shape = add(self.shape,translate(pad_TSSOP,-TSSOP_pad_dx,-1.5*TSSOP_pad_dy,0))
      self.pad.append(point(-TSSOP_pad_dx,-1.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'DATA'))
      #
      # pin 7: CR
      #
      self.shape = add(self.shape,translate(pad_TSSOP,-TSSOP_pad_dx,-2.5*TSSOP_pad_dy,0))
      self.pad.append(point(-TSSOP_pad_dx,-2.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'CR'))
      #
      # pin 8: CLKOUT
      #
      self.shape = add(self.shape,translate(pad_TSSOP,-TSSOP_pad_dx,-3.5*TSSOP_pad_dy,0))
      self.pad.append(point(-TSSOP_pad_dx,-3.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'CLKOUT'))
      #
      # pin 9: Xtal/Ref
      #
      self.shape = add(self.shape,translate(pad_TSSOP,TSSOP_pad_dx,-3.5*TSSOP_pad_dy,0))
      self.pad.append(point(TSSOP_pad_dx,-3.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'Xtal'))
      #
      # pin 10: RESET
      #
      self.shape = add(self.shape,translate(pad_TSSOP,TSSOP_pad_dx,-2.5*TSSOP_pad_dy,0))
      self.pad.append(point(TSSOP_pad_dx,-2.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'RESET'))
      #
      # pin 11: GND
      #
      self.shape = add(self.shape,translate(pad_TSSOP,TSSOP_pad_dx,-1.5*TSSOP_pad_dy,0))
      self.pad.append(point(TSSOP_pad_dx,-1.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'GND'))
      #
      # pin 12: RF_P
      #
      self.shape = add(self.shape,translate(pad_TSSOP,TSSOP_pad_dx,-0.5*TSSOP_pad_dy,0))
      self.pad.append(point(TSSOP_pad_dx,-0.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'RF_P'))
      #
      # pin 13: RF_N
      #
      self.shape = add(self.shape,translate(pad_TSSOP,TSSOP_pad_dx,0.5*TSSOP_pad_dy,0))
      self.pad.append(point(TSSOP_pad_dx,0.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'RF_N'))
      #
      # pin 14: VDD
      #
      self.shape = add(self.shape,translate(pad_TSSOP,TSSOP_pad_dx,1.5*TSSOP_pad_dy,0))
      self.pad.append(point(TSSOP_pad_dx,1.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'VDD'))
      #
      # pin 15: RSSIA
      #
      self.shape = add(self.shape,translate(pad_TSSOP,TSSOP_pad_dx,2.5*TSSOP_pad_dy,0))
      self.pad.append(point(TSSOP_pad_dx,2.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'RSSIA'))
      #
      # pin 16: nINT/DDET
      #
      self.shape = add(self.shape,translate(pad_TSSOP,TSSOP_pad_dx,3.5*TSSOP_pad_dy,0))
      self.pad.append(point(TSSOP_pad_dx,3.5*TSSOP_pad_dy,0))
      self.labels.append(self.text(self.pad[-1].x,self.pad[-1].y,self.pad[-1].z,'nINT'))

class CBA(part):
   #
   # CBA logo
   #
   def __init__(self,r=.02):
      self.value = ''
      self.pad = [point(0,0,0)]
      self.labels = []
      d = 3*r
      self.shape = cylinder(0,0,0,0,r)
      self.shape = add(self.shape,translate(cylinder(0,0,0,0,r),-d,d,0))
      self.shape = add(self.shape,translate(cube(-r,r,-r,r,0,0),-d,0,0))
      self.shape = add(self.shape,translate(cube(-r,r,-r,r,0,0),-d,-d,0))
      self.shape = add(self.shape,translate(cube(-r,r,-r,r,0,0),0,-d,0))
      self.shape = add(self.shape,translate(cube(-r,r,-r,r,0,0),d,-d,0))
      self.shape = add(self.shape,translate(cube(-r,r,-r,r,0,0),d,0,0))
      self.shape = add(self.shape,translate(cube(-r,r,-r,r,0,0),d,d,0))
      self.shape = add(self.shape,translate(cube(-r,r,-r,r,0,0),0,d,0))

class fab(part):
   def __init__(self,r=.05):
      self.value = ''
      self.pad = [point(0,0,0)]
      self.labels = []
      d = 1.8*r
      l = 3.5*r
      h = r/2.
      self.shape = rectangle(-d,d,-d,d)
      self.shape = subtract(self.shape,circle(0,0,r))
      self.shape = subtract(self.shape,rectangle(-l,0,-h,h))
      self.shape = add(self.shape,rectangle(d,l,-h,h))
      self.shape = add(self.shape,circle(l,0,r))
      self.shape = add(self.shape,circle(-l,0,r))

#
# define board
#

Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
width = 1.02 # board width
height = .87 # board height
x = 1 # x origin
y = 1 # y origin
zt = 0 # top z
zb = -0.06 # bottom z
w = .015 # wire width
rv = 0.016 # via size
rp = 0.03 # pad size
mask = .004 # solder mask size
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

pcb = PCB(x,y,width,height,mask)

IC1 = ATtiny44_SOICN('IC1\nt44')
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
pcb = IC1.add(pcb,x+.49,y+.56)

VIC1 = via(zb,zt,rv,rp)
pcb = VIC1.add(pcb,IC1.pad[14].x+.08,IC1.pad[14].y+.02)

pcb = wire(pcb,w,
   VIC1.pad[1],
   IC1.pad[14])
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

J1 = header_ISP('J1\nISP')
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
pcb = J1.add(pcb,IC1.x+.05,IC1.pad[7].y-.22,angle=90)
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
   IC1.pad[8],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(J1.pad[1].x,IC1.pad[8].y),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J1.pad[1])

pcb = wire(pcb,w,
   IC1.pad[9],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(J1.pad[3].x,IC1.pad[9].y),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J1.pad[3])
   
pcb = wire(pcb,w,
   IC1.pad[7],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(IC1.pad[7].x,J1.y+.02),
   point(IC1.pad[7].x+.04,J1.y-.02),
   point(J1.pad[4].x,J1.y-.02),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J1.pad[4])
   
pcb = wire(pcb,w,
   IC1.pad[4],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(J1.pad[5].x,IC1.pad[4].y),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J1.pad[5])

Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
VJ12 = via(zb,zt,rv,rp)
pcb = VJ12.add(pcb,J1.pad[2].x+.075,J1.pad[2].y)

Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   VJ12.pad[1],
   J1.pad[2])
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
VJ16 = via(zb,zt,rv,rp)
pcb = VJ16.add(pcb,J1.pad[6].x-.075,J1.pad[6].y)
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   VJ16.pad[1],
   J1.pad[6])

pcb = wire(pcb,w,
   VJ16.pad[2],
   VIC1.pad[2])

J2 = header_FTDI('J2 FTDI')
pcb = J2.add(pcb,x+width-.22,IC1.y-.0,angle=0)
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
   IC1.pad[13],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(IC1.pad[13].x+.105,IC1.pad[13].y),
   point(IC1.pad[13].x+.105,J2.pad[4].y),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J2.pad[4])

pcb = wire(pcb,w,
   IC1.pad[12],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(IC1.pad[12].x+.07,IC1.pad[12].y),
   point(IC1.pad[12].x+.07,J2.pad[5].y+.04),
   point(IC1.pad[12].x+.11,J2.pad[5].y),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   J2.pad[5])

Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
VJ2 = via(zb,zt,rv,rp)
pcb = VJ2.add(pcb,J2.pad[3].x+.1,J2.pad[3].y)

pcb = wire(pcb,w,
   VJ2.pad[1],
   J2.pad[3])

pcb = wire(pcb,w,
   VJ12.pad[2],
   VJ2.pad[2])

Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
XTAL1 = XTAL_EFOBM('XTAL1\n20 MHz')
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
pcb = XTAL1.add(pcb,IC1.pad[4].x-.2,IC1.pad[13].y+.003,angle=-90)
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
   IC1.pad[2],
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   point(XTAL1.x+.12,IC1.pad[2].y),
   point(XTAL1.x+.12,XTAL1.pad[1].y),
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   XTAL1.pad[1])

pcb = wire(pcb,w,
   IC1.pad[3],
   XTAL1.pad[3])

Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
VXTAL = via(zb,zt,rv,rp)
pcb = VXTAL.add(pcb,XTAL1.x-.12,XTAL1.y)

pcb = wire(pcb,w,
   XTAL1.pad[2],
   VXTAL.pad[1])

pcb = wire(pcb,w,
   VJ16.pad[2],
   VXTAL.pad[2])

Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
R1 = R_1206('R1\n10k');
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
pcb = R1.add(pcb,IC1.pad[1].x,IC1.pad[1].y+.1)
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
   R1.pad[1],
   IC1.pad[1])

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   R1.pad[2],
   point(J1.pad[5].x,R1.y),
   J1.pad[5])

VR1 = via(zb,zt,rv,rp)
pcb = VR1.add(pcb,R1.pad[1].x-.08,R1.y)

pcb = wire(pcb,w,
   VR1.pad[1],
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   R1.pad[1])

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   VJ2.pad[2],
   point(VJ2.x,VR1.y,zb),
   VR1.pad[2])
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

C1 = C_1206('C1\n1uF');
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
pcb = C1.add(pcb,IC1.pad[14].x,R1.y)
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   J2.pad[1],
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   C1.pad[2])

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   C1.pad[2],
   VIC1.pad[1])

VC1 = via(zb,zt,rv,rp)
pcb = VC1.add(pcb,C1.pad[1].x-.025,C1.y-.06)
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

pcb = wire(pcb,w,
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   VC1.pad[1],
   C1.pad[1])

pcb = wire(pcb,w,
   VR1.pad[2],
   point(VC1.x,VR1.y,zb),
   VC1.pad[2])
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed

#
# select output
#

outputs = {}
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
if (output == "top, labels, and exterior"):
   outputs["function"] = add(add(color(Tan,pcb.board),pcb.labels),
      color(White,pcb.exterior))
   outputs["layers"] = [zt]
elif (output == "top, bottom, labels, and exterior"):
   outputs["function"] = add(add(color(Tan,pcb.board),pcb.labels),
      color(White,pcb.exterior))
   outputs["layers"] = [zb,zt]
elif (output == "top, bottom, labels, holes, and exterior"):
   outputs["function"] = add(add(color(Tan,
      subtract(pcb.board,pcb.holes)),pcb.labels),
      color(White,pcb.exterior))
   outputs["layers"] = [zb,zt]
elif (output == "top traces"):
   outputs["function"] = color(White,pcb.board)
   outputs["layers"] = [zt]
elif (output == "top traces and exterior"):
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
   outputs["function"] = color(White,add(pcb.board,pcb.exterior))
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   outputs["layers"] = [zt]
elif (output == "bottom traces reversed"):
   outputs["function"] = color(White,
      reflect_x(pcb.board,2*x+width))
   outputs["layers"] = [zb]
elif (output == "bottom traces reversed and exterior"):
   outputs["function"] = color(White,
      reflect_x(add(pcb.board,pcb.exterior),2*x+width))
   outputs["layers"] = [zb]
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
elif (output == "interior"):
   outputs["function"] = color(White,pcb.interior)
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   outputs["layers"] = [zt]
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
elif (output == "exterior"):
   outputs["function"] = color(White,pcb.exterior)
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   outputs["layers"] = [zt]
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
elif (output == "holes"):
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   outputs["function"] = color(White,
      subtract(add(pcb.exterior,pcb.interior),pcb.holes))
   outputs["layers"] = [zb]
elif (output == "holes and interior"):
   outputs["function"] = color(White,
      subtract(pcb.interior,pcb.holes))
   outputs["layers"] = [zb]
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
elif (output == "solder mask"):
   outputs["function"] = color(White,pcb.mask)
Neil Gershenfeld (test)'s avatar
Neil Gershenfeld (test) committed
   outputs["layers"] = [zt]
Neil Gershenfeld (test)'s avatar
wip
Neil Gershenfeld (test) committed
else:
   print("oops -- don't recognize output")

#
# set limits and parameters
#

border = 0.05
outputs["xmin"] = x-border # min x to render
outputs["xmax"] = x+width+border # max x to render
outputs["ymin"] = y-border # min y to render
outputs["ymax"] = y+height+border # max y to render
outputs["mm_per_unit"] = 25.4 # use inch units
outputs["type"] = "RGB" # use RGB color

#
# send output
#

json.dump(outputs,sys.stdout)