Devesh36/bench-eight

Eight-channel 0–10 V measurement and control console: dual ADS1115 ADCs, buffered inputs, Pico controller, microSD, RTC, RS-485, four protected low-voltage outputs and a separate OLED/encoder panel in a tscircuit assembly.

Version
0.1.3
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone Devesh36/bench-eight  # download the package files into ./bench-eight
tsci add Devesh36/bench-eight    # add it to your project as @tsci/Devesh36.bench-eight

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.

mechanics.tsx

import { jscad } from "tscircuit";
import { PixelText } from "./lettering";
export const mounts = [-75, 75].flatMap((x) =>
	[-55, 55].map((y) => [x, y] as const),
);
export function Rounded({
	w,
	d,
	h,
	z,
	r = 5,
}: { w: number; d: number; h: number; z: number; r?: number }) {
	return (
		<jscad.hull>
			{[-1, 1].flatMap((x) =>
				[-1, 1].map((y) => (
					<jscad.cylinder
						key={`${x}:${y}`}
						radius={r}
						height={h}
						center={[x * (w / 2 - r), y * (d / 2 - r), z]}
					/>
				)),
			)}
		</jscad.hull>
	);
}
export function Base() {
	return (
		<jscad.subtract>
			<jscad.union>
				<jscad.subtract>
					<Rounded w={168} d={128} h={38} z={13} />
					<Rounded w={163} d={123} h={39} z={16.5} r={3} />
				</jscad.subtract>
				{mounts.map(([x, y]) => (
					<jscad.cylinder
						key={`${x}:${y}`}
						radius={3.5}
						height={4.2}
						center={[x, y, -2.9]}
					/>
				))}
			</jscad.union>
			{mounts.map(([x, y]) => (
				<jscad.cylinder
					key={`${x}:${y}`}
					radius={1.25}
					height={9}
					center={[x, y, -3]}
				/>
			))}
			{/* Open access wells align to the actual terminal blocks. */}
			<jscad.cuboid size={[148, 12, 34]} center={[0, 62, 20]} />
			<jscad.cuboid size={[12, 66, 34]} center={[82, 5, 20]} />
			<jscad.cuboid size={[14, 12, 8]} center={[-45, -62, 2]} />
			<jscad.cuboid size={[13, 12, 7]} center={[-23, -62, 3]} />
			<jscad.cuboid size={[22, 15, 6]} center={[-63, -62, 2]} />
			<jscad.cuboid size={[47, 12, 13]} center={[56, -62, 7]} />
			{Array.from({ length: 9 }, (_, i) => (
				<jscad.cuboid
					key={i}
					size={[5, 3, 14]}
					center={[-83, -20 + i * 5, 18]}
				/>
			))}
		</jscad.subtract>
	);
}
export function Lid() {
	return (
		<jscad.subtract>
			<Rounded w={168} d={128} h={2.4} z={33.2} />
			<jscad.cuboid size={[56, 28.5, 8]} center={[-15, -6, 33]} />
			<jscad.cylinder radius={4} height={10} center={[37, -6, 33]} />
			<jscad.cylinder radius={1.6} height={10} center={[43, 9, 33]} />
			<jscad.cuboid size={[146, 25, 8]} center={[0, 51, 33]} />
			<jscad.cuboid size={[24, 65, 8]} center={[75, 5, 33]} />
			<jscad.cuboid size={[22, 18, 8]} center={[-63, -58, 33]} />
			<jscad.cuboid size={[45, 20, 8]} center={[57, -55, 33]} />
			{mounts.map(([x, y]) => (
				<jscad.cylinder
					key={`${x}:${y}`}
					radius={1.7}
					height={7}
					center={[x, y, 33]}
				/>
			))}
			{Array.from({ length: 8 }, (_, i) => (
				<jscad.cuboid
					key={i}
					size={[2, 12, 8]}
					center={[-64 + i * 4, 19, 33]}
				/>
			))}
		</jscad.subtract>
	);
}
export function Pillars() {
	return (
		<jscad.union>
			{mounts.map(([x, y]) => (
				<jscad.subtract key={`${x}:${y}`}>
					<jscad.cylinder radius={3} height={31.2} center={[x, y, 16.4]} />
					<jscad.cylinder radius={1.25} height={36} center={[x, y, 16.4]} />
				</jscad.subtract>
			))}
		</jscad.union>
	);
}
export function PanelSpacers() {
	return (
		<jscad.union>
			{[-50, 50].flatMap((x) =>
				[-26, 14].map((y) => (
					<jscad.subtract key={`${x}:${y}`}>
						<jscad.cylinder radius={3} height={20.4} center={[x, y, 11]} />
						<jscad.cylinder radius={1.6} height={24} center={[x, y, 11]} />
					</jscad.subtract>
				)),
			)}
		</jscad.union>
	);
}
export function Bezel() {
	return (
		<jscad.subtract>
			<jscad.cuboid size={[60, 32.5, 0.8]} center={[-15, -6, 34.8]} />
			<jscad.cuboid size={[55.5, 28, 3]} center={[-15, -6, 34.8]} />
		</jscad.subtract>
	);
}
export function DisplayBoard() {
	return <jscad.cuboid size={[61.5, 39.5, 1.6]} center={[-15, -6, 29.2]} />;
}
export function DisplayGlass() {
	return <jscad.cuboid size={[58, 31, 2]} center={[-15, -6, 32]} />;
}
export function DisplayText() {
	return (
		<jscad.union>
			<PixelText text="BENCH EIGHT" x={-40} y={4} z={33.02} pitch={0.65} />
			<PixelText text="NO DATA" x={-30} y={-9} z={33.02} pitch={0.6} />
		</jscad.union>
	);
}
export function Branding() {
	return (
		<jscad.union>
			<PixelText text="BENCH EIGHT" x={-35} y={29} z={34.43} pitch={1.05} />
			<PixelText text="tscircuit" x={-18} y={-34} z={34.43} pitch={0.67} />
			<PixelText text="TURN" x={31} y={-23} z={34.43} pitch={0.5} />
			<PixelText text="USB 5V" x={-52} y={-51} z={34.43} pitch={0.38} />
			<PixelText text="ON  OFF" x={-29} y={-52} z={34.43} pitch={0.38} />
			{Array.from({ length: 8 }, (_, i) => (
				<PixelText
					key={i}
					text={`CH${i + 1}`}
					x={-67 + i * 18}
					y={37}
					z={34.43}
					pitch={0.45}
				/>
			))}
		</jscad.union>
	);
}
export function Knob() {
	return (
		<jscad.subtract>
			<jscad.union>
				<jscad.cylinder radius={9} height={10} center={[37, -6.5, 44]} />
				<jscad.cylinder radius={9.5} height={1} center={[37, -6.5, 39.5]} />
			</jscad.union>
			<jscad.cylinder radius={3} height={10} center={[37, -6.5, 42]} />
			{Array.from({ length: 24 }, (_, i) => (
				<jscad.cylinder
					key={i}
					radius={0.55}
					height={11}
					center={[
						37 + 9 * Math.cos((i * Math.PI) / 12),
						-6.5 + 9 * Math.sin((i * Math.PI) / 12),
						44,
					]}
				/>
			))}
		</jscad.subtract>
	);
}
export function DisplayClips() {
	return (
		<jscad.union>
			{[-1, 1].map((side) => (
				<jscad.union key={side}>
					<jscad.cuboid
						size={[2, 41, 5]}
						center={[-15 + side * 32, -6, 29.5]}
					/>
					<jscad.cuboid size={[4, 41, 1]} center={[-15 + side * 31, -6, 28]} />
				</jscad.union>
			))}
		</jscad.union>
	);
}
export function Feet() {
	return (
		<jscad.union>
			{mounts.map(([x, y]) => (
				<jscad.cylinder
					key={`${x}:${y}`}
					radius={5}
					height={2.5}
					center={[x, y, -7.25]}
				/>
			))}
		</jscad.union>
	);
}
export function Screws() {
	return (
		<jscad.union>
			{mounts.map(([x, y]) => (
				<jscad.cylinder
					key={`${x}:${y}`}
					radius={2.5}
					height={1.2}
					center={[x, y, 35]}
				/>
			))}
		</jscad.union>
	);
}
export function Slider() {
	return <jscad.cuboid size={[2.3, 13, 2.3]} center={[-24, -59, 2.7]} />;
}
export function LedPipe() {
	return <jscad.cylinder radius={1.4} height={11.5} center={[43, 9, 28.6]} />;
}

export function Harness({
	lift = 0,
	panelLift = lift,
}: { lift?: number; panelLift?: number }) {
	const paths = [
		[
			[27, -12, 7],
			[33, -12, 14],
			[33, -38, 17],
			[-37, -38, 20 + panelLift],
			[-37, -6, 28 + panelLift],
		],
		[
			[-14, -23, 28 + panelLift],
			[-30, -24, 32 + lift],
			[-44, -6, 31 + lift],
		],
	];
	return (
		<jscad.colorize color="#3c5167">
			<jscad.union>
				{paths.flatMap((points, k) =>
					points.slice(1).map((p, i) => (
						<jscad.hull key={`${k}:${i}`}>
							<jscad.sphere
								radius={k ? 1 : 1.7}
								center={points[i] as [number, number, number]}
							/>
							<jscad.sphere
								radius={k ? 1 : 1.7}
								center={p as [number, number, number]}
							/>
						</jscad.hull>
					)),
				)}
			</jscad.union>
		</jscad.colorize>
	);
}