Modern Experimental Techniques – Physics

Workshop 3 β€” Firmware and basic mechanical design (PCB housing) Β· Fri 2 Oct 2026 Β· 14:20–16:20 Β· R311, IAMS

Workshop 3 β€” Firmware and basic mechanical design (PCB housing)

The slides: Workshop 3: getting things made. Nobody learns a CAD program (computer-aided design: the program a part is drawn in) today: Claude Code writes the geometry; you specify, look, check the numbers, slice and decide.

Hard cutoff: Friday 9 October, 2 pm. The final housing files for 3D printing / laser cutting must be in for manufacturing then.

Prerequisite: OpenSCAD 2021.01 and Bambu Studio installed and opened once (setup step 11). Bring your laptop and your dev board.

Detailed plan (follows the workshop outline above)

The boards are on order (placed 28 September, back around 16 October), so everything on the firmware side runs in sim mode on the dev board (a build in which the firmware β€” the program on the microcontroller β€” fakes its hardware, so the app works on the bare board). You start your instrument's firmware with a driver and its app panel, wire one alarm rule, and design the housing.

Firmware and app β€” a driver and its panel

The block-driver interface

Every driver is a folder firmware/src/blocks/<section>_<name>/ implementing name() / begin() / loop() / handle(cmd, reply) / status(out). You start from blocks/template/.

The protocol

WebSocket (a live two-way connection between the phone page and the board) messages {block, cmd, args} in and {block, status} out; one panel module per driver in host/pwa/panels/<section>.js; instrument.py (a Python program on your PC) mirrors the same commands in Python.

Sim mode

The SIM flag fakes the hardware so the whole app runs on a bare dev board β€” you work ahead of the boards and swap the flag off when they arrive.

One alarm rule per panel

A driver's status β†’ the base alarm engine β†’ a module output + notification: A "AI1 above a threshold" or "no free induction decay seen" Β· B "output clipped" or "TRIG edge seen" Β· C "opto count jumped" or "a module output left on".

E11: driver + panel in sim. Choose the part of the board your instrument needs first β€” the section you worked on in Workshop 2 is a natural start, not an obligation. /tutor L3: copy the template to blocks/<section>_<name>/; fill in the section's commands (A read_all, set_range, capture Β· B set_dc, sine, pulse, dio Β· C module, module_all, opto_reset); make the SIM branch return plausible values; add the panel and one alarm rule; flash (write the firmware onto the board over USB); see the panel react on the phone; open the pull request (a request to merge your changes into the shared project; someone reviews it first). The tutor generates the skeleton; you name the commands, write the SIM values, and explain one message round-trip before flashing. Sections that talk to each other are paired (B ↔ A for a waveform measured on an input, B ↔ C for a pulse that switches a module output). Done when the panel controls the section in sim and the pull request is open.

Housing β€” part of Project 3

Tips for printed and cut parts

Nuts in pockets are the fastening: an M3 nut slides into a 5.8 mm hexagonal pocket, 2.5 mm deep, and the screw pulls it tight. Walls 2 mm; holes +0.3 mm (printed holes come out small); layers are the weak direction, so let the load run along them; 45Β° is the steepest overhang that prints without support. Print a test coupon first: it answers the fit for your printer. The PCB front panel is the face of the instrument, so the front cover is a plate with holes where the panel's parts are.

Your own design

You write the specification yourself, from the housing brief: what the housing must hold, the printing rules, the files to hand in, and the two board models. Those models, hardware/release/class-board.stl and front-panel.stl (STEP versions beside them), were exported from the final KiCad boards with kicad-cli, keeping only the connectors, LEDs and modules, so every dimension comes from the boards and none from a ruler. Ask Claude to ask you its questions before it writes code. Start by opening each board on its own in OpenSCAD, one import() line at a time, and looking at it; there is no example housing to copy, because the design is yours.

Output

housing.scad, base.stl, cover.stl, coupon.stl (STL: the 3D-print file), cover.dxf (DXF: the laser-cutting drawing) and a screenshot, in docs/students/<name>/housing/, by the cutoff. The institute prints and cuts them.

E12: your housing. On the shared screen, and in your own Claude Code session with OpenSCAD beside it: write your specification from the brief, answer Claude's questions, let it write housing.scad, look at it and check the numbers in the console, fix it and make it yours, export the parts and slice them in Bambu Studio, add the test coupon, commit from Source Control. A design in another CAD program you already use is welcome too, if it fits the boards and meets the deadline. Done when the files are in your folder.

From here β€” this was the last workshop: E11–E12

The housing files by Friday 9 October, 2 pm; the driver + panel pull request; then your instrument: its firmware, its app and its project website; around 16 October, collect the boards and housings and assemble; 26–30 October, present. Improve your apps, build and have fun. Help: the tutor, then e-mail s.p.bennetts@g.iams.sinica.edu.tw.

Presentation and demonstration

The demonstration is yours to shape: your instrument, your app and your website at work, in the order that shows them best; ask the tutor if you want help planning it.

Materials