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/test-order-review.py

"""Regression cases for the actual generated USB geometry and current budget."""
import copy,importlib.util,json,unittest
from pathlib import Path
ROOT=Path(__file__).resolve().parent.parent

def module(name,path):
 s=importlib.util.spec_from_file_location(name,ROOT/path);m=importlib.util.module_from_spec(s);s.loader.exec_module(m);return m
usb=module('usb','scripts/pcb-audit/audit-usb.py');budget=module('budget','scripts/check-current-budget.py')
class ReviewRegressionTests(unittest.TestCase):
 @classmethod
 def setUpClass(cls):
  cls.c=json.loads((ROOT/'dist/index/circuit.json').read_text());cls.spec=json.loads((ROOT/'manufacturing/current-budget.json').read_text())
 def test_current_generated_usb_passes(self):self.assertFalse(usb.analyze(self.c)['failures'])
 def test_returning_a_segment_to_bottom_is_rejected(self):
  c=copy.deepcopy(self.c);r=next(r for r in c if r.get('pcb_trace_id')=='usb_dp_connector' and r['type']=='pcb_trace')
  r['route'][0]['layer']='bottom'
  self.assertTrue(any(f['issue']=='USB not entirely on top' for f in usb.analyze(c)['failures']))
 def test_missing_reference_plane_is_rejected(self):
  c=[r for r in self.c if not (r['type']=='pcb_copper_pour' and r['layer']=='inner1')]
  self.assertTrue(any(f['issue']=='L2 ground reference gap' for f in usb.analyze(c)['failures']))
 def test_oversized_usb_width_is_rejected(self):
  c=copy.deepcopy(self.c);r=next(r for r in c if r.get('pcb_trace_id')=='usb_dp_connector' and r['type']=='pcb_trace');r['route'][0]['width']=.4
  self.assertTrue(any(f['issue']=='USB width changed' for f in usb.analyze(c)['failures']))
 def test_current_budget_passes(self):self.assertFalse(budget.review(self.c,self.spec)['failures'])
 def test_old_resistor_limits_inside_the_contract(self):
  c=copy.deepcopy(self.c);next(r for r in c if r['type']=='source_component' and r['name']=='R142')['resistance']=1200
  self.assertIn('U11 hardware limit can act inside the PD contract',budget.review(c,self.spec)['failures'])
 def test_excess_logic_load_is_rejected(self):
  s=copy.deepcopy(self.spec);s['logicOutputAllocationMa']['9000']=1000
  self.assertIn('Input allocation exceeds PD contract',budget.review(self.c,s)['failures'])
 def test_lit_large_oled_is_rejected_on_fallback(self):
  s=copy.deepcopy(self.spec);s['oledRequiresPdContract']=False
  self.assertIn('Logic allocation exceeds fallback current',budget.review(self.c,s)['failures'])
if __name__=='__main__':unittest.main()