Entry.log

Published

WithDiode: Build, Program, and Simulate Hardware in the Browser

WithDiode provides a fast path from idea to working circuit without wrestling with toolchains, bench wiring, or messy breadboards. This article explains what WithDiode does, how its pieces fit together, and what it means for hobbyists, educators, and developers who want reproducible, programmatic hardware experiments.

What the tool does at a glance

  • Visual circuit authoring: drag-and-drop components (resistors, transistors, LEDs, timers, switches, MCU footprints), connect wires, and build circuits visually on a schematic-like canvas.
  • Interactive simulation: run the circuit in the browser and inspect live signals, voltages, and currents. Toggle switches, change component values, and watch the simulation update in real time.
  • Code-driven devices: attach programmable components (microcontroller simulation or scriptable virtual devices) and write firmware-like code that interacts with the simulated hardware.
  • Export and reproduce: save projects, export circuit descriptions and netlists, and share links so collaborators can reproduce your setup.

Typical workflows

  • Rapid prototyping: sketch a circuit, iterate on component values, and verify behavior before building a physical prototype.
  • Teaching and labs: instructors present a circuit and students experiment without hardware logistics.
  • Algorithm + hardware co-design: test control code against the simulated circuit before flashing a real MCU.
  • Troubleshooting: reproduce a failing circuit configuration in the simulator before inspecting the physical board.

Core technical components

Component models

Each part (resistor, capacitor, transistor, op-amp, LED, switch, MCU peripheral) is represented by a runtime model that exposes electrical behavior. Passive parts use linear circuit equations; reactive parts model stateful dynamics (capacitor charge, inductor flux). More complex or programmable parts wrap behavioral models that trade fidelity for interactivity.

Netlist and solver

The editor compiles the drawn circuit into a netlist (nodes, elements, terminals). A numerical solver computes node voltages and branch currents. Typical techniques include:

  • Modified Nodal Analysis (MNA) for linear and piecewise-linear circuits.
  • Time-domain integration (implicit methods) for reactive and non-linear components.
  • Hybrid/event-driven methods for digital switches and discrete logic.

For interactivity the solver uses adaptive time-stepping and pragmatic device models rather than full transistor-level SPICE.

Real-time UI and instrumentation

The simulator streams sampled values to a waveform viewer, numeric displays, and animated components. Virtual oscilloscopes and multimeters probe nodes and branches without disturbing the simulation.

Programmable devices and firmware simulation

WithDiode exposes either a lightweight MCU emulator (cycle-approximate) or a tick-based scripting API so code can interact with pins. This enables workflows such as: read ADC, run a control loop, and drive a MOSFET, all inside the simulator.

Persistence and sharing

Projects serialize to a reproducible format (JSON or project archive). Shareable links embed the project data or reference a server-hosted project ID so others can open the exact same circuit.

Representative example: 555-based LED flasher

  1. Drop a 555 timer, capacitor, resistor network, and LED on the canvas.
  2. Wire pins, set R/C values, and press Run.
  3. Probe the 555 output with the waveform viewer to measure frequency and duty cycle.
  4. Tweak resistor values interactively to tune the flash rate.

Performance and engineering trade-offs

Interactive simulators favor responsiveness over transistor-level fidelity. Key trade-offs:

  • Model fidelity vs. interactivity: simplified models and coarser timesteps enable real-time interaction but are not substitutes for SPICE when analog accuracy matters.
  • Resource constraints: large circuits or high-frequency dynamics can strain in-browser solvers; offloading heavy runs to a remote service is a common mitigation.
  • MCU fidelity: full instruction-accurate emulation is expensive; many environments use higher-level behavioral models for peripherals.

Integration points and extensions

  • Export to SPICE/LTspice for high-fidelity verification.
  • Hardware-in-the-loop (HIL) to forward simulated pin states to a real MCU.
  • PCB export and BOM generation for moving from simulation to fabrication.
  • Marketplace for shared models and tutorials to grow the component library.

Implications and conclusion

WithDiode makes hardware prototyping accessible: design, simulate, and iterate in a single, shareable browser flow. For hobbyists and educators it lowers the barrier to experimentation. For engineers it shortens the feedback loop between firmware and hardware design. The main practical guideline is to treat the simulator as an exploration and prototyping tool, then use higher-fidelity SPICE or hardware-in-the-loop late in the validation pipeline.