Tennis Programming - Gremlin SPICE reconstruction 0.3.1
* Basis: BNL EH1-900-1-3 A (1958), computing/relay diagram.
* See docs/model.json and docs/corrections.json for model boundaries.
* No host code changes a ball coordinate, capacitor charge or inductor current.
* Raw U2 voltage is zero at the net top; displayed height is V(y)+20 V.
* Electronic display sheet EH1-900-2-3 A is NOT represented by this plant.

.param RI=1meg CI=1u RFB=10meg CHF=10n RPOT=50k
.param NH=20 COURT=75 SERVE=62 G=60
.param A0=10k FP=1 VRAIL=110 ROUT=100
.param RCOIL=10k LCOIL=10 IPICK=50u IHYS=15u
.func hi(a) {(1+tanh((a-50)/2))/2}
.func positive(a) {(1+tanh(a/.2))/2}
.global logic railp railm
Vlogic logic 0 100
Vp railp 0 {VRAIL}
Vm railm 0 {-VRAIL}
Vgravity grav 0 {-G}
VknobL knob_l 0 .65
VknobR knob_r 0 .65
VbuttonL button_l_input 0 0
VbuttonR button_r_input 0 0
Vreset reset_input 0 0
RbuttonL button_l_input button_l 1k
CbuttonL button_l 0 100n
RbuttonR button_r_input button_r 1k
CbuttonR button_r 0 100n
Rreset reset_input reset 1k
Creset reset 0 100n

* Finite-gain, dominant-pole amplifier macro-model. Explicit engineering
* substitute: the transistor/tube implementation of a Donner 30 is unresolved.
.subckt OA s out
Berror target 0 V=min(max(-{A0}*V(s),-10000),10000)
Rpole target pole {1/(6.283185307179586*FP*1u)}
Cpole pole 0 1u
Dpositive pole railp DCLAMP
Dnegative railm pole DCLAMP
Ebuffer buffer 0 pole 0 1
Rout buffer out {ROUT}
.ends OA
.model DCLAMP D(Is=1e-12 N=1 Rs=1)
.model DGE D(Is=1u N=1.5 Rs=20)
.subckt CONTACT a b control
Bcontact a b I=V(a,b)*(1p+(.02-1p)*(1+tanh((V(control)-55)/.8))/2)
.ends CONTACT

* Sensitive relay: rectifier, measured-current R-L coil, flyback path,
* continuous hysteretic pickup and RC armature surrogate. R/L/thresholds are unmeasured.
.subckt RELAY drive contact params: I0=0
Ddrive drive cp DGE
Dflyback 0 cp DGE
Rcoil cp cn {RCOIL}
Lcoil cn sense {LCOIL} ic={I0}
Vsense sense 0 0
Bpickup target 0 V=100*(1+tanh((I(Vsense)-{IPICK}+{IHYS}*(V(contact)/50-1))/5u))/2
Rarmature target contact 1k
Rrelease contact 0 2k
Carmature contact 0 1u
.ends RELAY

* Bistable contact macro-model. Reset has priority. Charge on Q is retained through
* a finite-conductance feedback contact; all memory is capacitor charge.
.subckt LATCH set reset q
Bkeep logic q I=V(logic,q)*(1p+.001*hi(V(q)))
Bset logic q I=V(logic,q)*(1p+.001*hi(V(set))*(1-hi(V(reset))))
Breset q 0 I=V(q)*(1p+.1*hi(V(reset)))
Rpull q 0 100k
Cmemory q 0 1u
.ends LATCH

* RY1B..J: four 1 uF controller banks. A capacitor is either charging through
* its 50 kOhm path, or connected to the amplifier feedback by two contacts.
.subckt BANK sum out ref active p n
Vsense cp p 0
Cbank cp n {CI}
XfeedbackP p sum active CONTACT
XfeedbackN n out active CONTACT
Bnot off 0 V=100-V(active)
XchargeP p charging off CONTACT
Rcharge charging ref {RPOT}
XchargeN n 0 off CONTACT
.ends BANK

* Linked control transfers: explicit adjustable reconstruction calibration.
BleftX ref_lx 0 V=100-50*V(knob_l)
BleftY ref_ly 0 V=20+85*V(knob_l)
BrightX ref_rx 0 V=-(100-50*V(knob_r))
BrightY ref_ry 0 V=20+85*V(knob_r)
BselL active_l 0 V=100*hi(V(run_contact))*(1-hi(V(bank)))
BselR active_r 0 V=100*hi(V(run_contact))*hi(V(bank))
Xly sy u1 ref_ly active_l lyp lyn BANK
Xry sy u1 ref_ry active_r ryp ryn BANK
Xlx sx u6 ref_lx active_l lxp lxn BANK
Xrx sx u6 ref_rx active_r rxp rxn BANK

* U1/U2 and U6/U7: archival 1 megOhm / 1 uF computing chain, with the
* 10 megOhm || .01 uF high-frequency feedback branches retained.
Rg grav sy {RI}
Ryfb sy u1 {RFB}
Cyhf sy u1 {CHF}
XU1 sy u1 OA
Rypos u1 py {RI}
Cypos py y {CI}
XU2 py y OA
Rxfb sx u6 {RFB}
Cxhf sx u6 {CHF}
XU6 sx u6 OA
Rxpos u6 px {RI}
Cxpos px x {CI}
XU7 px x OA

* RY3A/B: 10 uF ground holding network. In sample mode A=0, B=U1 through
* 10 kOhm. In bounce mode A=U1, B=sum. Charge redistribution performs bounce.
Cground ga gb 10u
Rgsample u1 gs 10k
BgroundNot ground_not 0 V=100-V(ground_contact)
XgroundA0 ga 0 ground_not CONTACT
XgroundB0 gb gs ground_not CONTACT
XgroundA1 ga u1 ground_contact CONTACT
XgroundB1 gb sy ground_contact CONTACT

* RY4A/B: 5 uF net holding capacitor, likewise switched with its polarity
* reversed into the horizontal feedback path. No restitution multiplier.
Cnet na nb 5u
BnetNot net_not 0 V=100-V(net_contact)
XnetA0 na u6 net_not CONTACT
XnetB0 nb 0 net_not CONTACT
XnetA1 na sx net_contact CONTACT
XnetB1 nb u6 net_contact CONTACT

* U3 - unity inverter below the net plane. U4 - adjustable ground detector.
Ru3 y s3 1meg
Rf3 s3 u3 1meg
XU3 s3 u3 OA
Vheight h_ref 0 {NH}
Ru4a y s4 100k
Ru4b h_ref s4 100k
Rf4 s4 u4 1meg
XU4 s4 u4 OA
Xground u4 ground_contact RELAY

* U8/U9: symmetric end references. Comparator macro-model polarity is an
* explicit working interpretation of the archival diode OR, correction C02.
BendR end_r 0 V=min(max(10000*(V(x)-{COURT}),-100),100)
BendL end_l 0 V=min(max(10000*(-V(x)-{COURT}),-100),100)
DendR end_r end_drive DGE
DendL end_l end_drive DGE
Rend end_drive 0 1meg
Xend end_drive end_contact RELAY

* U10/RY5 centre detector. The symmetric RC edge gate corrects the incomplete
* one-sided net gating of the surviving drawing (C03); no position is clamped.
Bcentre centre_drive 0 V=min(max(10000*V(x),-100),100)
Xcentre centre_drive centre_contact RELAY
Bedgestep edge_source 0 V=V(centre_contact)
Cedge edge_source edge 1n
Redge edge 0 10meg
Bedgeabs edge_abs 0 V=abs(V(edge))
BnetGate u3 net_drive I=V(u3,net_drive)*(1p+(.02-1p)*(1+tanh((V(edge_abs)-1)/.05))/2)
RnetDrive net_drive 0 1meg
Xnet net_drive net_contact RELAY

* Electrical button conditioning and player interlock. The B sources are
* documented logic macro-models (C04), not a transcription of every RY1 wire.
BhitL hit_l_drive 0 V=60*hi(10*V(button_l))*hi(V(can_l))
BhitR hit_r_drive 0 V=60*hi(10*V(button_r))*hi(V(can_r))
XhitL hit_l_drive hit_l_contact RELAY
XhitR hit_r_drive hit_r_contact RELAY
BsetRun set_run 0 V=max(V(hit_l_contact),V(hit_r_contact))
BresetRun reset_run 0 V=max(V(end_contact),V(reset))
XrunLatch set_run reset_run run LATCH
BrunDrive run_drive 0 V=.6*V(run)
Xrun run_drive run_contact RELAY
Xbank hit_r_contact hit_l_contact bank LATCH
BsetServer set_server 0 V=100*hi(V(end_contact))*positive(V(end_r))
BresetServer reset_server 0 V=max(V(reset),100*hi(V(end_contact))*positive(V(end_l)))
Xserver set_server reset_server server LATCH
BresetPermits reset_permits 0 V=max(V(reset_run),100-V(run))
BsetL set_l 0 V=100*hi(V(bank))*(1-hi(V(centre_contact)))*positive(V(y))
BsetR set_r 0 V=100*(1-hi(V(bank)))*hi(V(centre_contact))*positive(V(y))
BresetL reset_l 0 V=max(V(reset_permits),V(hit_l_contact))
BresetR reset_r 0 V=max(V(reset_permits),V(hit_r_contact))
XpermitL set_l reset_l permit_l LATCH
XpermitR set_r reset_r permit_r LATCH
BcanL can_l 0 V=100*(1-hi(V(run_contact)))*(1-hi(V(server)))+hi(V(run_contact))*V(permit_l)
BcanR can_r 0 V=100*(1-hi(V(run_contact)))*hi(V(server))+hi(V(run_contact))*V(permit_r)

* RY2 reset/hold contacts. They establish starting voltages by current flow.
* X offset source is an explicit serve-position calibration (C05).
Bhold hold 0 V=100-V(run_contact)
XholdY sy u1 hold CONTACT
XholdX sx u6 hold CONTACT
XholdPosY py y hold CONTACT
Bserve x x_hold V={SERVE}*(2*hi(V(server))-1)
XholdPosX px x_hold hold CONTACT

* Named telemetry. These voltage probes do not feed the plant.
BpreLX pre_lx 0 V=-V(lxp,lxn)
BpreLY pre_ly 0 V=-V(lyp,lyn)
BpreRX pre_rx 0 V=-V(rxp,rxn)
BpreRY pre_ry 0 V=-V(ryp,ryn)
.save v(u1) v(y) v(u6) v(x) v(pre_lx) v(pre_ly) v(pre_rx) v(pre_ry)
+ v(run) v(run_contact) v(can_l) v(can_r) v(server) v(bank)
+ v(ground_contact) v(net_contact) v(centre_contact) v(end_contact)
+ i(v.xground.vsense) i(v.xnet.vsense) i(v.xrun.vsense)
+ i(v.xly.vsense) i(v.xry.vsense) i(v.xlx.vsense) i(v.xrx.vsense)
.save v(sy) v(sx) v(py) v(px) v(ga) v(gb) v(na) v(nb) v(edge_source) v(edge) v(button_l) v(button_r) v(reset) v(permit_l) v(permit_r) v(xly.cp) v(lyn) v(xry.cp) v(ryn) v(xlx.cp) v(lxn) v(xrx.cp) v(rxn) v(xu1.pole) v(xu2.pole) v(xu3.pole) v(xu4.pole) v(xu6.pole) v(xu7.pole) v(hit_l_contact) v(hit_r_contact) i(v.xend.vsense) i(v.xcentre.vsense) i(v.xhitl.vsense) i(v.xhitr.vsense) v(railp) v(railm) v(logic) v(grav)
.options method=gear maxord=2 reltol=0.0001 abstol=1e-9 vntol=1e-6 chgtol=1p


* One electrical solve: computer, loaded line controls, passive supply,
* all fifteen PNP selectors and the declared scope terminal macro.
.param DISPLAY_EPOCH=0.0000000000000000
Bmains mains 0 V=165.4629867976521*sin(376.9911184307752*(time+DISPLAY_EPOCH))
Xinstrument mains net_v net_h court_v court_h dpp12 dpp6 dmm6 dmm22 TFT_INSTRUMENT
Xdisplay y x net_v net_h court_v court_h screen_y screen_x phase_a phase_b phase_c dpp12 dpp6 dmm6 dmm22 TFT_DISPLAY BETA=75
Xscope screen_x screen_y plate_x plate_y beam_i TFT_SCOPE
.ic v(xdisplay.base_l)=.01 v(xdisplay.base_r)=.02 v(xdisplay.ff_bl)=.01 v(xdisplay.ff_br)=.02
.temp 25
* Keep capacitor/selector states and probes, rather than all algebraic branch
* currents. The circuit solve is identical; only stored plot size changes.
.save v(xdisplay.base_l) v(xdisplay.base_r) v(xdisplay.emit_l) v(xdisplay.emit_r) v(xdisplay.ff_bl) v(xdisplay.ff_br) v(xdisplay.ff_el) v(xdisplay.ff_er) v(xdisplay.ff_l) v(xdisplay.ff_r) v(xdisplay.osc_l) v(xdisplay.osc_r) v(xdisplay.pulse_tap) v(xdisplay.trigger) v(xdisplay.xkeys.ah_b) v(xdisplay.xkeys.ah_c) v(xdisplay.xkeys.av_b) v(xdisplay.xkeys.av_c) v(xdisplay.xkeys.bh_b) v(xdisplay.xkeys.bh_c) v(xdisplay.xkeys.bv_b) v(xdisplay.xkeys.bv_c) v(xdisplay.xkeys.ch_b) v(xdisplay.xkeys.ch_c) v(xdisplay.xkeys.cv_b) v(xdisplay.xkeys.cv_c) v(xscope.pole_x) v(xscope.pole_y) v(plate_x) v(plate_y) v(beam_i) v(screen_x) v(screen_y) v(phase_a) v(phase_b) v(phase_c) v(net_v) v(court_h)
.save all
* Electronic Switch for Tennis Programming, BNL EH1-900-2-3 A, 1959-11-18.
* Transcription of the timing/selector network; external supply rails and
* six analogue computer outputs are ports. Transformer/bridge/CRT omitted.
* Q identifiers are ours: the archival sheet gives no device designators.
*
* DEVICE MODEL STATUS: preliminary Ge PNP Gummel-Poon surrogate. RCA SC-11
* (1964), printed p.131, gives typical small-signal hfe=75 at Ic=.6mA,
* Vce=-9V, and identifies 2N140 as Ge PNP. It is NOT a fitted switching model.
* IS/BR/VAF/CJ/TF/TR and the 1N100 surrogate below are engineering assumptions.
* Maximum ratings are not avalanche thresholds and are not used as such.
.subckt TFT_DISPLAY av ah bv bh cv ch scope_v scope_h phase_a phase_b phase_c pp12 pp6 mm6 mm22 params: BETA=75 ISGE=1u REVERSE=5 CTIME=.5u
.model GE140 PNP(IS={ISGE} BF={BETA} BR={REVERSE} VAF=45
+ RB=50 RC=5 RE=2 CJE=100p CJC=10p TF=20n TR=100n EG=.67 XTI=3 TNOM=25)
.model GE100 D(IS=1u N=1.3 RS=20 CJO=2p EG=.67 XTI=3 TNOM=25)

* Astable: 20k base returns, .5uF cross-coupling. The right 2k load is
* drawn as two 1k resistors, with the pulse pickoff at their midpoint.
Racl osc_l 0 2k
Rabl base_l 0 20k
Rabr base_r 0 20k
Racr1 pulse_tap 0 1k
Racr2 osc_r pulse_tap 1k
Cacl osc_l base_r {CTIME}
Cacr osc_r base_l {CTIME}
Qal osc_l base_l emit_l GE140
Qar osc_r base_r emit_r GE140
Rael emit_l pp6 510
Raer emit_r pp6 510

* Emitter-current inverters. The right astable drives BOTH B and C,
* suppressing those selectors while A is selected.
Qda phase_a emit_l pp6 GE140
Qdb phase_b emit_r pp6 GE140
Qdc phase_c emit_r pp6 GE140

* Positive differentiated edge toggles the cross-coupled bistable.
Ctrigger pulse_tap trigger 1n
Rtrigger trigger 0 5.1k
DtriggerL trigger ff_l GE100
DtriggerR trigger ff_r GE100
Rfcl ff_l 0 2k
Rfcr ff_r 0 2k
Rfbl ff_bl pp12 30k
Rfbr ff_br pp12 30k
RfcrossL ff_l ff_br 10k
RfcrossR ff_r ff_bl 10k
CfcrossL ff_l ff_br 1n
CfcrossR ff_r ff_bl 1n
Qfl ff_l ff_bl ff_el GE140
Qfr ff_r ff_br ff_er GE140
Rfel ff_el pp6 510
Rfer ff_er pp6 510
Qdfb phase_b ff_el pp6 GE140
Qdfc phase_c ff_er pp6 GE140

* Three level-shifted selector drives. The left diode symbol faces left
* on the sheet but has the SAME electrical polarity as the other two:
* anode at -6V, cathode at the phase collector.
Rpa phase_a mm22 5.1k
Rpb phase_b mm22 5.1k
Rpc phase_c mm22 5.1k
Dpa mm6 phase_a GE100
Dpb mm6 phase_b GE100
Dpc mm6 phase_c GE100
RpullA phase_a pp12 51k
RpullB phase_b pp12 51k
RpullC phase_c pp12 51k

Xkeys av ah bv bh cv ch scope_v scope_h phase_a phase_b phase_c TFT_KEYS BETA={BETA} ISGE={ISGE} REVERSE={REVERSE}
.ends TFT_DISPLAY

* Separate key bank permits DC transfer/leakage tests of the SAME devices.
.subckt TFT_KEYS av ah bv bh cv ch scope_v scope_h phase_a phase_b phase_c params: BETA=75 ISGE=1u REVERSE=5
.model GE140 PNP(IS={ISGE} BF={BETA} BR={REVERSE} VAF=45
+ RB=50 RC=5 RE=2 CJE=100p CJC=10p TF=20n TR=100n EG=.67 XTI=3 TNOM=25)
* Six PNP analogue keys, 51k/1k input dividers and common emitter outputs.
* No ideal switches, behavioural oscillators or externally scheduled gates.
Rav av av_c 51k
Rav0 av_c 0 1k
Ravb phase_a av_b 51k
Qav av_c av_b scope_v GE140
Rah ah ah_c 51k
Rah0 ah_c 0 1k
Rahb phase_a ah_b 51k
Qah ah_c ah_b scope_h GE140
Rbv bv bv_c 51k
Rbv0 bv_c 0 1k
Rbvb phase_b bv_b 51k
Qbv bv_c bv_b scope_v GE140
Rbh bh bh_c 51k
Rbh0 bh_c 0 1k
Rbhb phase_b bh_b 51k
Qbh bh_c bh_b scope_h GE140
Rcv cv cv_c 51k
Rcv0 cv_c 0 1k
Rcvb phase_c cv_b 51k
Qcv cv_c cv_b scope_v GE140
Rch ch ch_c 51k
Rch0 ch_c 0 1k
Rchb phase_c ch_b 51k
Qch ch_c ch_b scope_h GE140
.ends TFT_KEYS

* Oscilloscope terminal/deflection MACROMODEL, not a tube-by-tube DuMont.
* DuMont Oscillographer 14(1), 1953, pp.13,19-20: X input 2.2Mohm||50pF,
* Y input 2Mohm||50pF; 5ADP deflection factors at Eb2=1.6kV:
* X 48V/in, Y 36.8V/in. These are nominal instrument-family values.
* Gain, position, pole implementation, clamp and grid setting are OUR calibration.
* Two equal 300kHz RC poles give |H(100kHz)|=.9, |H(300kHz)|=.5.
* Tube/gun supplies are ideal. No power transformer, heater or tube ageing model.
.subckt TFT_SCOPE in_x in_y plate_x plate_y beam_i
RinputX in_x 0 2.2meg
RinputY in_y 0 2meg
CinputX in_x 0 50p
CinputY in_y 0 50p
BtargetX target_x 0 V=min(max(54*(V(in_x)+.11665),-110),110)
BtargetY target_y 0 V=min(max(44*(V(in_y)+.11665)-30,-110),110)
RpoleX1 target_x pole_x 1k
CpoleX1 pole_x 0 530.5164769729845p
EbufferX buffer_x 0 pole_x 0 1
RpoleX2 buffer_x plate_x 1k
CpoleX2 plate_x 0 530.5164769729845p
RpoleY1 target_y pole_y 1k
CpoleY1 pole_y 0 530.5164769729845p
EbufferY buffer_y 0 pole_y 0 1
RpoleY2 buffer_y plate_y 1k
CpoleY2 plate_y 0 530.5164769729845p
* Grid-current law is a declared 3/2-power gun surrogate, not a fitted 5ADP1.
Vgrid grid 0 -15
Vaccel anode 0 1600
Bgun anode 0 I=25u*(max(0,1+V(grid)/48)/.6875)^1.5
* Current is exposed as a voltage-valued telemetry port (1 V = 1 A).
Bcurrent beam_i 0 V=-I(Vaccel)
.ends TFT_SCOPE


* BNL EH1-900-2-3 A: passive supply, transcription research.
* 117/36 interpreted as RMS, 60Hz chosen US mains. Core effects omitted.
* RW, ESR and semiconductor parameters are declared uncertain assumptions.
* Ideal transformer has reciprocal primary current: energy conservation.
.subckt TFT_SUPPLY primary pp12 pp6 mm6 mm22 params: RATIO=.3076923076923077 RW=2 ESR=.5 CF=50u DRS=10 DIS=1u
Etransform secdrive secreturn primary 0 {RATIO}
Fprimary primary 0 Etransform {-RATIO}
Rwinding secdrive sec_a {RW}
Rreference secreturn 0 1g
.model RECT_GE D(IS={DIS} N=1.3 RS={DRS} CJO=2p EG=.67 XTI=3 TNOM=25)
D1 sec_a rect_p RECT_GE
D2 secreturn rect_p RECT_GE
D3 mm22 sec_a RECT_GE
D4 mm22 secreturn RECT_GE
Rseries rect_p pp12 10
Rdivider1 pp12 pp6 120
Rdivider2 pp6 0 180
Rdivider3 0 mm6 120
Rdivider4 mm6 mm22 390
Resrp12 pp12 cp12 {ESR}
Cfp12 cp12 0 {CF}
Resrp6 pp6 cp6 {ESR}
Cfp6 cp6 0 {CF}
Resrm6 mm6 cm6 {ESR}
Cfm6 0 cm6 {CF}
Resrm22 mm22 cm22 {ESR}
Cfm22 0 cm22 {CF}
.ends TFT_SUPPLY

* Operating calibration preserves the calculator's raw ground=-20V/net-top=0V.
* NET_AC=50Vrms comes from the annotated input. Its DC reference and both
* potentiometer positions are declared reconstruction settings, not recovered.
* Court secondary131.5Vrms is chosen, not specified in the surviving drawing.
.subckt TFT_INSTRUMENT mains net_v net_h court_v court_h pp12 pp6 mm6 mm22
Xsupply mains pp12 pp6 mm6 mm22 TFT_SUPPLY
VnetRef net_ref 0 -11.5
Enet net_drive net_ref mains 0 {50/117}
Fnet mains 0 Enet {-50/117}
RnetTop net_drive net_v 41650
RnetBottom net_v net_ref 8350
VnetH net_h 0 0
VcourtV court_v 0 -20
Ecourt court_drive 0 mains 0 {131.5/117}
Fcourt mains 0 Ecourt {-131.5/117}
RcourtTop court_drive court_h 25k
RcourtBottom court_h 0 25k
.ends TFT_INSTRUMENT

.end
