0hmX/TMDS62LEVM
This code defines the physical layout and component placement for a TI AM62L evaluation module, including mechanical and population components, without routing.
- Version
- 1.0.2
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone 0hmX/TMDS62LEVM # download the package files into ./TMDS62LEVM
tsci add 0hmX/TMDS62LEVM # add it to your project as @tsci/0hmX.TMDS62LEVMIn 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/generate-placement-data.mjs
import { readFileSync, writeFileSync } from "node:fs"
import { resolve } from "node:path"
const sourcePath = process.argv[2]
const extractionPath = process.argv[3]
const outputPath = resolve("src/generated/placements.ts")
if (!sourcePath) {
throw new Error(
"Usage: node scripts/generate-placement-data.mjs /path/to/_PROC181E1-1_XY_REPORT.XLS",
)
}
const extractedByName = extractionPath
? new Map(
JSON.parse(readFileSync(extractionPath, "utf8")).all_xy_placements.map(
(placement) => [placement.refdes, placement],
),
)
: new Map()
const MIL_TO_MM = 0.0254
const BOARD_ORIGIN_MIL = { x: 2677.217, y: 2612 }
const round = (value) => Math.round(value * 1000) / 1000
const rows = readFileSync(sourcePath, "utf8")
.split(/\r?\n/)
.slice(13)
.filter(Boolean)
.map((line) => {
const [
name,
value,
rawLayer,
footprint,
rawX,
rawY,
rawRotation,
description,
] = line.split("\t")
const xMil = Number.parseFloat(rawX)
const yMil = Number.parseFloat(rawY)
if (!name || !Number.isFinite(xMil) || !Number.isFinite(yMil)) return null
const extracted = extractedByName.get(name)
return {
name,
value,
footprint,
description,
pcbX: round((xMil - BOARD_ORIGIN_MIL.x) * MIL_TO_MM),
pcbY: round((yMil - BOARD_ORIGIN_MIL.y) * MIL_TO_MM),
pcbRotation: Number.parseFloat(rawRotation) || 0,
layer: rawLayer === "BottomLayer" ? "bottom" : "top",
populated: extracted?.populated_in_bom ?? true,
bodyPcbX: round(extracted?.idf_outline?.geometric_center_x_mm ?? (xMil - BOARD_ORIGIN_MIL.x) * MIL_TO_MM),
bodyPcbY: round(extracted?.idf_outline?.geometric_center_y_mm ?? (yMil - BOARD_ORIGIN_MIL.y) * MIL_TO_MM),
}
})
.filter(Boolean)
const uniqueNames = new Set(rows.map(({ name }) => name))
if (rows.length !== 1585 || uniqueNames.size !== rows.length) {
throw new Error(
`Expected 1585 unique placements, got ${rows.length} rows / ${uniqueNames.size} names`,
)
}
const output = `import type { PlacementRecord } from "./types"\n\n/**\n * Generated from TI's official PROC181E1-1 Altium pick-and-place report.\n * Coordinates are millimetres relative to the board centre; populated comes\n * from the official BOM quantity, and bodyPcbX/bodyPcbY include IDF offsets.\n */\nexport const placements = ${JSON.stringify(rows, null, 2)} as const satisfies readonly PlacementRecord[]\n`
writeFileSync(outputPath, output)
console.log(`Wrote ${rows.length} placements to ${outputPath}`)