RF Transmitter Enclosure

A finned die-cast aluminium transmitter box with its radio board, shield can and three connectors on one end wall: an antenna jack with a quarter-wave whip, a coaxial power jack and a six-contact data jack. The 1/4-36 antenna thread, the 5/16 in nut, the 5.5 x 2.1 mm power plug and the M3 screws are published figures, and the band sets the whip length. Each thread is a true helix in its mating thread, and the lid screws turn out of their bosses before the lid swings up. The kernel measures the mass of the box and the lid. The box and the board are a display model.
Code
This is the full program. The playground runs it in your browser without a change.
import { box, compound, cut, cutAll, cylinder, edgeFinder, extrude, fillet, fuseAll, line, loft, measureVolume, polygon, revolve, rotate, torus, translate, unwrap, wire } from 'brepjs/quick';
import { color } from 'brepjs/playground';
// Die-cast aluminium transmitter box with its connectors on one end wall. Z is up, units are millimetres.
// The antenna thread, the nut size, the power jack and the M3 screws are published figures. The whip
// length is a quarter of the wavelength. The box and the radio board are a display model.
interface TxParams {
band?: number; // carrier frequency in MHz. It sets the length of the whip.
explode?: number; // 0 = closed. To 0.4 the lid screws turn out of the bosses, then the lid swings up on its far edge
whipAngle?: number; // degrees the whip folds down at its knuckle (0 = upright)
}
type P2 = [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
const LIGHT_SPEED = 299792.458; // km/s. Divide by MHz to get the wavelength in millimetres.
const SMA = { thread: 6.35, minor: 5.59, pitch: 25.4 / 36, hex: 7.94 }; // 1/4-36 UNS thread, 5/16 in nut
const JACK = { barrel: 5.5, pin: 2.1 }; // coaxial power plug that the jack takes
const M3 = { major: 3, minor: 2.459, pitch: 0.5 }; // metric coarse thread
const M3_FLAT = { head: 5.6, headHeight: 1.86 }; // ISO 10642 countersunk head with a 2 mm hexagon socket
const M3_PAN = { head: 5.6, headHeight: 2.4 }; // ISO 7045 pan head
const DENSITY = 2.7e-3; // aluminium casting alloy, grams per cubic millimetre
// ---- display model
const BOX = { length: 115, width: 65, height: 30, wall: 2.5, corner: 4 };
const LID = 3; // plate thickness
const BOSS = { radius: 4, inset: 4.5, depth: 9 }; // corner screw bosses, tapped M3
const BOARD = { length: 96, width: 50, thick: 1.6, lift: 5 };
const PORT_Z = 5.2; // connector axis above the board
const FINS = { count: 11, pitch: 8, width: 3, depth: 3 }; // cooling fins on the two long walls
const OPEN = { lift: 10, tilt: 62, screws: 7.5, unscrew: 0.4 }; // lid and screw travel, and the part of explode that backs the screws out
const PLAY = 0.08; // radial play between a screw thread and its tapped hole
const PAN_SCREW = 5; // length of the board screws
const brick = (l: number, w: number, h: number, x: number, y: number, z: number): Shape => box(l, w, h, { at: [x, y, z + h / 2] });
// Box with rounded vertical edges, centred on the Z axis, bottom at z.
const tub = (l: number, w: number, h: number, z: number, r: number): Shape =>
unwrap(fillet(own(brick(l, w, h, 0, 0, z)), edgeFinder().inDirection('Z'), r)) as Shape;
// A closed profile in the (r, z) half-plane, revolved about Z.
const lathe = (pts: P2[]): Shape => {
const profile = own(unwrap(polygon(pts.map(([r, z]): [number, number, number] => [r, 0, z]))));
return unwrap(revolve(profile, { axis: [0, 0, 1] })) as Shape;
};
// The same, with its axis turned to +X and its origin moved to a point.
const latheX = (pts: P2[], at: [number, number, number]): Shape => translate(own(rotate(own(lathe(pts)), 90, { axis: [0, 1, 0] })), at);
// Hexagon across flats, extruded up from z.
const hexagon = (flats: number, h: number, z = 0): Shape => {
const r = flats / Math.sqrt(3);
const pts = Array.from({ length: 6 }, (_, i): [number, number, number] => [r * Math.cos((i * Math.PI) / 3), r * Math.sin((i * Math.PI) / 3), z]);
return unwrap(extrude(own(unwrap(polygon(pts))), h)) as Shape;
};
// A 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, tip < core is the thread in a hole. A right-hand thread.
const FACETS = 12; // sections of the smooth loft in each turn. Each flank is one helical face. A shallow thread on a large radius needs more
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, sections = FACETS): 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) * sections));
const loops = 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): [number, number, number] => [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 own(unwrap(loft(loops, { ruled: false }))) as Shape;
};
const FLANK = 0.42 * M3.pitch; // half width of an M3 tooth at its root
const RC = M3.minor / 2;
const RM = M3.major / 2;
// The thread of a tapped M3 hole from z = from to z = to. It is half a pitch from the thread of a screw on the same axis.
const tapped = (from: number, to: number): Shape => helixTooth(RM + PLAY, RC + PLAY, M3.pitch, from + FLANK, to - FLANK, M3.pitch / 2);
const volume = (s: Shape): number => unwrap(measureVolume(s));
function transmitter({ band = 868, explode = 1, whipAngle = 0 }: TxParams = {}) {
const { length: ol, width: ow, height: h, wall } = BOX;
const il = ol - 2 * wall;
const iw = ow - 2 * wall;
const bx = ol / 2 - BOSS.inset;
const by = ow / 2 - BOSS.inset;
const corners: P2[] = [[bx, by], [-bx, by], [-bx, -by], [bx, -by]];
const zb = wall + BOARD.lift;
const top = zb + BOARD.thick;
const axisZ = top + PORT_Z;
const face = ol / 2; // outer face of the +X wall
const edge = BOARD.length / 2;
const ports = { antenna: 16, power: -1, data: -15.5 }; // y of each connector
// Base: a cast tray with soft bottom edges, tapped corner bosses, tapped board pads and three ports in the +X wall.
const blank = own(tub(ol, ow, h + 4, 0, BOX.corner));
const soft = own(unwrap(fillet(blank, edgeFinder().not((f) => f.inDirection('Z')), 1.5)) as Shape);
const pads: P2[] = [[40, 21], [-44, 21], [-44, -21], [26, -21]];
const tray = own(unwrap(cutAll(soft, [own(brick(ol + 2, ow + 2, 6, 0, 0, h)), own(tub(il, iw, h, wall, 1.5))])) as Shape);
const cast = own(unwrap(fuseAll([
tray,
...corners.map(([x, y]) => own(cylinder(BOSS.radius, h - 1, { at: [x, y, 1] }))),
...pads.map(([x, y]) => own(cylinder(3, BOARD.lift + 1, { at: [x, y, wall - 1] }))),
...[1, -1].flatMap((side) => Array.from({ length: FINS.count }, (_, i) =>
own(brick(FINS.width, FINS.depth + 1, h - 8, (i - (FINS.count - 1) / 2) * FINS.pitch, side * (ow / 2 + FINS.depth / 2 - 0.5), 4)))),
])) as Shape);
const padDepth = PAN_SCREW - BOARD.thick + 0.6;
const casting = own(unwrap(cutAll(cast, [
...corners.map(([x, y]) => own(cylinder(RM + PLAY, BOSS.depth + 1, { at: [x, y, h - BOSS.depth] }))),
...pads.map(([x, y]) => own(cylinder(RM + PLAY, padDepth + 1, { at: [x, y, zb - padDepth] }))),
own(cylinder(SMA.thread / 2 + 0.15, wall + 2, { at: [face - wall - 1, ports.antenna, axisZ], axis: [1, 0, 0] })),
own(cylinder(4.2, wall + 2, { at: [face - wall - 1, ports.power, axisZ], axis: [1, 0, 0] })),
own(brick(wall + 2, 11.4, 8.6, face - wall / 2, ports.data, top + 0.9)),
])) as Shape);
const bossThread = tapped(h - BOSS.depth + 1, h);
const padThread = tapped(zb - padDepth + 0.4, zb);
const base = compound([casting, ...corners.map(([x, y]) => own(translate(bossThread, [x, y, 0]))), ...pads.map(([x, y]) => own(translate(padThread, [x, y, 0])))]) as Shape;
// Lid: a plate with countersunk holes and a label recess.
const sink = own(lathe([[0, 0.5], [M3_FLAT.head / 2 + 0.1, 0.5], [M3_FLAT.head / 2 + 0.1, -0.3], [1.7, -M3_FLAT.headHeight], [1.7, -LID - 1], [0, -LID - 1]]));
const plate = own(tub(ol, ow, LID, h, BOX.corner));
const lidWhole = own(unwrap(cutAll(plate, [
...corners.map(([x, y]) => own(translate(sink, [x, y, h + LID]))),
own(tub(46, 26, 1, h + LID - 0.5, 2)),
])) as Shape);
const grams = (volume(casting) + volume(lidWhole)) * DENSITY;
// First the screws back out of the bosses. Then the lid swings up on its far edge and takes the loose screws with it.
const backOut = OPEN.screws * Math.min(1, Math.max(0, explode) / OPEN.unscrew);
const up = Math.min(1, Math.max(0, (explode - OPEN.unscrew) / (1 - OPEN.unscrew)));
const swing = (s: Shape): Shape => rotate(own(translate(s, [0, 0, up * OPEN.lift])), -up * OPEN.tilt, { axis: [0, 1, 0], at: [-ol / 2, 0, h + up * OPEN.lift] });
const lid = swing(lidWhole);
// Countersunk lid screws with a hexagon socket and one helical tooth. One master, four copies.
// A screw that backs out turns by one turn for each pitch, so it stays in mesh with the thread of its boss.
const flat = M3_FLAT;
const shank = 10;
const screwBlank = own(lathe([[0, 0], [flat.head / 2, 0], [flat.head / 2, -0.3], [RM, -flat.headHeight], [RM, -LID], [RC, -LID], [RC, -shank + 0.2], [RC - 0.2, -shank], [0, -shank]]));
const socketed = own(unwrap(cut(screwBlank, own(hexagon(2, 1.3, -1.2)))) as Shape);
const threaded = own(compound([socketed, helixTooth(RC, RM, M3.pitch, -shank + 0.2 + FLANK, -LID - FLANK, -h - LID)]) as Shape);
const lidScrew = own(rotate(threaded, (360 * backOut) / M3.pitch));
const lidScrews = corners.map(([x, y]) => own(swing(own(translate(lidScrew, [x, y, h + LID + backOut])))));
// Radio board on the four tapped pads, held by pan-head screws.
const board = unwrap(cutAll(own(brick(BOARD.length, BOARD.width, BOARD.thick, 0, 0, zb)), pads.map(([x, y]) => own(cylinder(1.6, 4, { at: [x, y, zb - 1] }))))) as Shape;
const pan = M3_PAN;
const panEnd = -pan.headHeight - PAN_SCREW;
const panScrew = own(unwrap(cutAll(
own(lathe([[0, 0], [pan.head / 2 - 0.9, 0], [pan.head / 2, -0.9], [pan.head / 2, -pan.headHeight], [RM, -pan.headHeight], [RM, -pan.headHeight - 0.6], [RC, -pan.headHeight - 0.6], [RC, panEnd + 0.2], [RC - 0.2, panEnd], [0, panEnd]])),
[own(brick(3.4, 0.7, 1.4, 0, 0, -1.2)), own(brick(0.7, 3.4, 1.4, 0, 0, -1.2))],
)) as Shape);
const panThreaded = own(compound([panScrew, helixTooth(RC, RM, M3.pitch, panEnd + 0.2 + FLANK, -pan.headHeight - 0.6 - FLANK, -top - pan.headHeight)]) as Shape);
const dark: Shape[] = [];
const steel: Shape[] = [...lidScrews, ...pads.map(([x, y]) => own(translate(panThreaded, [x, y, top + pan.headHeight])))];
const brass: Shape[] = [];
const orange: Shape[] = [];
const white: Shape[] = [];
const part = (list: Shape[], s: Shape): void => { list.push(own(s)); };
// Antenna jack: a flange inside the wall, a threaded barrel through it, a washer and a nut outside.
// The barrel, the nut and the coupling nut of the whip are built on one axis, so that their threads are in mesh.
const y1 = ports.antenna;
part(brass, brick(2, 9, 9, face - wall - 1, y1, axisZ - 4.5));
part(brass, cylinder(2.6, face - wall - edge, { at: [face - wall - 2, y1, axisZ], axis: [-1, 0, 0] }));
part(brass, brick(6, 1.2, PORT_Z - 2.6, edge - 3, y1, top));
const barrel = 11; // thread length outside the inner wall face
const [sc, sm, sf] = [SMA.minor / 2, SMA.thread / 2, 0.42 * SMA.pitch];
const inNut = (from: number, to: number): Shape => helixTooth(sm + 0.1, sc + 0.1, SMA.pitch, from + sf, to - sf, SMA.pitch / 2, 24);
const nutHole = own(cylinder(sm + 0.1, 30, { at: [0, 0, -5] }));
const nut = own(unwrap(cut(own(hexagon(SMA.hex, 2.4, wall + 0.5)), nutHole)) as Shape);
const coupling = own(unwrap(cut(own(hexagon(SMA.hex, 7.5, wall + 3.4)), nutHole)) as Shape);
const threadedJack = own(compound([
own(lathe([[1.6, 0], [sc, 0], [sc, barrel], [1.6, barrel]])), helixTooth(sc, sm, SMA.pitch, 0.2 + sf, barrel - 0.2 - sf, 0, 24),
nut, inNut(wall + 0.5, wall + 2.9), coupling, inNut(wall + 3.4, barrel),
]) as Shape);
part(brass, translate(own(rotate(threadedJack, 90, { axis: [0, 1, 0] })), [face - wall, y1, axisZ]));
part(white, latheX([[0.7, 0], [1.6, 0], [1.6, barrel - 0.6], [0.7, barrel - 0.6]], [face - wall, y1, axisZ]));
part(steel, latheX([[SMA.thread / 2 + 0.15, 0], [5, 0], [5, 0.5], [SMA.thread / 2 + 0.15, 0.5]], [face, y1, axisZ]));
// Whip antenna: a coupling nut on the jack, an elbow, a knuckle and a quarter-wave whip.
const quarter = LIGHT_SPEED / band / 4; // millimetres
const plugAt = face + 3.4;
const elbowX = plugAt + 7.5;
part(dark, latheX([[0, 0], [4.6, 0], [4.6, 9], [0, 9]], [elbowX, y1, axisZ]));
const knuckleX = elbowX + 9 + 4.6;
part(dark, cylinder(4.6, 9.2, { at: [knuckleX, y1 - 4.6, axisZ], axis: [0, 1, 0] }));
const whip = own(lathe([[0, 4.6], [4.4, 4.6], [4.4, 16], [3.4, 22], [2.6, quarter - 2], [1.6, quarter], [0, quarter]]));
part(dark, rotate(own(translate(whip, [knuckleX, y1, axisZ])), whipAngle, { axis: [0, 1, 0], at: [knuckleX, y1, axisZ] }));
// Power jack: a body behind the wall with a socket for the plug and a centre pin.
const y2 = ports.power;
const jackBody = own(brick(14, 9, 10.4, face - wall - 7, y2, top));
part(dark, unwrap(cut(jackBody, own(cylinder(JACK.barrel / 2 + 0.4, 10, { at: [face - wall - 9, y2, axisZ], axis: [1, 0, 0] })))) as Shape);
part(brass, cylinder(JACK.pin / 2, 9, { at: [face - wall - 9, y2, axisZ], axis: [1, 0, 0] }));
// Data jack with six contacts: a body, an opening with a latch slot, and the contact wires.
const y3 = ports.data;
const dataBody = own(brick(18, 13.2, 11.6, face - wall - 9, y3, top));
part(dark, unwrap(cutAll(dataBody, [own(brick(14, 9.8, 6.8, face - wall - 6, y3, top + 1.8)), own(brick(14, 3.4, 9, face - wall - 6, y3, top + 1.8))])) as Shape);
for (let i = 0; i < 6; i++) part(brass, brick(9, 0.45, 0.45, face - wall - 8.5, y3 + (i - 2.5) * 1.02, top + 1.8));
// Shield can over the radio stage, with a grid of vent holes.
const canHoles = Array.from({ length: 24 }, (_, i) => own(cylinder(0.8, 2, { at: [4 + (i % 6) * 5, -5 + Math.floor(i / 6) * 5, top + 5] })));
part(white, unwrap(cutAll(own(unwrap(fillet(own(brick(32, 22, 6, 16.5, 2.5, top)), edgeFinder().inDirection('Z'), 1)) as Shape), canHoles)) as Shape);
// Controller chip with leads, crystal can, toroid choke, capacitors, regulator, switch bank, lamps and header.
part(dark, brick(10, 10, 1.4, -16, 6, top + 0.3));
for (const [dx, dy] of [[1, 0], [-1, 0], [0, 1], [0, -1]] as const) part(steel, brick(dx ? 1.2 : 8.4, dy ? 1.2 : 8.4, 0.5, -16 + dx * 5.6, 6 + dy * 5.6, top));
part(steel, unwrap(fillet(own(brick(11, 4.7, 3.5, -16, -6, top)), edgeFinder().inDirection('Z'), 2.2)) as Shape);
part(brass, torus(4.2, 1.9, { at: [-34, -12, top + 1.9] }));
part(brass, torus(3, 1.4, { at: [-17, -15, top + 1.4] }));
for (const [x, y, r, hh] of [[16, -16.5, 4, 11], [6, -17, 3.2, 8]] as const) {
part(dark, cylinder(r, hh - 0.4, { at: [x, y, top] }));
part(steel, cylinder(r - 0.6, 0.4, { at: [x, y, top + hh - 0.4] }));
}
part(dark, brick(6.5, 6.2, 2.3, -5, -16, top));
part(steel, brick(5.4, 4, 0.6, -5, -10.9, top));
part(orange, brick(10.5, 9.5, 4, -36, 12, top));
for (let i = 0; i < 4; i++) part(white, brick(1.2, 3, 1, -36 + (i - 1.5) * 2.54, 12 + (i % 2 ? 1.2 : -1.2), top + 4));
[orange, white].forEach((list, i) => part(list, brick(2, 1.3, 1.1, 44, 6 + i * 3.5, top)));
part(dark, brick(6 * 2.54, 2.54, 2.5, -31, -22, top));
for (let i = 0; i < 6; i++) part(brass, brick(0.64, 0.64, 6, -31 + (i - 2.5) * 2.54, -22, top + 2.5));
for (let i = 0; i < 14; i++) part(i % 3 ? brass : dark, brick(2, 1.25, 0.6, -6 + (i % 7) * 3.4 - (i > 6 ? 20 : 0), i > 6 ? 19 : -22, top));
return { base, lid, board, groups: [dark, steel, brass, orange, white].map((list) => compound(list) as Shape), grams, quarter };
}
const built = freeing(() => transmitter());
console.log('Quarter-wave whip: ' + built.quarter.toFixed(1) + ' mm. Aluminium box and lid: ' + built.grams.toFixed(0) + ' g from the kernel volumes.');
export default [
color(built.base, '#c3c9d1'),
color(built.lid, '#c3c9d1'),
color(built.board, '#12b5b0'),
...built.groups.map((g, i) => color(g, ['#48515c', '#e6e9ee', '#d3a956', '#ff5a1f', '#f5f2ea'][i]!)),
];Functions used
box compound cut cutAll cylinder edgeFinder extrude fillet fuseAll line loft measureVolume polygon revolve rotate torus translate unwrap wire color