Hardware Superintelligence: Flex, a laboratory for hardware agents
LabWired Engineering Series
Flex is the portable firmware execution provider in LabWired. It executes WebAssembly firmware against reusable models of sensors, actuators, communication buses and other hardware components.
An agent can change a sensor input, introduce a bus fault or vary a mechanical load, then inspect the resulting behavior. Each experiment selects a suitable model and execution engine for the engineering question.
Portable firmware execution
A thermostat test requires a temperature model, executable control logic and an observable fan command. Flex runs this experiment independently of the target processor’s instruction set.
The WebAssembly runtime connects to typed model ports on a shared virtual timeline. Declarative part descriptors reuse existing behavior primitives. The execution infrastructure records digital transitions, analog samples and protocol transactions.
Agents access Flex through the existing LabWired MCP run and verify tools. Interrupt latency, DMA transfers, startup sequences and silicon errata require target-specific execution.
A retained browser and CLI regression receipt records 73 passing scripts across 26 Flex fixtures. The comparisons include result text, digital and analog captures, I²C/SPI transfer records and console records. The receipt establishes coverage for the recorded fixtures and their pinned inputs. Arduino library compatibility and additional component models remain separate acceptance tasks.
Experiment 1: temperature, voltage and a digital alarm
Our NTC alarm fixture uses a 10 kΩ, B=3950 thermistor model and a 10 kΩ pull-down resistor. A portable Rust program reads the modeled voltage and switches an alarm at 2,000 mV.
| Temperature input | Model voltage | Alarm |
|---|---|---|
| 0 °C | 756 mV | Off |
| 25 °C | 1,650 mV | Off |
| 50 °C | 2,428 mV | On |
The program reads the sensor port, writes the alarm output and advances virtual time. The fixture compares the native and actual Chromium results, including the logic and analog captures. Scope: functional alarm behavior. Target ADC registers and physical thermistor tolerance remain unverified.
Inspect the original browser receipt.
Experiment 2: the same temperature, different behavior
A thermostat with hysteresis retains its previous output state inside the threshold band.
Our NTC fan controller fixture reuses the same analog source. The firmware switches the fan on at 2,000 mV and off at 1,800 mV.
| Scenario | Temperature steps | Fan output after each step |
|---|---|---|
| Heat cycle | 25 → 50 → 33 → 25 °C | Off → On → On → Off |
| Mild cycle | 25 → 33 → 25 °C | Off → Off → Off |
At 33 °C, the voltage is 1,932 mV in both cases. In one case the fan is on; in the other it is off. The controller retains its state in firmware memory between calls.
The recorded heat-cycle test passed 14 assertions and captured four digital edges. The mild-cycle negative control passed 11 assertions and captured no edges. The runner also checks that the heat-cycle expectations fail when applied to the mild input sequence.
The experiment verifies functional hysteresis. The 1 µs control period is a test parameter. Thermal dynamics and physical fan behavior are outside its scope.
Experiment 3: an aquarium controller with reusable part models
The generated-parts aquarium fixture combines a DS18B20 temperature probe and an active-low relay. Three output devices display the results: an I²C LCD1602, TM1637 seven-segment display and WS2812 ring.
The portable firmware reads the probe over 1-Wire, checks its scratchpad CRC, controls the heater and updates the displays. The models reuse catalog descriptors, GPIO behavior, display primitives and protocol-specific sinks.
| Water temperature | Heater state | LCD result |
|---|---|---|
| 18.5 °C | On | Water 18.50C / Heater ON |
| 25.25 °C | Off | Water 25.25C / Heater off |
The recorded Chromium/CLI runs passed 10 and 6 assertions, respectively. Their digital captures contain 1,040 and 1,048 edges. The assertions cover the modeled protocol, display and relay interactions. Electrical behavior of the 1-Wire bus and physical heater operation require separate tests.
A component descriptor specifies part identity, parameters, supported behavior and model coverage. New parts can reuse the same runtime primitives.
Reusable protocol models: Modbus RTU
The Modbus RTU lab uses target MCU execution with the same principle of reusable part models. An Arduino Uno polls two XY-MD02 sensors through a MAX485 transceiver. The sensor register map is represented as data; the transceiver and bus implement reusable behavior. An independent pymodbus decoder checks the observed frames. Requests with bad CRCs receive no response.
Verification covers byte-level protocol behavior. Electrical signal integrity, including ringing and termination effects, remains outside the model.
Run the Modbus example in LabWired · Read the engineering case study.
Power and mechanical behavior
An electrical connection requires voltage and current. A rotational connection requires torque and angular velocity. Geometric constraints define fit and permitted motion. Calculating forces requires a mechanical dynamics model.
LabWired already has examples in these domains. Their integration with Flex is an architectural objective.
The smart-basket carrier experiment uses a reduced-order power plant that represents the battery, converters and loads. Seven scenarios produced 420 waveform samples. During the modeled load burst, battery current rose from 0.60 A to 1.26 A. Voltage fell from 3.90 V to 3.82 V. The recorded assertions passed.
The results depend on the assumed loads, battery parameters and converter efficiencies. RF activity, converter switching and physical battery performance remain unverified.
The industrial BLDC lab exercises normal drive operation and driver-fault, overcurrent-flag and undervoltage-flag shutdown. Each fault must produce the expected serial markers and a low inverter-enable signal. All four recorded scenarios passed their model-level checks. The fault flags are digital stimuli. Physical current and supply transients, and inverter safety qualification, require separate evidence.
Run the BLDC example · Source and test evidence.
The quadrotor example pairs a verified single motor-control channel with a four-rotor mechanical assembly. Its recorded geometric checks cover 13 poses. Live motor-to-rotor coupling and aerodynamic flight verification remain open integration tasks.
The power, motor and mechanical experiments use their respective domain-specific engines. The shared device contract will connect those engines with Flex.
A composable component architecture
Consider a bearing. It may have a part number, a CAD solid, dimensional tolerances, load limits and a friction model. It may also have an independently calibrated lifetime model.
All representations should reference one component identity and the applicable sourced parameters.
Our architectural direction is one revisioned device graph with interchangeable representations and explicit interfaces. Flex supplies portable behavior; target MCU engines supply detailed firmware execution; circuit solvers evaluate electrical behavior; mechanical solvers evaluate motion and forces. KiCad and KernelCAD provide design checks and manufacturing artifacts.
The interfaces must define units, physical quantities, sign conventions, ownership, timing and model validity. The execution coordinator must handle different solver rates and feedback delays. System-level assertions must independently verify interactions between components.
Current development priorities are physically meaningful ports, interchangeable model representations, multi-rate coupling and revision-bound verification evidence. A general bearing model with validated wear and friction, broad Arduino library compatibility and automatic external-part onboarding remain open engineering tasks.
Engineering with hardware agents
Through LabWired MCP, an agent can submit a design for execution, inspect traces and test results, revise its implementation and repeat the experiment. Flex extends this workflow to portable firmware and reusable component behavior.
We measure progress through reproducible experiments, independently checked negative controls, explicit model coverage and comparison with physical hardware. Our next architectural acceptance target is a coupled motor and bearing model with measurable feedback and system-level assertions.