Rotary Potentiometer (24 mm, cutaway)

A 24 mm panel-mount rotary potentiometer with its cover cut away: M8 x 0.75 bushing with a helical thread, washer and a nut with the mating thread, flatted shaft, phenolic wafer with the resistive track, rotor, wiper and three solder terminals. The body, bushing, shaft and terminal dimensions and the 300 degree travel are published figures, and the shaft angle moves the wiper. The kernel measures the share of the track between terminal 1 and the wiper. The wafer, the track, the rotor, the wiper and the cover tabs are a display model.
Code
This is the full program. The playground runs it in your browser without a change.
import { box, clone, compound, cut, cutAll, cylinder, extrude, fuseAll, line, loft, measureVolume, polygon, revolve, rotate, unwrap, wire } from 'brepjs/quick';
import { color } from 'brepjs/playground';
// 24 mm panel-mount rotary potentiometer with its cover cut away. The build has the shaft on +Z and the
// mounting face at z = 0. The last lines lay the shaft near +Y with the terminals up. Units are millimetres.
// The body, bushing, shaft, lug and terminal dimensions and the 300 degree travel are published figures.
// The wafer, the track, the rotor, the wiper, the cover tabs and the nut are a display model.
interface PotParams {
angle?: number; // shaft angle in degrees from the full counterclockwise stop, 0 to 300. It moves the wiper
cutaway?: number; // degrees of the cover to cut away (0 = closed)
shaft?: 20 | 25 | 30; // shaft length from the mounting face
}
type P2 = [number, number];
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 (24 mm carbon potentiometer, solder lugs, flatted shaft)
const BODY = { diameter: 24, depth: 11.8 };
const BUSHING = { major: 8, minor: 7.188, pitch: 0.75, length: 6.5 }; // M8 x 0.75, fine thread
const SHAFT = { diameter: 6, flat: 4.5, flatLength: 12, chamfer: 0.5 }; // flat: thickness that stays at the flat
const TRAVEL = 300; // mechanical angle in degrees
const LUG = { at: 11.5, thick: 1.2, width: 2.8 }; // anti-rotation lug on the mounting face
const TERMINALS = { pitch: 6.7, reach: 19.5 }; // three solder lugs. reach is from the axis to the tips
const TOTAL_OHMS = 10000; // one value of the standard series, linear taper
// ---- display model
const PLATE = 1.6; // front plate, one piece with the bushing
const WAFER = { thick: 1.6, radius: 11.5, tongue: 9.5, bore: 3.4 }; // phenolic board that carries the track
const TRACK = { inner: 8, outer: 10.5, thick: 0.15 };
const COLLECTOR = { inner: 4, outer: 5.5 }; // ring for the centre terminal
const STRIP = { width: 3.4, thick: 0.5 };
const ROTOR = { radius: 7, gap: 1, back: 9 };
const WIPER = { width: 1.3, thick: 0.3, contact: 0.5 }; // width of one finger
const COVER = 0.5; // sheet of the cover
const NUT = { flats: 11, height: 2, washer: 6.5 };
const PLAY = 0.08; // radial play between the bushing thread and the nut thread
const VIEW_TURN = -8; // degrees that the laid part turns about Z for the view
// One helical thread tooth about +Z, from z = from to z = to. Its crest passes the +X side at z = ref.
// tip > core is the thread of a screw on a core of that radius. tip < core is the thread in a bore.
// The loft is smooth: each flank is one helical face.
const FACETS = 12; // sections of the loft in each turn
const SLACK = 0.998; // keeps the tooth a hair clear of its core or its bore
const helixTooth = (core: number, tip: number, pitch: number, from: number, to: number, ref: number): Shape => {
const root = tip > core ? core / SLACK : core * SLACK;
const crest = tip > core ? tip : tip / SLACK;
const half = 0.42 * pitch;
const n = Math.max(2, Math.round(((to - from) / pitch) * FACETS));
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;
};
// The thread of a screw between two heights, and the mating thread of a nut or a tapped hole. The two are half a pitch apart.
const screwTooth = (m: { major: number; minor: number; pitch: number }, z0: number, z1: number): Shape =>
helixTooth(m.minor / 2, m.major / 2, m.pitch, z0 + 0.42 * m.pitch, z1 - 0.42 * m.pitch, 0);
const nutTooth = (m: { major: number; minor: number; pitch: number }, z0: number, z1: number): Shape =>
helixTooth(m.major / 2 + PLAY, m.minor / 2 + PLAY, m.pitch, z0 + 0.42 * m.pitch, z1 - 0.42 * m.pitch, m.pitch / 2);
const turn = (s: Shape, deg: number): Shape => rotate(s, deg, { axis: [0, 0, 1] }) as Shape;
// A closed profile in the (r, z) half-plane, revolved about the axis.
const lathe = (pts: P2[], angle = 2 * Math.PI): Shape => unwrap(revolve(own(unwrap(polygon(pts.map(([r, z]): P3 => [r, 0, z])))), { axis: [0, 0, 1], angle })) as Shape;
const ring = (r0: number, r1: number, z0: number, z1: number): Shape => lathe([[r0, z0], [r1, z0], [r1, z1], [r0, z1]]);
// A part of a ring: from the angle start, counterclockwise through sweep degrees.
const arc = (r0: number, r1: number, z0: number, z1: number, start: number, sweep: number): Shape =>
turn(own(lathe([[r0, z0], [r1, z0], [r1, z1], [r0, z1]], (sweep * Math.PI) / 180)), start);
const slab = (x0: number, x1: number, y0: number, y1: number, z0: number, z1: number): Shape => own(box(x1 - x0, y1 - y0, z1 - z0, { at: [(x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2] }));
function potentiometer({ angle = 225, cutaway = 200, shaft = 25 }: PotParams = {}) {
const turned = Math.max(0, Math.min(TRAVEL, angle));
const rs = SHAFT.diameter / 2;
const rBody = BODY.diameter / 2;
// Front plate and bushing in one piece. The bushing has one helical tooth.
const crest = BUSHING.major / 2;
const core = BUSHING.minor / 2;
const plate = own(lathe([[rs, -PLATE], [WAFER.radius, -PLATE], [WAFER.radius, 0], [core, 0], [core, BUSHING.length - 0.3], [core - 0.3, BUSHING.length], [rs, BUSHING.length]]));
const lug = slab(-LUG.at - LUG.thick / 2, -LUG.at + LUG.thick / 2, -LUG.width / 2, LUG.width / 2, -PLATE, 2);
const front = unwrap(fuseAll([plate, lug])) as Shape;
const tooth = own(screwTooth(BUSHING, 0, BUSHING.length - 0.3));
// Washer and hex nut on the bushing. The nut has the mating thread, half a pitch from the thread of the bushing.
const washer = own(ring(crest + 0.1, NUT.washer, 0, 0.5));
const across = NUT.flats / Math.sqrt(3);
const hex = own(unwrap(polygon(Array.from({ length: 6 }, (_, i): P3 => [across * Math.cos((i * Math.PI) / 3), across * Math.sin((i * Math.PI) / 3), 0.5]))));
const nut = own(unwrap(cut(own(unwrap(extrude(hex, [0, 0, NUT.height])) as Shape), own(cylinder(crest + PLAY, 6, { at: [0, 0, -1] })))) as Shape);
const nutThread = own(nutTooth(BUSHING, 0.5, 0.5 + NUT.height));
// Shaft with a chamfer and a flat.
const c = SHAFT.chamfer;
const round = own(lathe([[0, -ROTOR.back], [rs, -ROTOR.back], [rs, shaft - c], [rs - c, shaft], [0, shaft]]));
const stem = unwrap(cut(round, slab(SHAFT.flat - rs, rs + 1, -rs - 1, rs + 1, shaft - SHAFT.flatLength, shaft + 1))) as Shape;
// Wafer: a disc with a tongue for the terminals. The track and the collector ring are on its rear face.
const zw = -PLATE - WAFER.thick;
const wafer = unwrap(cut(own(unwrap(fuseAll([own(ring(0, WAFER.radius, zw, -PLATE)), slab(-WAFER.tongue, WAFER.tongue, -15, 0, zw, -PLATE)])) as Shape), own(cylinder(WAFER.bore, 6, { at: [0, 0, zw - 1] })))) as Shape;
const zt = zw - TRACK.thick;
const gap = (360 - TRAVEL) / 2; // the track is open for 60 degrees at the terminals
const first = 270 - gap; // end of the track at terminal 1: the full counterclockwise stop
const wiperAt = first - turned;
const used = turned > 0.5 ? [arc(TRACK.inner, TRACK.outer, zt, zw, wiperAt, turned)] : [];
const rest = turned < TRAVEL - 0.5 ? [arc(TRACK.inner, TRACK.outer, zt, zw, first - TRAVEL, TRAVEL - turned)] : [];
const collector = own(ring(COLLECTOR.inner, COLLECTOR.outer, zt, zw));
// Terminals: three strips with solder eyes. The outer two lie on the ends of the track.
const eye = (x: number): Shape => own(cylinder(0.9, 3, { at: [x, -TERMINALS.reach + 2.2, zt - 2] }));
const strip = (x: number, top: number): Shape => own(unwrap(cut(slab(x - STRIP.width / 2, x + STRIP.width / 2, -TERMINALS.reach, top, zt - STRIP.thick, zt), eye(x))) as Shape);
const terminals = [strip(-TERMINALS.pitch, -8.6), strip(0, -4.5), strip(TERMINALS.pitch, -8.6)];
// Rotor on the shaft, with the wiper: a spring plate with two fingers on the track and a contact on the collector.
const zr = zt - ROTOR.gap;
const rotor = lathe([[rs, -ROTOR.back + 0.5], [rs + 1.6, -ROTOR.back + 0.5], [rs + 1.6, -ROTOR.back + 2], [ROTOR.radius, -ROTOR.back + 2], [ROTOR.radius, zr], [rs, zr]]);
const reach = (TRACK.inner + TRACK.outer) / 2;
const base = slab(rs + 0.4, ROTOR.radius, -WIPER.width, WIPER.width, zr, zr + WIPER.thick);
const finger = (side: number): Shape => slab(ROTOR.radius, reach + 0.9, side * WIPER.width - WIPER.width / 2, side * WIPER.width + WIPER.width / 2, zr, zr + WIPER.thick);
const contact = (r: number, y: number): Shape => own(cylinder(WIPER.contact, zt - zr - WIPER.thick, { at: [r, y, zr + WIPER.thick] }));
const wiper = [base, finger(0.5), finger(-0.5), contact(reach, WIPER.width / 2), contact(reach, -WIPER.width / 2), contact((COLLECTOR.inner + COLLECTOR.outer) / 2, 0)].map((s) => own(turn(s, wiperAt)));
// Cover: a drawn cup with a notch for the tongue and three tabs that fold over the front plate.
const zc = -BODY.depth;
const cup = own(lathe([[0, zc], [rBody, zc], [rBody, zw], [rBody - COVER, zw], [rBody - COVER, zc + COVER], [0, zc + COVER]]));
const tab = own(lathe([[WAFER.radius, zw], [rBody, zw], [rBody, 0.4], [rBody - 2, 0.4], [rBody - 2, 0], [WAFER.radius, 0]], (20 * Math.PI) / 180));
const tabs = [20, 80, 140].map((a) => own(turn(tab, a)));
const whole = own(unwrap(cut(own(unwrap(fuseAll([cup, ...tabs])) as Shape), slab(-WAFER.tongue - 0.1, WAFER.tongue + 0.1, -14, -8, zt - STRIP.thick - 0.3, zw))) as Shape);
const wedge = own(turn(own(lathe([[0, zc - 1], [rBody + 2, zc - 1], [rBody + 2, 2], [0, 2]], (Math.max(cutaway, 1) * Math.PI) / 180)), -cutaway / 2));
const cover = cutaway > 0 ? (unwrap(cut(whole, wedge)) as Shape) : (unwrap(clone(whole)) as Shape);
// The share of the track between terminal 1 and the wiper, from the kernel volumes.
const volume = (parts: Shape[]): number => parts.reduce((sum, s) => sum + unwrap(measureVolume(s)), 0);
const share = volume(used) / (volume(used) + volume(rest));
// Lay the shaft near +Y, with the terminals up and the open side toward +X.
const lay = (s: Shape): Shape => turn(own(rotate(s, -90, { axis: [1, 0, 0] }) as Shape), VIEW_TURN);
const group = (parts: Shape[]): Shape => lay(own(compound(parts) as Shape));
return {
metal: group([own(front), tooth, own(cover)]), hardware: group([washer, nut, nutThread]), stem: lay(own(stem)), wafer: lay(own(wafer)), track: group([...used.map(own), ...rest.map(own)]),
contacts: group([collector, ...terminals, ...wiper]), rotor: lay(own(rotor)), share, turned,
};
}
const part = freeing(() => potentiometer());
console.log('Shaft at ' + part.turned + ' of ' + TRAVEL + ' degrees. The kernel measures ' + (100 * part.share).toFixed(1) + ' % of the track between terminal 1 and the wiper.');
console.log('Linear taper: ' + (part.share * TOTAL_OHMS).toFixed(0) + ' ohm of ' + TOTAL_OHMS + ' ohm from terminal 1 to terminal 2.');
export default [
color(part.metal, '#c3c9d1'),
color(part.hardware, '#8d96a0'),
color(part.stem, '#e6e9ee'),
color(part.wafer, '#a5713d'),
color(part.track, '#2b2f36'),
color(part.contacts, '#d3a956'),
color(part.rotor, '#12b5b0'),
];Functions used
box clone compound cut cutAll cylinder extrude fuseAll line loft measureVolume polygon revolve rotate unwrap wire color
▶ Run Rotary Potentiometer (24 mm, cutaway) in the playground