* PM_K-1 Stage 4 : balanced output driver -- antiphase + build-out into a cable
*
* The THAT1646 turns the single-ended mix into a balanced (differential) output:
* Out+ and Out- swing equal-and-opposite, so noise picked up equally on both wires
* cancels at the far end. It has a fixed +6 dB gain (differential = 2x input).
* We model it as two ideal sources (Out+ = +Vin, Out- = -Vin) and add the 47 ohm
* per-leg build-out resistors driving a 600 ohm load plus cable capacitance.
*
* Shows: audio band is dead flat, and the build-out + cable rolloff sits far above
* audio -- i.e. the build-out tames long/capacitive cables without dulling the sound.
* Run:  ngspice -b ../eda/sim/stage4_driver.cir

.title Stage4 balanced driver

Vin in 0 AC 1
Eop op 0 in 0 1        ; Out+ = +Vin
Eon on 0 0 in 1        ; Out- = -Vin   -> differential (op-on) = 2*Vin = +6 dB
Rbp op  hot  47        ; build-out, hot leg
Rbn on  cold 47        ; build-out, cold leg
Rl  hot cold 600       ; receiver / load
Cch hot 0 1n           ; ~cable capacitance per leg
Ccc cold 0 1n

.ac dec 20 10 10meg
.control
run
let vddb = db(v(hot) - v(cold))      ; differential magnitude in dB
meas ac d_1k    find vddb at=1k
meas ac d_20k   find vddb at=20k
meas ac d_1meg  find vddb at=1meg
meas ac ph_hot  find vp(hot)  at=1k
meas ac ph_cold find vp(cold) at=1k
echo
echo "  differential @1kHz : $&d_1k dB    @20kHz : $&d_20k dB   (flat across audio)"
echo "  hot phase: $&ph_hot rad ; cold phase: $&ph_cold rad  (~pi rad = 180 deg apart = balanced/antiphase)"
echo "  differential @1MHz : $&d_1meg dB  (build-out+cable rolloff stays above audio)"
wrdata ../eda/sim/plots/stage4_driver.data vddb
.endc
.end
