mohan-bee/flight-controller-v2

A 64 mm STM32F405 flight-controller PCB with ICM-42688 IMU, SPI flash, USB-C/ESD, battery buck and 3.3 V regulation, four motor outputs, service I/O, and PETG standoff mounting hardware.

Version
0.1.0
License
ISC
Stars
0

assembly/mount.tsx

import { assembly } from "@tscircuit/core";
import type { JscadOperation } from "jscad-planner";

export const mountingPoints = [
  { name: "REAR_LEFT", x: -28, y: -28 },
  { name: "FRONT_LEFT", x: -28, y: 28 },
  { name: "REAR_RIGHT", x: 28, y: -28 },
  { name: "FRONT_RIGHT", x: 28, y: 28 },
];

export const mountHeight = 12;
const baseThickness = 2;
const clearanceRadius = 1.7;

// Part-local XYZ in mm: base bottom Z=0; PCB support face Z=12.
export const mountPlan: JscadOperation = {
  type: "subtract",
  shapes: [
    {
      type: "union",
      shapes: [
        { type: "cuboid", size: [72, 72, baseThickness], center: [0, 0, 1] },
        ...mountingPoints.map(({ x, y }): JscadOperation => ({
          type: "cylinder", radius: 3, height: mountHeight,
          center: [x, y, mountHeight / 2],
        })),
      ],
    },
    { type: "cuboid", size: [42, 42, mountHeight + 2], center: [0, 0, mountHeight / 2] },
    ...mountingPoints.map(({ x, y }): JscadOperation => ({
      type: "cylinder", radius: clearanceRadius, height: mountHeight + 2,
      center: [x, y, mountHeight / 2],
    })),
  ],
};

const boltPlan: JscadOperation = {
  type: "union",
  shapes: [
    { type: "cylinder", radius: 1.5, height: 18, center: [0, 0, -9] },
    { type: "cylinder", radius: 2.7, height: 2, center: [0, 0, 1] },
  ],
};
const washerPlan: JscadOperation = {
  type: "subtract",
  shapes: [
    { type: "cylinder", radius: 3, height: 0.5, center: [0, 0, 0.25] },
    { type: "cylinder", radius: clearanceRadius, height: 2 },
  ],
};
const nutPlan: JscadOperation = {
  type: "subtract",
  shapes: [
    { type: "cylinder", radius: 3.175, height: 2.4, resolution: 6 },
    { type: "cylinder", radius: 1.5, height: 4 },
  ],
};
const nylonModel = (shape: JscadOperation): JscadOperation => ({
  type: "colorize", color: [0.88, 0.9, 0.94], shape,
});

export function FlightControllerMount() {
  return <assembly.printedpart name="MOUNT" displayName="72 mm PETG prototype mounting base"
    material="petg" color="#315d84" cadModel={{ jscad: mountPlan }}>
    <assembly.referencesurface name="board" width={64} height={64}
      centerZOffset={mountHeight} normalDirection="z+" />
  </assembly.printedpart>;
}

export function MountingHardware() {
  return mountingPoints.map(({ name, x, y }) => (
    <assembly.subassembly key={name} name={name}>
      <assembly.part name="BOLT" displayName="M3 x 18 nylon screw (nominal, threads omitted)"
        cadModel={{ jscad: nylonModel(boltPlan), positionOffset: { x, y, z: 1.3 } }} />
      <assembly.part name="WASHER" displayName="M3 nylon washer, 0.5 mm"
        cadModel={{ jscad: nylonModel(washerPlan), positionOffset: { x, y, z: 0.8 } }} />
      <assembly.part name="NUT" displayName="M3 nylon nut (nominal, threads omitted)"
        cadModel={{ jscad: nylonModel(nutPlan), positionOffset: { x, y, z: -14 } }} />
    </assembly.subassembly>
  ));
}