* ce-stage.cir
* ARGYNIX Skills (worldskills.blog), lesson "Analog faults: predict every node, then measure".
* A common-emitter stage, to predict its DC node voltages with and without faults.
* Made for LTspice, free from Analog Devices. Open it with File, Open (choose Netlists as
* the type of file), then Run.
*
* FAULT chooses the fault, numbered like the rows of the lesson's table:
*   0 none                 1 R1 open              2 R2 open           3 RC open
*   4 RE open              5 base-emitter junction open (here, the base lead)
*   6 base-emitter short   7 collector-emitter short
* An open part is OPEN (1 GOhm), a short is SHORT (1 mOhm), as in the lesson.
* Change the number in  .param FAULT=0  and run again. LTspice shows the node voltages in
* its operating point window, and the .meas lines write Vb, Ve and Vc to the log beside
* this file (ce-stage.log; in LTspice, View, SPICE Error Log). Write them into your own
* fault table.
*
* To see all eight at once, take the * off the .step line below. LTspice then draws each
* node voltage against FAULT, and shows no operating point window.
*
* RMETER is a 10 MOhm meter on the emitter. With FAULT=4, change it to 1Meg and then to
* 100Meg and run again, to see how much the meter matters.
*
* What to expect with no fault: Vb 2.05 V, Ve 1.39 V, Vc 5.52 V. The lesson's table was
* worked by hand, with 0.65 V across a conducting junction and 0.2 V across a saturated
* transistor, and this model lands within about 0.1 V of it. A floating collector (FAULT=3)
* is the exception: it reads about 0.2 V here, because a floating node's voltage depends
* on the transistor.

.param FAULT=0
.param OPEN=1G SHORT=1m
* .step param FAULT 0 7 1

VCC    vcc 0   DC 12
R1     vcc b   {if(FAULT==1, OPEN, 47k)}
R2     b   0   {if(FAULT==2, OPEN, 10k)}
RC     vcc c   {if(FAULT==3, OPEN, 4.7k)}
RE     e   0   {if(FAULT==4, OPEN, 1k)}
RBLEAD b   bq  {if(FAULT==5, OPEN, SHORT)}
RBE    b   e   {if(FAULT==6, SHORT, OPEN)}
RCE    c   e   {if(FAULT==7, SHORT, OPEN)}
Q1     c   bq  e   NPN200
RMETER e   0   10Meg

* A plain NPN of our own: gain 200, nothing else. Real parts differ: use the maker's model
* for exact values.
.model NPN200 NPN(IS=1e-14 BF=200)

.op
.meas OP Vb FIND V(b)
.meas OP Ve FIND V(e)
.meas OP Vc FIND V(c)
.end
