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/update-buck-net-map.py

"""Rebind physical net labels after removing only U_BUCK.EN from VIN."""
from route_geometry import *
baseline=Path('../../checkpoints/nema17-round12-pre-fix-20261020-Md2v1O/restore-verified')
old=json.loads((baseline/'dist/index/circuit.json').read_text())
now=load_circuit('dist/index/circuit.json')
old_root=connectivity(old);new_root=connectivity(now)
physical_ports={e['source_port_id'] for e in old if e['type']=='pcb_port'}
mapping=json.loads((baseline/'routing/net-map.json').read_text())
roots={}
for p in [e for e in old if e['type'] in ['source_port','source_net']]:
    pid=p[p['type']+'_id']
    if pid=='source_port_255':continue
    if old_root(pid) not in mapping['roots']:
        assert pid not in physical_ports,'every physical port needs a net label'
        continue
    label=mapping['roots'][old_root(pid)]
    rid=new_root(pid)
    assert rid not in roots or roots[rid]==label,'unintended net merge'
    roots[rid]=label
assert new_root('source_port_255')=='source_port_255'
roots['source_port_255']='N214'
names={new_root(k):v for k,v in mapping['names'].items()}
mapping['roots']=roots;mapping['names']=names
assert mapping['pinmap']['P255']['pcb_port_id']=='pcb_port_255'
old_label=mapping['pinmap']['P255']['net']
mapping['pinmap']['P255']['net']='N214'
mapping['pin_counts'][old_label]-=1;mapping['pin_counts']['N214']=1
Path('routing/net-map.json').write_text(json.dumps(mapping,indent=2)+'\n')
physical=json.loads((baseline/'routing/physical-copper.json').read_text())
branch=[((-12.422904,-2.9712),(-13.1456,-2.9712)),
        ((-13.1456,-2.9712),(-13.5652,-2.5516)),
        ((-13.5652,-2.5516),(-13.5652,-1.35))]
def is_branch(w):
    if w['net']!=old_label or w['layer']!='bottom' or not math.isclose(w['width'],.15):return False
    return any(all(math.dist(a,b)<1e-6 for a,b in zip(w['points'],pair)) or
               all(math.dist(a,b)<1e-6 for a,b in zip(w['points'],reversed(pair))) for pair in branch)
removed=[w for w in physical['wires'] if is_branch(w)]
assert len(removed)>=3
physical['wires']=[w for w in physical['wires'] if not is_branch(w)]
Path('routing/physical-copper.json').write_text(json.dumps(physical,indent=2)+'\n')
print(json.dumps(dict(removedBranchSegments=len(removed),newIsolatedNet='N214',otherNetsUnchanged=True)))