Skip to main content

Library for composing circuits and pcb layouts

Project description

# Circuit Description Library

## Getting started

`joule_thief.py`
```python
from pycircuit.circuit import *
from pycircuit.library import *


Device('BAT0805', 'BAT', '0805',
Map('1', '+'),
Map('2', '-'))

Package('TDK ACT45B', RectCrtyd(5.9, 3.4), DualPads(4, 2.5, radius=2.275),
package_size=(5.9, 3.4), pad_size=(0.9, 1.35))

Device('TDK ACT45B', 'Transformer_1P_1S', 'TDK ACT45B',
Map('1', 'L1.1'), Map('2', 'L2.1'), Map('3', 'L2.2'), Map('4', 'L1.2'))


@circuit('TOP')
def top():
vcc, gnd, n1, n2, n3 = nets('VCC GND n1 n2 n3')

with Inst('TR1', 'Transformer_1P_1S') as tr1:
tr1['L1', 'L1'] = n1, n2
tr1['L2', 'L2'] = vcc, n3

Inst('BAT1', 'BAT')['+', '-'] = vcc, gnd
Inst('R1', 'R', '10k 0805')['~', '~'] = vcc, n1
Inst('Q1', 'Q', 'npn sot23')['B', 'C', 'E'] = n2, n3, gnd
Inst('LED1', 'D', 'led red 0805')['A', 'C'] = n3, gnd
```

`build.py`
```python
import joule_thief
from pycircuit.build import Builder
from pycircuit.compiler import Compiler
from pycircuit.library.design_rules import oshpark_4layer
from placer import Placer
from router import Router
from pykicad.pcb import Zone


def compile(filein, fileout):
compiler = Compiler()
compiler.compile(filein, fileout)


def place(filein, fileout):
placer = Placer()
placer.place(filein, fileout)


def route(filein, fileout):
router = Router()
router.route(filein, fileout)


def post_process(pcb, kpcb):
xmin, ymin, xmax, ymax = pcb.boundary()
coords = [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)]

zone = Zone(net_name='GND', layer='F.Cu',
polygon=coords, clearance=0.3)

kpcb.zones.append(zone)
return kpcb


if __name__ == '__main__':
Builder('joule_thief', joule_thief.top, oshpark_4layer,
compile, place, route, post_process).build()
```

`Makefile`
```make
PYCIRCUIT = ../..

build:
python3 build.py

view:
node $(PYCIRCUIT)/viewer/app.js 3000 net.dot.svg pcb.svg

kicad:
pcbnew *.kicad_pcb &>/dev/null &

clean:
rm -f *.net *.hash *.dot *.svg *.place *.route *.pro *.kicad_pcb

.PHONY: build view kicad clean
```

![Viewer](https://user-images.githubusercontent.com/741807/34364054-39b1362e-ea82-11e7-94b7-baf712e1aeab.png)
![KiCad](https://user-images.githubusercontent.com/741807/34364057-43e7ee62-ea82-11e7-9787-84fefaecbc49.png)

# License
ISC License

Copyright (c) 2017, David Craven

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycircuit-0.0.2.tar.gz (20.7 kB view details)

Uploaded Source

File details

Details for the file pycircuit-0.0.2.tar.gz.

File metadata

  • Download URL: pycircuit-0.0.2.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pycircuit-0.0.2.tar.gz
Algorithm Hash digest
SHA256 854eb499dd3dcb7e73d7114d8b4d03453c328d6f49b78b77047bc0a88c51f2c7
MD5 789466c7d133c900079d2225b891d1f8
BLAKE2b-256 b6b8f91697a4ae53e9461df48b926466f36d424c4101c69b7ac865f1cb903374

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page