shibosoftwaredev/f1c100s-linux-nema17-stepper-controller

A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.

Version
0.4.56
License
unset
Stars
0

scripts/prepare-fixed-closure.py

"""Create a separate completion job with all accepted copper fixed."""
from route_geometry import *
c=load_circuit()
cu=json.loads(Path('routing/physical-copper.json').read_text())
tree=parse_sexpr(Path('routing/board.dsn').read_text())
structure=one(tree,'structure');wiring=one(tree,'wiring')
for i,e in enumerate(c):
    if e['type']!='pcb_smtpad':continue
    g=geometry(e).buffer(.16,quad_segs=12)
    for l in LAYERS:
        structure.append(['via_keepout',f'NO_DRILL_SMD_{i}_{l}',
          ['polygon',l,'0',*[str(round(v*1000,4)) for p in list(g.exterior.coords)[:-1] for v in p]]])
# 0.125 mm copper separation also provides 0.20 mm from a 0.30 mm
# drill when its annulus is 0.45 mm. Never relax the legacy checked copper.
for node in [structure,*entries(one(tree,'network'),'class')]:
    for rule in entries(node,'rule'):
        for item in entries(rule,'clearance'):
            if len(item)==2:item[1]='125'
for w in cu['wires']:
    wiring.append(['wire',['path',w['layer'],str(round(w['width']*1000,4)),
      *[str(round(v*1000,4)) for p in w['points'] for v in p]],['net',w['net']],['type','protect']])
for v in cu['vias']:
    wiring.append(['via','VIA',str(round(v['x']*1000,4)),str(round(v['y']*1000,4)),['net',v['net']],['type','protect']])
def enc(value):return '('+' '.join(enc(x) for x in value)+')' if isinstance(value,list) else str(value)
Path('routing/fixed-closure.dsn').write_text(enc(tree)+'\n')
print(json.dumps(dict(fixedWires=len(cu['wires']),fixedVias=len(cu['vias']))))