carrier.cir · 38 lines
Autonomous 1 kHz, 2 Vpp triangle carrier for heater PWM
* DC-powered behavioral Schmitt comparator + constant-current integrator.
* No PULSE, PWL, SIN, time expressions, or externally supplied clock.
*
* Comparator feedback beta = 10k/(15k+10k) = 0.4.
* With square = 0 or 5 V, hysteresis thresholds are 1.5 and 3.5 V.
* Integrator current = +/-2.5 V / 62.5k = +/-40 uA.
* C = 10 nF: slope = +/-4000 V/s, half-period = 2/4000 = 0.5 ms.
* Thus f = 1 kHz, carrier = 2 Vpp, centered on 2.5 V.
VCC vcc 0 DC 5
VREF ref 0 DC 2.5
* Finite-gain, rail-limited ideal comparator; positive feedback makes it
* a Schmitt trigger. Its output controls the charging current below.
BCOMP square 0 V={0.5*v(vcc)*(1+tanh(10000*(v(hyst)-v(carrier))))}
RFB square hyst 15k
RREF hyst ref 10k
* Positive current charges the carrier capacitor when square is high.
BCHARGE 0 carrier I={(v(square)-v(ref))/62.5k}
CTIMING carrier 0 10n IC=1.5
* Initial capacitor charge selects a startup state, not a timing source.
.ic V(carrier)=1.5 V(square)=5 V(hyst)=3.5
.options reltol=1e-5 abstol=1e-10 vntol=1e-6
.control
set noaskquit
set wr_singlescale
set wr_vecnames
save v(carrier) v(square)
tran 1u 20m 0 1u uic
* Two columns: time (seconds), carrier voltage (volts).
wrdata carrier.txt v(carrier)
.endc
.endTriangle-wave carrier for a milk frother: GPT-6.1 Sol
modelopenai/gpt-6.1-soltaskspice-frother-triangle@v1, checks c1, harness h1date2026-10-02rounds1 of 8 allowed, 12 minutes on the clockcost$0.0288thinkingmediumtokens31,321 in, 1,749 out, of which 563 reasoningtime1 min 4 s
DC supplies onlydecided by a number, from the filepass
1 kHzdecided by a number, from the filepass
2 V peak to peakdecided by a number, from the filepass
Straight, even rampsdecided by a number, from the filepass
There is no post about this one, since only some results need one, so the picture, the source and the scoring are here instead.
run 2 · 1r · $0.0306
run 3 · 1r · $0.0289same prompt, other modelsall 6 runs on Triangle-wave carrier for a milk frother →
A milk frother's heater is driven by PWM, and the PWM needs a 1 kHz triangle-wave carrier of 2 V peak to peak. Build that oscillator in ngspice using only DC supplies, so the oscillation comes from the circuit itself, and simulate 20 ms. In a .control block, save the carrier voltage with wrdata to a .txt file so it can be plotted.Frozen at v1. This model got this and nothing else.
The netlist, re-run in ngspice offline and the written carrier read back. A triangle comes from integrating a square wave, so a PULSE into an RC, whose ramps curve, fails, and so does any source that is told the time. How it is scored, and this run's files on GitHub.