5 x 20 mm Panel Fuse Holder

A low-profile panel fuse holder with its 5 x 20 mm fuse, in half section: screw cap, glass fuse with its element, contact sleeve, spring, solder terminals, panel and nut. The outline, the D-shaped panel hole, the terminals, the fuse and the three masses are published figures. The kernel measures the mass of the socket, the cap and the nut. The cap and the nut run on true helical threads: the cap turns once for each pitch as it comes out. The bores, the contacts, the spring and the two thread sizes are a display model.
Code
This is the full program. The playground runs it in your browser without a change.
ts
import { box, circle, compound, cut, cutAll, cylinder, extrude, helix, line, loft, measureVolume, polygon, revolve, rotate, sweep, translate, unwrap, wire } from 'brepjs/quick';
import { color } from 'brepjs/playground';
// Panel fuse holder with a 5 x 20 mm fuse, in half section. The axis is Z, the panel face is z = 0, units are mm.
// The outline, the panel hole, the terminals, the fuse and the three masses are published figures.
// The bores, the contacts, the spring and the two thread sizes are a display model. Both threads are true helices.
interface FuseHolderParams {
cutaway?: number; // degrees of the plastic parts and the glass to cut away (0 = closed)
release?: number; // 0 = cap screwed in, 1 = cap and fuse out. The cap turns once for each pitch of travel.
panel?: number; // panel thickness, up to the published 7 mm
}
type P2 = [number, number]; // [r, z]
type P3 = [number, number, number];
type Shape = ReturnType<typeof cylinder>;
// Kernel shapes live in WASM memory. Every temporary goes through own(). freeing() runs a build and then frees them all.
const owned: { delete(): void }[] = [];
const own = <T extends { delete(): void }>(s: T): T => {
owned.push(s);
return s;
};
const freeing = <T,>(build: () => T): T => { try { return build(); } finally { owned.splice(0).forEach((s) => s.delete()); } }; // also when the build throws
// ---- published figures (low-profile holder with a screw cap)
const HOLDER = { length: 35.2, front: 5.6, bezel: 16, bezelThick: 3.8, bezelTop: 14.9, cap: 11, thread: 12.1, threadEnd: 16, step: 23.6, rear: 9.1 };
const HOLE = { diameter: 12.3, flat: 11.6, maxPanel: 7 }; // D-shaped panel hole
const TAB = { length: 6.3, width: 3.1, thick: 0.5 }; // solder terminals
const FUSE = { length: 20, diameter: 5.2, cap: 5.1 };
const CATALOGUE_G = { socket: 3.09, cap: 1.41, nut: 0.3 };
// ---- display model
const DENSITY = { plastic: 1.4e-3, brass: 8.5e-3, steel: 7.85e-3 }; // grams per cubic millimetre
const BORE = { fuse: 3.2, cap: 4.8, floor: -4.8 }; // radius of the fuse bore and of the cap bore, and where they meet
const SEAT = 2.4; // the cap head sits on this step in the bezel
const FUSE_TOP = 2;
const GLASS = { outer: 2.4, inner: 1.9 };
const SPRING = { radius: 2.2, wire: 0.3, turns: 6, stroke: 3 };
const NUT = { flats: 15, thick: 3 };
const NECK = { pitch: 1, depth: 0.54 }; // thread of the neck and the panel nut, right-hand
const CAP = { pitch: 0.8, depth: 0.43 }; // thread of the cap in the socket, right-hand
const PLAY = 0.08; // radial clearance between two mating threads
const LIFT = 26; // travel of the cap at release = 1
// A closed profile in the (r, z) half-plane, revolved about the axis.
const lathe = (pts: P2[], angle = 2 * Math.PI): Shape => {
const profile = own(unwrap(polygon(pts.map(([r, z]): [number, number, number] => [r, 0, z]))));
return unwrap(revolve(profile, { axis: [0, 0, 1], angle })) as Shape;
};
const block = (x0: number, x1: number, y0: number, y1: number, z0: number, z1: number): Shape =>
box(x1 - x0, y1 - y0, z1 - z0, { at: [(x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2] });
// One helical thread tooth about Z, from z0 to z1. Its crest passes the +X side at z = ref.
// tip > core is the thread of a screw on a core. tip < core is the thread in a bore: ref is half a pitch away.
// The loft is smooth, so each flank is one helical face. A long loft drifts off the helix: a long thread is pieces of 4 turns.
const SECTIONS = 12; // sections of the loft in each turn
const SLACK = 0.998; // keeps the tooth of a screw a hair clear of its core
const BORE_SLACK = 0.99; // and the tooth in a bore clear of the wall
const helixTooth = (core: number, tip: number, pitch: number, z0: number, z1: number, ref: number): Shape => {
const root = tip > core ? core / SLACK : core * BORE_SLACK;
const crest = tip > core ? tip : tip / SLACK;
const half = 0.42 * pitch;
const piece = (from: number, to: number): Shape => {
const n = Math.max(2, Math.round(((to - from) / pitch) * SECTIONS));
const sections = Array.from({ length: n + 1 }, (_, j) => {
const z = from + ((to - from) * j) / n;
const a = 2 * Math.PI * ((z - ref) / pitch);
const at = (r: number, dz: number): P3 => [r * Math.cos(a), r * Math.sin(a), z + dz];
const pts = [at(root, -half), at(crest, 0), at(root, half)];
return own(unwrap(wire(pts.map((p, i) => own(line(p, pts[(i + 1) % 3]!))))));
});
return unwrap(loft(sections, { ruled: false })) as Shape;
};
const count = Math.max(1, Math.ceil((z1 - z0) / (4 * pitch) - 0.001));
const pieces = Array.from({ length: count }, (_, i) => piece(z0 + ((z1 - z0) * i) / count, z0 + ((z1 - z0) * (i + 1)) / count));
return count === 1 ? pieces[0]! : (compound(pieces.map(own)) as Shape);
};
// The same tooth, only where its angle about Z is from a0 to a1 degrees: one piece for each turn.
// A section through the axis needs no boolean cut this way.
const helixArcs = (core: number, tip: number, pitch: number, z0: number, z1: number, ref: number, a0: number, a1: number): Shape[] => {
const pieces: Shape[] = [];
for (let k = Math.floor((z0 - ref) / pitch) - 2; ref + (k + a0 / 360) * pitch < z1; k++) {
const from = Math.max(z0, ref + (k + a0 / 360) * pitch);
const to = Math.min(z1, ref + (k + a1 / 360) * pitch);
if (to - from > 0.04 * pitch) pieces.push(helixTooth(core, tip, pitch, from, to, ref));
}
return pieces;
};
const volume = (s: Shape): number => unwrap(measureVolume(s));
const sum = (parts: Shape[]): number => parts.reduce((total, s) => total + volume(s), 0);
function fuseHolder({ cutaway = 180, release = 0, panel = 2 }: FuseHolderParams = {}) {
const lift = LIFT * Math.min(Math.max(release, 0), 1);
const plate = Math.min(Math.max(panel, 1), HOLE.maxPanel);
const end = HOLDER.front - HOLDER.length; // rear end of the body
const step = HOLDER.front - HOLDER.step;
const neck = HOLDER.front - HOLDER.threadEnd;
const rt = HOLDER.thread / 2;
const rn = rt - NECK.depth; // core of the neck thread
const capTip = BORE.cap - PLAY; // crest of the cap thread
const capCore = capTip - CAP.depth;
const spin = (360 * lift) / CAP.pitch; // the cap unscrews: one turn for each pitch
const floor = end + 1.2;
// Socket: bezel, threaded neck with a flat, stepped rear. One revolve, then the flat and the slot for the side strip.
// The neck thread carries the nut. The thread in the cap bore mates with the cap.
const flatAt = HOLE.flat - HOLE.diameter / 2 - 0.1;
const strip = block(-TAB.width / 2, TAB.width / 2, 4.3, 4.3 + TAB.thick, step - TAB.length, BORE.floor);
const socket = unwrap(cutAll(own(lathe([
[0.8, end], [4, end], [HOLDER.rear / 2, step], [rn, step], [rn, 0],
[HOLDER.bezel / 2, 0], [HOLDER.bezel / 2, HOLDER.bezelThick - 0.6], [HOLDER.bezelTop / 2, HOLDER.bezelThick], [HOLDER.cap / 2 + 0.1, HOLDER.bezelThick],
[HOLDER.cap / 2 + 0.1, SEAT], [BORE.cap, SEAT], [BORE.cap, BORE.floor], [BORE.fuse, BORE.floor], [BORE.fuse, floor], [0.8, floor],
])), [own(block(-10, -flatAt, -10, 10, neck, 0)), strip])) as Shape;
// Each thread is built only where the section leaves it, from sectionEdge to 360 - sectionEdge degrees. The neck thread stops at the flat.
const sectionEdge = Math.max(cutaway, 0) / 2;
const teeth = (core: number, tip: number, pitch: number, z0: number, z1: number, ref: number): Shape[] =>
(cutaway > 0 ? helixArcs(core, tip, pitch, z0, z1, ref, sectionEdge, 360 - sectionEdge) : [helixTooth(core, tip, pitch, z0, z1, ref)]).map(own);
const whole = (core: number, tip: number, pitch: number, z0: number, z1: number, ref: number): number => volume(own(helixTooth(core, tip, pitch, z0, z1, ref))); // for the mass
const flatEdge = (Math.acos(flatAt / rt) * 180) / Math.PI;
const neckSpan = [rn, rt, NECK.pitch, neck + 0.5, -0.5, 0] as const;
const neckTeeth = [...helixArcs(...neckSpan, sectionEdge, 180 - flatEdge), ...helixArcs(...neckSpan, 180 + flatEdge, 360 - sectionEdge)].map(own);
const boreSpan = [BORE.cap, capCore + PLAY, CAP.pitch, BORE.floor + 1.3, SEAT - 0.4, CAP.pitch / 2] as const;
// Contacts of the socket: a ring under the cap, the side strip, the end rivet with its tab, the spring and its button.
const ring = lathe([[BORE.fuse, BORE.floor], [BORE.cap, BORE.floor], [BORE.cap, BORE.floor + 0.4], [BORE.fuse, BORE.floor + 0.4]]);
const rivet = lathe([[0, end], [0.8, end], [0.8, floor], [2.8, floor], [2.8, floor + 0.6], [0, floor + 0.6]]);
const tab = unwrap(cut(own(block(-TAB.width / 2, TAB.width / 2, -TAB.thick / 2, TAB.thick / 2, end - TAB.length, end)), own(cylinder(0.7, 2, { at: [0, -1, end - TAB.length + 1.6], axis: [0, 1, 0] })))) as Shape;
const rest = FUSE_TOP - FUSE.length - 0.6 - (floor + 0.6); // spring length under the fuse
const reach = rest + Math.min(lift, SPRING.stroke); // the spring follows the fuse for a short stroke
const pitch = (reach - 2 * SPRING.wire) / SPRING.turns;
const coil = own(unwrap(wire([own(circle(SPRING.wire, { at: [SPRING.radius, 0, 0], axis: [0, 1, pitch / (2 * Math.PI * SPRING.radius)] }))])));
const spring = own(unwrap(sweep(coil as never, own(helix(pitch, reach - 2 * SPRING.wire, SPRING.radius)), { mode: 'simple' })) as Shape);
const top = floor + 0.6 + reach;
const button = lathe([[0, top], [2.8, top], [2.8, top + 0.6], [0, top + 0.6]]);
// Cap: a head with a cross slot for a screwdriver and a threaded skirt, with a brass sleeve that grips the fuse.
const head = HOLDER.front;
const capBlank = own(lathe([
[3, BORE.floor + 0.8], [capCore, BORE.floor + 0.8], [capCore, SEAT], [HOLDER.cap / 2, SEAT], [HOLDER.cap / 2, head - 0.5], [HOLDER.cap / 2 - 0.5, head],
[0, head], [0, SEAT], [3, SEAT],
]));
const cap = unwrap(cutAll(capBlank, [own(block(-4.2, 4.2, -0.6, 0.6, head - 1.3, head + 1)), own(block(-0.6, 0.6, -4.2, 4.2, head - 1.3, head + 1))])) as Shape;
// A screw that turns as it travels keeps its helix in place: only the ends of the cap thread move with the lift.
const capSpan = [capCore, capTip, CAP.pitch, BORE.floor + 1.2 + lift, SEAT - 0.4 + lift, 0] as const;
const sleeve = lathe([
[FUSE.diameter / 2, BORE.floor + 0.4], [capCore - 0.1, BORE.floor + 0.4], [capCore - 0.1, BORE.floor + 0.8], [3, BORE.floor + 0.8], [3, SEAT], [0, SEAT], [0, FUSE_TOP], [FUSE.diameter / 2, FUSE_TOP],
]);
// Fuse: two end caps on a glass tube, and the element between them.
const rf = FUSE.diameter / 2;
const endCap = (z: number, dir: number): Shape => lathe([[0, z], [rf, z], [rf, z + dir * FUSE.cap], [GLASS.outer, z + dir * FUSE.cap], [GLASS.outer, z + dir * 0.3], [0, z + dir * 0.3]]);
const zf = FUSE_TOP - FUSE.length;
const fuseCaps = [endCap(FUSE_TOP, -1), endCap(zf, 1)];
const glass = lathe([[GLASS.inner, zf + 0.3], [GLASS.outer, zf + 0.3], [GLASS.outer, FUSE_TOP - 0.3], [GLASS.inner, FUSE_TOP - 0.3]]);
const element = cylinder(0.25, FUSE.length - 0.6, { at: [0, 0, zf + 0.3] });
// Panel with its D hole, and the nut behind it. The nut has the mating thread. It turns as the panel thickness moves it.
const dHole = own(unwrap(cut(own(cylinder(HOLE.diameter / 2, 20, { at: [0, 0, -10] })), own(block(-10, HOLE.diameter / 2 - HOLE.flat, -10, 10, -11, 11)))) as Shape);
const sheet = unwrap(cut(own(block(-14, 14, -14, 14, -plate, 0)), dHole)) as Shape;
const hex = own(unwrap(polygon(Array.from({ length: 6 }, (_, i): [number, number, number] => [(NUT.flats / Math.sqrt(3)) * Math.cos((i * Math.PI) / 3), (NUT.flats / Math.sqrt(3)) * Math.sin((i * Math.PI) / 3), -plate - NUT.thick]))));
const nutBlank = own(rotate(own(unwrap(extrude(hex, NUT.thick)) as Shape), (-360 * plate) / NECK.pitch) as Shape);
const nut = unwrap(cut(nutBlank, own(cylinder(rt + PLAY, 20, { at: [0, 0, -15] })))) as Shape;
const nutSpan = [rt + PLAY, rn + PLAY, NECK.pitch, -plate - NUT.thick + 0.5, -plate - 0.5, NECK.pitch / 2] as const;
// Mass of the three catalogue items, from the kernel volumes of the whole parts.
const grams = {
socket: (volume(socket) + whole(...neckSpan) * ((360 - 2 * flatEdge) / 360) + whole(...boreSpan)) * DENSITY.plastic + sum([ring, strip, rivet, tab, button]) * DENSITY.brass + volume(spring) * DENSITY.steel,
cap: (volume(cap) + whole(...capSpan)) * DENSITY.plastic + volume(sleeve) * DENSITY.brass,
nut: (volume(nut) + whole(...nutSpan)) * DENSITY.plastic,
};
// Half section: a boolean cut of the plastic, the sleeve, the ring and the glass, centred on +X.
const wedge = own(rotate(own(lathe([[0, -60], [40, -60], [40, 60], [0, 60]], (Math.max(cutaway, 1) * Math.PI) / 180)), -cutaway / 2) as Shape);
const open = (s: Shape, dz = 0): Shape => {
own(s);
const cutOpen = cutaway > 0 ? own(unwrap(cut(s, wedge)) as Shape) : s;
return translate(cutOpen, [0, 0, dz]) as Shape;
};
const up = (s: Shape): Shape => own(translate(own(s), [0, 0, lift]) as Shape);
const turned = (s: Shape): Shape => rotate(own(s), spin) as Shape; // the cap, before the section cut
return {
socket: compound([own(open(socket)), ...neckTeeth, ...teeth(...boreSpan)]) as Shape,
cap: compound([own(open(turned(cap), lift)), ...teeth(...capSpan)]) as Shape,
nut: compound([own(open(nut)), ...teeth(...nutSpan)]) as Shape,
panel: open(sheet),
brass: compound([own(open(ring)), own(open(sleeve, lift)), own(strip), own(rivet), own(tab), own(button)]) as Shape,
spring: translate(spring, [0, 0, floor + 0.6 + SPRING.wire]) as Shape,
fuseCaps: compound(fuseCaps.map(up)) as Shape,
glass: open(glass, lift),
element: translate(own(element), [0, 0, lift]) as Shape,
grams,
};
}
const part = freeing(() => fuseHolder());
const g = part.grams;
console.log('Mass from the kernel volumes: socket ' + g.socket.toFixed(2) + ' g, cap ' + g.cap.toFixed(2) + ' g, nut ' + g.nut.toFixed(2) + ' g.');
console.log('The catalogue has ' + CATALOGUE_G.socket + ' g, ' + CATALOGUE_G.cap + ' g and ' + CATALOGUE_G.nut + ' g.');
export default [
color(part.socket, '#f5f2ea'),
color(part.cap, '#12b5b0'),
color(part.nut, '#ff5a1f'),
color(part.panel, '#c3c9d1'),
color(part.brass, '#d3a956'),
color(part.spring, '#8d96a1'),
color(part.fuseCaps, '#e6e9ee'),
color(part.glass, '#bfe3e6'),
color(part.element, '#ff5a1f'),
];Functions used
box circle compound cut cutAll cylinder extrude helix line loft measureVolume polygon revolve rotate sweep translate unwrap wire color