PhysBox Logo physbox.io
Sim-To-Real Technical Architecture

Hardware-In-The-Loop, 3D Printing,
Laser Cutting & CNC Workflows.

An in-depth technical exploration of how PhysBox: Volt bridges physical ESP32/CYD microcontrollers with WASM SPICE models, and how PhysBox: Mesh translates parametric WebAssembly geometry into 3D prints, laser-cut finger joints, CNC G-code toolpaths, and live WebSerial machine control.

Hardware-In-The-Loop (HIL) Integration

Connecting real ESP32 & Cheap Yellow Display (CYD) microcontrollers directly into the browser's WebAssembly SPICE solver at 460,800 baud with zero buffer starvation.

ESP32 CYD Hardware-In-The-Loop Laboratory Setup
Hardware-In-The-Loop (HIL): ESP32 CYD screen displaying real-time waveforms synchronized with PhysBox Volt circuit WASM solver.

Real-Time UART & WebSocket Bridge

In traditional EDA, firmware execution is either completely synthetic or disconnected from physical hardware — the schematic and the silicon never meet. PhysBox Volt introduces a dedicated Serial & WebSocket HIL Bridge running at up to 460,800 baud.

Physical microcontrollers read ADC inputs from external analog sensors, execute custom MicroPython or C++ firmware logic, and stream pin states back to the browser worker thread.

Lookahead Queue Buffer

Maintains a 40ms simulation step ahead of real time with a 240ms target depth to absorb serial jitter and eliminate pin starvation.

Sub-Millisecond Triggers

Derives sub-millisecond digital logic thresholds dynamically based on analog rail voltages computed in WASM.

Integrated Audio I/O

Route live physical microphone audio into input nodes and feed synthesized DAC output straight to system speakers.

Native Batching (`hil_batch`)

MicroPython and C++ native firmware routines package multiple I/O states per packet for maximum baud-rate efficiency.

MicroPython HIL Firmware Routine (`hil_bridge.py`)
import machine, time, select, sys

# Initialize UART at high-speed 460800 baud for PhysBox Volt HIL Bridge
uart = machine.UART(1, baudrate=460800, tx=22, rx=23)
adc = machine.ADC(machine.Pin(34))
dac = machine.DAC(machine.Pin(25))

print("[HIL] Connected to PhysBox Volt SPICE Engine")

while True:
    if select.select([sys.stdin], [], [], 0)[0]:
        cmd = sys.stdin.readline().strip()
        if cmd.startswith("DAC:"):
            val = int(cmd.split(":")[1])
            dac.write(val) # Update physical DAC output from WASM circuit model

    raw_val = adc.read()
    # Batch telemetry: ADC raw value + timestamp tick
    uart.write(f"ADC:{raw_val}:{time.ticks_us()}\n")
    time.sleep_us(500)

Laser Cutting & CNC Milling Pipeline

Unfold 3D assemblies into 2D sheet space, auto-generate interlocking finger joints with kerf compensation, compute CNC dogbone corner reliefs, generate GRBL G-code, and stream live over WebSerial.

Laser Cutting & CNC Toolpath Workflow
Laser Cut & CNC Pipeline: Interlocking wooden panel box joints, SVG sheet nesting, and live G-code streaming directly from PhysBox Mesh.

Sheet Unfolding, Finger Joints & WebSerial

PhysBox Mesh isn't restricted to additive 3D printing. It features a complete subtractive manufacturing engine (`laserCutExporter.ts` and `gcodeExporter.ts`) designed for Laser Cutters (LightBurn, Glowforge, LaserGRBL) and CNC Routers (GRBL, Marlin, ShopBot).

The engine automatically unfolds 3D panel meshes onto 2D sheet stock using maximal-rectangle packing algorithms, generates structural tab-and-slot joints, applies kerf/clearance adjustments, and streams G-code straight to machine hardware over WebSerial.

Procedural Interlocking Finger Joints

Generates tight press-fit tab-and-slot joints with kerf compensation, clearance tuning, and custom tab width across panel edges.

CNC Dogbone & T-Bone Corner Relief

Calculates corner overcuts so spinning round CNC end mills can seat square 90° mating tabs without manual CAD edits.

3D Contour Layer Slicing

Slices arbitrary 3D volumetric meshes into stacked 2D sheet contours (plywood/acrylic) for layered organic physical builds.

WebSerial Live Machine Control

Frame job boundaries and stream G-code directly to physical GRBL/Marlin CNC routers and laser cutters straight from the browser.

Generated GRBL G-Code & WebSerial Output (`laser_panel_cut.gcode`)
; Generated by PhysBox Mesh Laser & CNC Engine
; Machine Mode: LASER CUTTER | Stock Thickness: 3.00mm | Kerf: 0.15mm
; Interlocking Finger Joint Mode: TAB_SLOT | Corner Relief: DOGBONE
G90 (Absolute Distance Mode)
G21 (Metric Units)
M3 S1000 (Laser Power Active @ 100%)
G0 X0.00 Y0.00 Z5.00 F1500 (Safe Retract Move)

; Panel 1: Top Enclosure Plate [Finger Joint Contour]
G0 X12.50 Y10.00
G1 Z0.00 F800 (Plunge to Cut Depth)
G1 X87.50 Y10.00 F1200 (Cut Finger Tab Edge A)
G1 X87.50 Y14.50 (Tab Slot Overcut with Kerf Comp)
G1 X100.00 Y14.50
G1 X100.00 Y85.50
...
M5 (Laser Off)
G0 Z10.00 (Job Complete - WebSerial Stream Ended)

Tested & Supported Hardware Matrix

Verified microcontrollers, CNC routers, laser cutters, and browser controllers compatible out-of-the-box with PhysBox WebSerial streaming.

Hardware Category Supported Models / Controllers Baud Rate / Protocol PhysBox Target App
HIL Microcontrollers ESP32, ESP32-S3, Cheap Yellow Display (CYD), Arduino Uno / Nano, Raspberry Pi Pico 460,800 baud (WebSerial packed binary arrays) PhysBox Volt
CNC & Laser Controllers GRBL 1.1, FluidNC, grblHAL, CNC Shield v3, LaserGRBL boards 115,200 baud (WebSerial G-code streaming) PhysBox Etch
3D Printers (Slicers) PrusaSlicer, Bambu Studio, Cura, OrcaSlicer 1-Click Z-Up Binary STL Export PhysBox Mesh
Supported Browsers Google Chrome, Microsoft Edge, Opera, Brave (Chromium engine) WebSerial & WebAssembly Native APIs All PhysBox Apps

AI Agents Driving Fabrication & HIL

Through 81 Model Context Protocol (MCP) tools, AI agents like Claude Code and Gemini Antigravity inspect physical tolerances, generate CAD models, unfold 2D sheet panels, and test circuit telemetry autonomously.

1

Validate OpenSCAD

Agents invoke physics_validate_scad to check vertex counts, watertight geometry, and physical bounding boxes.

2

Simulate Kinematics

Agents call physics_build_scene and physics_run_headless to run MuJoCo rollouts and check joint binding.

3

Unfold & Nest 2D Panels

Mesh unfolds the model into finger-jointed, kerf-compensated 2D panels, and agents hand the sheet to Etch with etch_set_svg to lay it out for cutting.

4

Stream G-Code / HIL

Agents generate G-code via etch_generate_gcode and verify microsecond circuit responses via circuit_get_waveforms.