Geneva Wheel Drive

The Geneva drive of a 35 mm film projector: a driver with a roller pin and a locking cam indexes a four-slot star wheel, and the sprocket on the star shaft pulls the film down one frame for each turn. The film width, the perforation size and pitch, four perforations for each frame and the M4 thread of the plate screws are published figures. The turn angle moves the star wheel, the sprocket and the film by the Geneva law. The centre distance, the plate, its threaded standoffs and the part sections are a display model.
Code
This is the full program. The playground runs it in your browser without a change.
ts
import { box, cutAll, cylinder, extrude, fuseAll, line, loft, polygon, revolve, rotate, translate, unwrap, wire } from 'brepjs/quick';
import { color } from 'brepjs/playground';
// Geneva drive of a 35 mm film projector: each turn of the driver indexes the star wheel 90 degrees, and the
// sprocket on the star shaft pulls the film down by one frame. The film figures and the M4 thread are published.
// The centre distance, the plate, the standoffs and all part sections are a display model. Units are millimetres.
interface GenevaParams {
turn?: number; // degrees of the driver. 0 is the middle of an index, the pin is in the slot from -45 to 45.
film?: boolean; // false leaves the film out
}
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 (35 mm film, KS perforations)
const FILM = { width: 34.98, pitch: 4.75, perforation: [2.794, 1.981], perFrame: 4 }; // perforation: across, along
const FRAMES_PER_SECOND = 24;
const M4 = { major: 4, minor: 3.242, pitch: 0.7 }; // ISO metric coarse thread of the plate screws, right-hand
// ---- display model
const SLOTS = 4;
const TEETH = SLOTS * FILM.perFrame; // one index moves one frame
const CENTRES = 60; // star axis to driver axis
const CRANK = CENTRES / Math.SQRT2; // pin circle of the driver, and the radius of the star
const ROLLER = 4; // radius of the roller on the pin
const LOCK = 30; // radius of the locking cam
const SHAFT = 5;
const PLATE = 5;
const Z = { disc: 2, cam: 7, star: 7.5, top: 13.5, hub: 27, drum: 64 }; // levels above the plate
const FILM_THICK = 0.14;
const MARGIN = 2.01; // film edge to the perforation
const RUN = 55; // straight film at each side of the sprocket
const RAD = Math.PI / 180;
const STANDOFF = { flats: 7, length: 8 }; // hexagon pillar with an M4 thread, under each corner of the plate
const SCREW_LENGTH = 10; // under the head: through the plate and five millimetres into the standoff
const PLAY = 0.07; // radial clearance between the screw thread and the standoff thread
const ZZ: P3 = [0, 0, 1];
const turned = (s: Shape, deg: number): Shape => own(rotate(s, deg, { axis: ZZ }) as Shape);
const disc = (r: number, z0: number, z1: number, x = 0, y = 0): Shape => own(cylinder(r, z1 - z0, { at: [x, y, z0] }));
const prism = (pts: [number, number][], z0: number, z1: number): Shape => own(unwrap(extrude(own(unwrap(polygon(pts.map(([x, y]): P3 => [x, y, z0])))), z1 - z0))) as Shape;
// 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 pieces;
};
// The star angle for a driver angle: the Geneva law. The slot follows the pin for 90 degrees, then the star dwells.
function starAngle(turn: number): number {
const index = Math.round(turn / 360);
const a = (turn - 360 * index) * RAD;
const follow = Math.atan2(CRANK * Math.sin(a), CENTRES - CRANK * Math.cos(a)) / RAD;
return (360 / SLOTS) * index + (Math.abs(a) < Math.PI / SLOTS ? follow : Math.sign(a) * (180 / SLOTS));
}
function geneva({ turn = 18, film = true }: GenevaParams = {}) {
const star = starAngle(turn);
// ---- plate with two bearing bosses, on four threaded standoffs. A slotted M4 screw holds each one.
const corners: [number, number][] = [[116, -50], [116, 50], [112, 54], [-48, 54], [-52, 50], [-52, -50], [-48, -54], [112, -54]];
const spots: [number, number][] = [[108, 46], [-44, 46], [-44, -46], [108, -46]];
const plate = unwrap(cutAll(own(unwrap(fuseAll([prism(corners, -PLATE, 0), disc(11, 0, Z.disc), disc(11, 0, Z.disc, CENTRES)]))) as Shape, [
disc(SHAFT, -PLATE - 1, Z.disc + 1), disc(SHAFT, -PLATE - 1, Z.disc + 1, CENTRES),
...spots.map(([x, y]) => disc(2.25, -PLATE - 1, 1, x, y)),
])) as Shape;
// One joint on the Z axis: the screw thread is a helix, and the standoff thread is half a pitch away from it.
const screw = [
own(unwrap(cutAll(own(unwrap(fuseAll([disc(3.6, 0, 2.4), disc(M4.minor / 2, -SCREW_LENGTH, 0.5)]))) as Shape, [own(box(8, 0.9, 1.2, { at: [0, 0, 2.2] }))]))) as Shape,
...helixTooth(M4.minor / 2, M4.major / 2, M4.pitch, -SCREW_LENGTH + 0.35, -0.4, 0).map(own),
];
const hexagon = Array.from({ length: 6 }, (_, i): [number, number] => [(STANDOFF.flats / Math.sqrt(3)) * Math.cos(i * 60 * RAD), (STANDOFF.flats / Math.sqrt(3)) * Math.sin(i * 60 * RAD)]);
const standoff = [
own(unwrap(cutAll(prism(hexagon, -PLATE - STANDOFF.length, -PLATE), [disc(M4.major / 2 + PLAY, -PLATE - STANDOFF.length - 1, -PLATE + 1)]))) as Shape,
...helixTooth(M4.major / 2 + PLAY, M4.minor / 2 + PLAY, M4.pitch, -PLATE - STANDOFF.length + 0.4, -PLATE - 0.4, M4.pitch / 2).map(own),
];
// Each joint is turned as a whole, so the two threads stay in mesh.
const joints = (parts: Shape[]): Shape[] => spots.flatMap(([x, y], i) => parts.map((s) => translate(turned(s, 40 * i + 15), [x, y, 0]) as Shape));
// ---- driver in its own frame: the pin is on +X. A disc below the star, the locking cam, the pin and the shaft.
const cam = own(unwrap(cutAll(disc(LOCK, Z.cam, Z.top + 0.5), [disc(CRANK + 0.4, Z.cam, Z.top + 1, CENTRES)]))) as Shape; // relief for the star tips
const flat = own(box(4, 12, 8, { at: [SHAFT + 0.6, 0, 25] }));
const driverRaw = own(unwrap(cutAll(own(unwrap(fuseAll([
disc(CRANK + 6, Z.disc, Z.cam + 0.1), cam, disc(2.2, Z.cam, Z.top + 1, CRANK), disc(12, Z.top, Z.top + 3.5), disc(SHAFT, -PLATE, 27),
]))) as Shape, [flat, ...[60, 120, 180, 240, 300].map((a) => disc(6, 1, Z.cam + 1, 39 * Math.cos(a * RAD), 39 * Math.sin(a * RAD)))]))) as Shape;
const rollerRaw = own(unwrap(cutAll(disc(ROLLER, Z.cam + 0.1, Z.top, CRANK), [disc(2.2, Z.cam, Z.top + 1, CRANK)]))) as Shape;
const onDriver = (s: Shape): Shape => translate(turned(s, 180 - turn), [CENTRES, 0, 0]) as Shape;
// ---- star wheel: a slot at 0 degrees. Slots for the roller, and arcs that sit on the locking cam.
const inner = CENTRES - CRANK - ROLLER - 0.6; // closed end of a slot
const slot = own(unwrap(fuseAll([own(box(CRANK, 2 * ROLLER, 10, { at: [inner + CRANK / 2, 0, 10] })), disc(ROLLER, 5, 15, inner)]))) as Shape;
const arc = turned(disc(LOCK + 0.05, 5, 15, CENTRES), 180 / SLOTS);
const quarter = Array.from({ length: SLOTS }, (_, i) => (360 * i) / SLOTS);
const wheel = own(unwrap(cutAll(disc(CRANK, Z.star, Z.top), quarter.flatMap((a) => [turned(slot, a), turned(arc, a)])))) as Shape;
const starRaw = own(unwrap(fuseAll([wheel, disc(7, Z.disc, Z.star + 0.1), disc(8, Z.top - 0.1, Z.hub), disc(SHAFT, -PLATE, Z.drum + 3)]))) as Shape;
// ---- sprocket: a drum with a relief between two rows of teeth. The pitch circle carries TEETH perforations.
const pitchR = (TEETH * FILM.pitch) / (2 * Math.PI);
const drumR = pitchR - FILM_THICK / 2;
const mid = (Z.hub + 1 + Z.drum) / 2; // centre line of the film
const row = FILM.width / 2 - MARGIN - FILM.perforation[0] / 2; // tooth row from the centre line
const toothRing = (z: number): Shape => prism(Array.from({ length: TEETH }, (_, i) => i).flatMap((i): [number, number][] => {
const at = (r: number, a: number): [number, number] => [r * Math.cos(a), r * Math.sin(a)];
const c = (2 * Math.PI * i) / TEETH;
return [at(drumR - 0.4, c - 0.19), at(drumR - 0.2, c - 0.065), at(drumR + 1.4, c - 0.028), at(drumR + 1.4, c + 0.028), at(drumR - 0.2, c + 0.065), at(drumR - 0.4, c + 0.19)];
}), z - 0.7, z + 0.7);
const drumProfile = own(unwrap(polygon([[SHAFT, 0, Z.hub], [drumR, 0, Z.hub], [drumR, 0, mid - row + 2.5], [drumR - 1.5, 0, mid - row + 4], [drumR - 1.5, 0, mid + row - 4], [drumR, 0, mid + row - 2.5], [drumR, 0, Z.drum + 1], [SHAFT, 0, Z.drum + 1]])));
const toothed = own(unwrap(fuseAll([own(unwrap(revolve(drumProfile, { axis: ZZ }))) as Shape, toothRing(mid - row), toothRing(mid + row)]))) as Shape;
const sprocketRaw = own(unwrap(cutAll(toothed, [disc(SHAFT, Z.hub - 1, Z.drum + 2)]))) as Shape;
// ---- film: a quarter wrap on the near side of the sprocket and two straight runs. It moves with the sprocket.
const strip = (): Shape => {
const z0 = mid - FILM.width / 2;
const wrap = pitchR * (Math.PI / 4); // half the wrap, along the film
const bend = own(unwrap(revolve(own(unwrap(polygon([[drumR, 0, z0], [drumR + FILM_THICK, 0, z0], [drumR + FILM_THICK, 0, z0 + FILM.width], [drumR, 0, z0 + FILM.width]]))), { axis: ZZ, angle: Math.PI / 2 }))) as Shape;
const run = (from: number): Shape => own(box(FILM_THICK, RUN, FILM.width, { at: [drumR + FILM_THICK / 2, from + RUN / 2, mid] }));
const blank = own(unwrap(fuseAll([turned(bend, -45), turned(run(-RUN), -45), turned(run(0), 45)]))) as Shape;
const hole = (y: number, z: number): Shape => own(box(3, FILM.perforation[1], FILM.perforation[0], { at: [pitchR, y, z] }));
const shift = ((((pitchR * star * RAD) % FILM.pitch) + FILM.pitch) % FILM.pitch);
const holes: Shape[] = [];
for (let u = shift - FILM.pitch * Math.ceil((wrap + RUN) / FILM.pitch); u < wrap + RUN - 1.5; u += FILM.pitch) {
if (u < -wrap - RUN + 1.5) continue;
for (const z of [mid - row, mid + row]) {
if (Math.abs(u) <= wrap) holes.push(turned(hole(0, z), u / pitchR / RAD));
else holes.push(u > 0 ? turned(hole(u - wrap, z), 45) : turned(hole(u + wrap, z), -45));
}
}
return unwrap(cutAll(blank, holes)) as Shape;
};
return {
plate, screws: joints(screw), standoffs: joints(standoff), driver: onDriver(driverRaw), roller: onDriver(rollerRaw),
star: rotate(starRaw, star, { axis: ZZ }) as Shape, sprocket: rotate(sprocketRaw, star, { axis: ZZ }) as Shape,
film: film ? [strip()] : [], turn, angle: star,
};
}
const part = freeing(() => geneva());
console.log('Driver at ' + part.turn + ' deg: the star wheel is at ' + part.angle.toFixed(2) + ' deg. It moves for 90 of each 360 degrees.');
console.log('One index is ' + FILM.perFrame + ' of ' + TEETH + ' teeth: ' + (FILM.perFrame * FILM.pitch).toFixed(2) + ' mm of film, one frame. At ' + FRAMES_PER_SECOND + ' frames per second the driver turns at ' + FRAMES_PER_SECOND * 60 + ' rpm.');
export default [
color(part.plate, '#48515c'),
...part.screws.map((s) => color(s, '#f5f2ea')),
...part.standoffs.map((s) => color(s, '#c3c9d1')),
color(part.driver, '#12b5b0'),
color(part.roller, '#f5f2ea'),
color(part.star, '#d3a956'),
color(part.sprocket, '#c3c9d1'),
...part.film.map((s) => color(s, '#ff5a1f')),
];Functions used
box cutAll cylinder extrude fuseAll line loft polygon revolve rotate translate unwrap wire color