MustafaMulla29/rp2040-bldc-motor-controller

Hardware assembly metadata and PCB geometry for a controller board with a snap-off rotary-encoder section, plus four parallel 150 µF/50 V bulk electrolytic capacitors filtering the motor supply.

Version
2.0.40
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone MustafaMulla29/rp2040-bldc-motor-controller  # download the package files into ./rp2040-bldc-motor-controller
tsci add MustafaMulla29/rp2040-bldc-motor-controller    # add it to your project as @tsci/MustafaMulla29.rp2040-bldc-motor-controller

In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.

scripts/pcb-audit/test-route-lengths.py

"""Analytic geometry fixtures for the independent route-length estimator."""
import importlib.util
from pathlib import Path
import unittest
from shapely.geometry import Point, LineString

spec = importlib.util.spec_from_file_location('route_lengths', Path(__file__).with_name('audit-route-lengths.py'))
audit = importlib.util.module_from_spec(spec)
spec.loader.exec_module(audit)

def wire(a, b, layer='top'):
    return dict(line=LineString([a,b]), width=.2, layer=layer)

def terminal(label, xy, layers=('top',), kind='pad'):
    p = Point(xy)
    return dict(id=label, label=label if kind=='pad' else None, center=p, shape=p.buffer(.2), layers=list(layers))

def measure(wires, terminals):
    graph, pins = audit.route_graph(wires, terminals)
    return audit.shortest(graph, pins['A'], set(pins['B']))

class GeometryTests(unittest.TestCase):
    def test_bend_not_direct_distance(self):
        length, vias, _ = measure([wire((0,0),(3,0)),wire((3,0),(3,4))], [terminal('A',(0,0)),terminal('B',(3,4))])
        self.assertAlmostEqual(length,7)
        self.assertEqual(vias,[])

    def test_branch_does_not_add_untraversed_tail(self):
        length, _, _ = measure([wire((0,0),(10,0)),wire((4,0),(4,3))], [terminal('A',(0,0)),terminal('B',(4,3))])
        self.assertAlmostEqual(length,7)

    def test_real_via_connects_layers(self):
        length, vias, _ = measure([wire((0,0),(3,0)),wire((3,0),(3,4),'bottom')],
            [terminal('A',(0,0)),terminal('B',(3,4),('bottom',)),terminal('V',(3,0),('top','bottom'),'via')])
        self.assertAlmostEqual(length,7)
        self.assertEqual(vias,['V'])

    def test_crossing_layers_without_via_are_disconnected(self):
        with self.assertRaises(RuntimeError):
            measure([wire((0,0),(3,0)),wire((3,0),(3,4),'bottom')], [terminal('A',(0,0)),terminal('B',(3,4),('bottom',))])

    def test_collinear_overlap_does_not_double_count(self):
        length, _, _ = measure([wire((0,0),(6,0)),wire((4,0),(10,0))], [terminal('A',(0,0)),terminal('B',(10,0))])
        self.assertAlmostEqual(length,10)

    def test_nearby_unconnected_copper_is_not_shortcut(self):
        with self.assertRaises(RuntimeError):
            measure([wire((0,0),(3,0)),wire((3,.5),(6,.5))], [terminal('A',(0,0)),terminal('B',(6,.5))])

if __name__=='__main__': unittest.main()