krishnax12/tlv3601-evm-recreation
Complete TI TLV3601EVM reference circuit with TLV3601/TLV3603 assembly options, Matchpack schematic, and a new autorouted four-layer PCB. Not TI's original artwork or hardware validated. Preview builds from the verified local native export; regenerating TSX requires local outline-keepout support. See reference.json.
- Version
- 0.0.5
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone krishnax12/tlv3601-evm-recreation # download the package files into ./tlv3601-evm-recreation
tsci add krishnax12/tlv3601-evm-recreation # add it to your project as @tsci/krishnax12.tlv3601-evm-recreationIn 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.tsx
import { mkdir } from "node:fs/promises"
import { resolve } from "node:path"
import { Resvg } from "@resvg/resvg-js"
import { RootCircuit } from "@tscircuit/core"
import type { AnyCircuitElement } from "circuit-json"
import {
convertCircuitJsonToPcbSvg,
convertCircuitJsonToStackedSchematicSheetsSvg,
} from "circuit-to-svg"
import { KicadFootprintToCircuitJsonConverter } from "kicad-to-circuit-json"
import type { ComparatorDevice } from "../components/comparator"
import Tlv3601Evm from "../index.circuit"
const requestedDevice = process.argv[2] ?? "tlv3601"
if (requestedDevice !== "tlv3601" && requestedDevice !== "tlv3603") {
throw new Error("Use: bun run render tlv3601 | tlv3603")
}
const device: ComparatorDevice = requestedDevice
type FootprintUrl = string
const footprints = new Map<FootprintUrl, Promise<AnyCircuitElement[]>>()
const loadFootprint = async (url: FootprintUrl) => {
const response = await fetch(url)
if (!response.ok)
throw new Error(`Footprint request failed: ${response.status}: ${url}`)
const converter = new KicadFootprintToCircuitJsonConverter()
converter.addFile(
url.split("/").at(-1) ?? "footprint.kicad_mod",
await response.text(),
)
converter.runUntilFinished()
return converter.getOutput()
}
const circuit = new RootCircuit({
platform: {
partsEngineDisabled: true,
footprintLibraryMap: {
kicad: async (footprintName) => {
const [library, name] = footprintName.split("/")
const url = `https://gitlab.com/kicad/libraries/kicad-footprints/-/raw/master/${library}.pretty/${name}.kicad_mod`
if (!footprints.has(url)) footprints.set(url, loadFootprint(url))
return { footprintCircuitJson: (await footprints.get(url)) ?? [] }
},
},
},
})
const solverEvents: string[] = []
circuit.on("solver:started", (event) => {
solverEvents.push(event.solverName)
})
circuit.add(<Tlv3601Evm device={device} />)
await circuit.renderUntilSettled()
const circuitJson = circuit.getCircuitJson()
const outputDirectory = resolve(import.meta.dir, "../outputs")
await mkdir(outputDirectory, { recursive: true })
await Bun.write(
resolve(outputDirectory, `${device}.circuit.json`),
JSON.stringify(circuitJson, null, 2),
)
await Bun.write(
resolve(outputDirectory, `${device}.solvers.json`),
JSON.stringify(solverEvents, null, 2),
)
const previews = {
[`${device}-top`]: convertCircuitJsonToPcbSvg(circuitJson, {
layer: "top",
width: 1200,
height: 1200,
showPinNumbers: true,
showFabricationNotes: false,
showCourtyards: false,
}),
[`${device}-inner1`]: convertCircuitJsonToPcbSvg(circuitJson, {
layer: "inner1",
width: 1200,
height: 1200,
showFabricationNotes: false,
showCourtyards: false,
}),
[`${device}-bottom`]: convertCircuitJsonToPcbSvg(circuitJson, {
layer: "bottom",
width: 1200,
height: 1200,
showFabricationNotes: false,
showCourtyards: false,
}),
[`${device}-plane-closeup`]: convertCircuitJsonToPcbSvg(circuitJson, {
layer: "bottom",
width: 1200,
height: 900,
viewport: { minX: -5, maxX: 7, minY: -4, maxY: 5 },
showFabricationNotes: false,
showCourtyards: false,
}),
[`${device}-schematic`]: convertCircuitJsonToStackedSchematicSheetsSvg(
circuitJson,
{ width: 1800, height: 1400 },
),
}
for (const [name, svg] of Object.entries(previews)) {
await Bun.write(resolve(outputDirectory, `${name}.svg`), svg)
await Bun.write(
resolve(outputDirectory, `${name}.png`),
new Resvg(svg).render().asPng(),
)
}
const diagnostics = circuitJson.filter(
(element) =>
element.type.endsWith("_error") || element.type.endsWith("_warning"),
)
console.log(
JSON.stringify(
{
device,
components: circuit.db.source_component.list().length,
pcbTraces: circuit.db.pcb_trace.list().length,
keepouts: circuit.db.pcb_keepout.list().length,
pours: circuit.db.pcb_copper_pour.list().length,
solverEvents,
diagnostics: Object.fromEntries(
[...new Set(diagnostics.map((element) => element.type))].map((type) => [
type,
diagnostics.filter((element) => element.type === type).length,
]),
),
},
null,
2,
),
)
if (diagnostics.some((element) => element.type.endsWith("_error")))
process.exitCode = 1