velxio/test/test_circuit
David Montero Crespo df37fdf6a4 feat: add 40 circuit examples + matching SPICE tests
Adds frontend/src/data/examples-circuits.ts with 40 new examples organized
into 6 categories, each demonstrating a specific analog/digital/electromech
concept that the SPICE engine can simulate end-to-end:

PASSIVE / ANALOG (10):
  voltage-divider, rc-low-pass-filter, wheatstone-bridge,
  ntc-temperature, led-current-limiting, parallel-resistors,
  pot-adc-reader, photoresistor-light, multi-led-bar,
  capacitor-charge-curve

TRANSISTOR / SEMICONDUCTOR (8):
  npn-led-switch, pnp-high-side-switch, mosfet-pwm-led,
  diode-rectifier, zener-regulator, schottky-reverse-protection,
  bjt-common-emitter, darlington-high-current

OP-AMP (5):
  opamp-inverting, opamp-voltage-follower, opamp-comparator,
  opamp-difference, opamp-schmitt-trigger

LOGIC GATES (6):
  and-gate-alarm, xor-toggle-detector, nand-sr-latch,
  full-adder, binary-counter-leds, logic-probe

ELECTROMECHANICAL (4):
  relay-led-switch, optocoupler-signal,
  l293d-motor-control, l293d-speed-pwm

POWER / REGULATOR (3):
  power-supply-7805, lm317-adjustable-psu, battery-voltage-monitor

BOARD-SPECIFIC (4):
  esp32-dual-adc, mega-multi-led, nano-sensor-station,
  esp32-pwm-led-rgb (uses ESP32 LEDC peripheral)

The new examples are appended to exampleProjects[] in examples.ts so the
existing gallery and category filters pick them up automatically.

test/test_circuit/test/spice_examples.test.js validates each example's
analog topology in ngspice — 45 individual assertions covering all 40
examples (plus extra cases for NTC/Zener sweeps and L293D direction).

Sandbox tally: 164 -> 209 tests, 7.9s runtime, all green.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 00:52:51 -03:00
..
autosearch feat: expand SPICE component catalog (fases 9 + 10) 2026-04-15 22:41:26 -03:00
fixtures feat: electrical simulation via ngspice-WASM (eecircuit-engine) 2026-04-15 12:11:54 +00:00
plan feat: expand SPICE component catalog (fases 9 + 10) 2026-04-15 22:41:26 -03:00
src feat: electrical simulation via ngspice-WASM (eecircuit-engine) 2026-04-15 12:11:54 +00:00
test feat: add 40 circuit examples + matching SPICE tests 2026-04-16 00:52:51 -03:00
README.md feat: electrical simulation via ngspice-WASM (eecircuit-engine) 2026-04-15 12:11:54 +00:00
package-lock.json feat: electrical simulation via ngspice-WASM (eecircuit-engine) 2026-04-15 12:11:54 +00:00
package.json feat: electrical simulation via ngspice-WASM (eecircuit-engine) 2026-04-15 12:11:54 +00:00

README.md

test_circuit — sandbox de emulación de circuitos

Sandbox para validar la emulación de circuitos analógicos + digitales + Arduino en JS puro antes de tocar Velxio.

Estructura

test_circuit/
├── plan/                   # Documentos de planificación (fases 07)
├── src/
│   ├── solver/             # MNA hand-rolled (legacy, baseline)
│   ├── components/         # Modelos JS (legacy, baseline)
│   ├── avr/                # AVRHarness (avr8js estilo Velxio)
│   └── spice/              # SpiceEngine (ngspice-WASM) + AVRSpiceBridge
├── test/                   # Vitest tests
│   ├── passive.test.js               # baseline JS
│   ├── transient_rc.test.js          # baseline JS
│   ├── diodes.test.js                # baseline JS
│   ├── avr_blink.test.js             # avr8js con blink.hex
│   ├── e2e_pot_pwm_led.test.js       # baseline JS + avr8js
│   ├── e2e_thermistor.test.js        # baseline JS + avr8js
│   ├── ngspice_smoke.test.js         # ngspice boot
│   ├── spice_passive.test.js         # ngspice DC
│   ├── spice_transient.test.js       # ngspice .tran
│   ├── spice_ac.test.js              # ngspice .ac Bode
│   ├── spice_active.test.js          # diodo, BJT, MOSFET, op-amp
│   ├── spice_digital.test.js         # lógica behavioral
│   ├── spice_555_astable.test.js     # oscilador relajación
│   └── spice_avr_mixed.test.js       # co-simulación avr8js ↔ ngspice
├── fixtures/               # .hex pre-compilados / ensamblados a mano
├── autosearch/             # Hallazgos, métricas, propuestas
└── package.json

Correr las pruebas

cd test/test_circuit
npm install
npm test

Por fase:

npm run test:phase3   # pasivos
npm run test:phase4   # activos (diodos)
npm run test:avr      # integración avr8js
npm run test:e2e      # end-to-end Arduino + circuito

Alcance

Ver plan/phase_0_scope.md.