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/render-system-diagram.tsx

import { Circuit } from "tscircuit"
import { convertCircuitJsonToSystemSvg } from "circuit-to-svg"
import { Resvg } from "@resvg/resvg-js"
import { mkdirSync, writeFileSync, readFileSync } from "node:fs"
import SystemDiagram from "../system-diagram.circuit"

const output = "dist/system-diagram"
mkdirSync(output, { recursive: true })
let json
if (process.argv[2]) json = JSON.parse(readFileSync(process.argv[2], "utf8"))
else {
  const circuit = new Circuit({ platform: { partsEngineDisabled: true } })
  circuit.add(<SystemDiagram />)
  await circuit.renderUntilSettled()
  json = circuit.getCircuitJson()
  writeFileSync(`${output}/circuit.json`, JSON.stringify(json, null, 2))
}
const errors = json.filter((x: any) => x.type.endsWith("_error"))
if (errors.length) throw new Error(JSON.stringify(errors, null, 2))
const pages = json.filter((x: any) => x.type === "system_block_page")
if (pages.length !== 3) throw new Error(`Expected three system pages; got ${pages.length}`)
for (const page of pages) {
  const svg = convertCircuitJsonToSystemSvg(json, { systemBlockPageId: page.system_block_page_id, width: 2200, includeVersion: false })
  writeFileSync(`${output}/${page.name}.svg`, svg)
  writeFileSync(`${output}/${page.name}.png`, new Resvg(svg).render().asPng())
  console.log(`Rendered ${page.name}`)
}