shibosoftwaredev/f1c100s-linux-nema17-stepper-controller

A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.

Version
0.4.56
License
unset
Stars
0

modules/f1c100s/src/module-layout.tsx

import type { Subcircuit } from "tscircuit"

/** Initial assembly faces; final carrier centers live in placement-plan.json. */
export const nativeMotorSideSupportPlacements: Record<string, {
  old: [number, number]; next: [number, number]; layer: "top" | "bottom";
}> = {
  C_B_AVCC: { old: [-5.8, 7.6], next: [-4.5, 6.9], layer: "top" },
  C_B_VCC_DRAM: { old: [-6.2, -8.7], next: [-5.5, -11.5], layer: "bottom" },
  C_VRA2: { old: [-4.0, 10.45], next: [-5.4, 7.0], layer: "bottom" },
  R_VRA2: { old: [-7.6, 10.45], next: [-7.6, 7.0], layer: "bottom" },
  C_B_VCC_TV: { old: [9.15, 8.1], next: [7.8, 7.6], layer: "bottom" },
  C_TV_REF: { old: [9.2, 10.6], next: [7.2, 10.6], layer: "bottom" },
  R_PU_SPI0_CS: { old: [-10.7, -10.45], next: [-12.5, -10.45], layer: "bottom" },
  C_D20: { old: [-8, -3.4], next: [-8, -3.4], layer: "bottom" },
  C_D22: { old: [-8, -4.4], next: [-8, -4.4], layer: "bottom" },
  C_B_VCC_IO: { old: [-8, 0], next: [-8, 0], layer: "bottom" },
  C_B_VDD_CORE: { old: [-8, -6.6], next: [-5.4, -6.6], layer: "bottom" },
  R_PU_TWI0_SDA: { old: [-10.45, -5], next: [-10.45, -4.7], layer: "bottom" },
  R_PU_TWI0_SCL: { old: [-10.45, -3.2], next: [-10.45, -3.2], layer: "bottom" },
}

/** The SoC is part of the carrier's single complete routing solution. */
export async function deferModuleRouting(input: any) {
  const handlers: Record<string, Array<(event: any) => void>> = {}
  return {
    input, isRouting: false,
    on(event: string, handler: (event: any) => void) { (handlers[event] ??= []).push(handler) },
    start() { queueMicrotask(() => handlers.complete?.forEach(f => f({ type: "complete", traces: [] }))) },
    stop() {}, solveSync() { return [] },
  }
}

/** Retain the established schematic selectors without loading saved copper. */
export function attachModuleGrouping(instance: Subcircuit) {
  ;(instance as any)._isInflatedFromCircuitJson = false
  const module = instance.selectOne(".MODULE") as any
  const components = [...module.children]
  module.add(<group name="COPPER" pcbX={0} pcbY={0} schLayout={{ layoutMode: "relative" }} />)
  const group = module.selectOne(".COPPER")
  group._doInitialSchematicLayoutSections = () => {}
  for (const component of components) {
    module.children = module.children.filter((child: any) => child !== component)
    group.add(component)
  }
  for (const trace of instance.selectAll("trace") as any[]) {
    for (const props of [trace.props, trace._parsedProps]) {
      delete props.pcbPath
      delete props.pcbStraightLine
      props.maxLength = /^N_HOSC[IO]$/.test(props.name ?? "") ? 10 : 5000
      if (/^N_HOSC[IO]$/.test(props.name ?? "")) props.maxViaCount = 0
      props.path = props.path?.map((path: string) => path.replace(".MODULE > ", ".MODULE .COPPER > "))
    }
  }
}