* PM_K-1 Stage 1 : input protection -- a +48V phantom-power step at the jack
*
* "Phantom power" is +48V DC that mixers put on their MIC inputs. If it ever reaches
* our input (miswire, wrong cable, our OUT plugged into a phantom'd input), a bare
* op-amp input would die. Our protection makes it a non-event:
*   - a series DC-BLOCKING film cap passes audio (AC) but blocks the +48V (DC),
*   - a series resistor + clamp diodes to the +/-15V rails survive the turn-on EDGE
*     (the cap passes the fast step before it charges).
*
* We hit the input with a +48V step at t=1ms and watch the OP-AMP INPUT node.
*
* Run:  ngspice -b ../eda/sim/stage1_phantom.cir

.title Stage1 phantom protection

Vin in 0 PWL(0 0 1m 0 1.001m 48 5 48)   ; +48V appears at t=1ms, stays

C1  in a 1u            ; DC-blocking film cap (audio passes, DC blocked)
Rs  a  n 1k            ; series current limit
Rb  n  0 1meg          ; bias / input impedance (audio high-pass corner ~0.16 Hz)

.model Dclamp D(Is=1e-14 N=1 Rs=10)
Dp n  vp Dclamp        ; clamp to +15
Dn vn n  Dclamp        ; clamp to -15
Vp vp 0 15
Vn vn 0 -15

.tran 2m 5
.control
run
meas tran vn_peak  max v(n) from=1m to=5
meas tran vn_final find v(n) at=4.9
echo
echo "  op-amp input PEAK during the +48V step : $&vn_peak V   (clamped near a +/-15 rail)"
echo "  op-amp input STEADY-STATE              : $&vn_final V   (DC blocked by the cap)"
echo "  -> +48V at the jack becomes a clamped blip that decays to ~0. Nothing is harmed;"
echo "     a wrong patch only ever sounds wrong. (Audio passes -- the high-pass is ~0.16 Hz.)"
wrdata ../eda/sim/plots/stage1_phantom.data v(n)
.endc
.end
