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-sense-base.py

"""Retire the old temperature-alert dead-end, not its MCU-to-sensor trunk.

The moved sensor now joins N158 at (19.7569,-16.2611) on inner1.
Below that junction these two segments terminate without a pad or via.
The original base session is preserved; physical connectivity is rechecked
after merging the newly authored leaves.
"""
from route_geometry import *

tree = parse_sexpr(Path('routing/current-base.ses').read_text())
network = one(one(tree, 'routes'), 'network_out')
alert = next(n for n in entries(network, 'net') if n[1] == 'N158')
retired = {
    ('inner1', '1500', '193875', '-184016', '193875', '-166305'),
    ('inner1', '1500', '193875', '-166305', '197569', '-162611'),
}
removed = [w for w in entries(alert, 'wire') if tuple(one(w, 'path')[1:]) in retired]
assert len(removed) == 2, 'Expected exactly the two obsolete alert-stub segments'
for w in removed:
    alert.remove(w)

# Replace the Ethernet B-rail excursion behind the motor mounting hole with
# a new 0.25 mm route. Keep the local AB-to-BC resistor connection and every
# original supply terminal; the continuity audit must close the new route.
ethernet = next(n for n in entries(network, 'net') if n[1] == 'N150')
ethernet_excursion = {
    ('bottom','2000','123332','-163185','123332','-143895'),
    ('bottom','2000','123332','-163185','154194','-194047'),
    ('inner1','2000','154194','-194047','184776','-163465'),
    ('inner1','2000','179575','-118155','179575','-66108'),
    ('inner1','2000','179575','-118155','184776','-123356'),
    ('inner1','2000','184776','-163465','184776','-123356'),
    ('inner1','2000','179575','-66108','182485','-63198'),
}
old_ethernet = [w for w in entries(ethernet,'wire') if tuple(one(w,'path')[1:]) in ethernet_excursion]
assert len(old_ethernet)==8, 'Expected the eight old B-rail excursion segments (one duplicate)'
for w in old_ethernet:ethernet.remove(w)
old_via = ['via','VIA','154194','-194047']
assert old_via in ethernet
ethernet.remove(old_via)

# The original DIR signal also takes an avoidable lower/right perimeter
# detour. Preserve both terminal escapes and their vias; reroute only the
# intervening low-current signal, with unchanged pins and firmware mapping.
direction = next(n for n in entries(network,'net') if n[1]=='N166')
old_direction = [w for w in entries(direction,'wire') if one(w,'path')[1] in ['inner1','inner2']]
assert len(old_direction)==12
for w in old_direction:direction.remove(w)
direction.remove(['via','VIA','49552','-168694'])

def encode(value):
    return '(' + ' '.join(encode(x) for x in value) + ')' if isinstance(value, list) else str(value)

Path('routing/current-retained-base.ses').write_text(encode(tree) + '\n')
print('Retired alert stubs, Ethernet B-rail excursion and DIR perimeter detour; terminal escapes retained')