** Script to curve trace BJT ** To use, select a single BJT on schematic then ** run this script. You will be prompted to enter ** max base current, max collector voltage and number of steps Let scr = GetPath('ScriptDir') if selectCount()<>1 then Echo "One and one only device must be selected" exit script endif Let type = PropValue('model') Let numTerms = Length(InstPins()) if type<>'q' && type<>'x' || numTerms<>3 && numTerms<>4 then Echo "Device is not a BJT" exit script endif ** Now try and determine sex of device ** First get symbol name Let symName = SymbolName('handle', PropValue('handle')) if symName='npn' || symName='npn_darl' then Let pol=1 elseif symName='pnp' || symName='pnp_darl' then Let pol=-1 else ** Don't recognise the symbol so we will ask the user Let sel = RadioSelect(1, ['npn', 'pnp'], 'Select device polarity') if sel=1 then Let pol=1 else Let pol = -1 endif endif Let global:device = propvalue('value') if symName='npn_darl' || symName='pnp_darl' then ** Darlington so initialise base current box at 10uA instead of 1mA Let options = ValueDialog([10u, 15, 10], ['Max Base Current', 'Max Collector Voltage', 'Number Steps'], 'BJT Trace Settings') else Let options = ValueDialog([1m, 15, 10], ['Max Base Current', 'Max Collector Voltage', 'Number Steps'], 'BJT Trace Settings') endif Let IbMax = options[0]*pol Let VceMax = options[1]*pol Let numSteps = options[2] ** Create netlist to simulate Echo /file design.net "* BJT curve trace" if type='q' then Echo /append design.net "Q1 C B 0 0" {device} elseif type='x' && numTerms=4 then Echo /append design.net "X1 C B 0 0" {device} else Echo /append design.net "X1 C B 0" {device} endif Echo /append design.net "Vce C 0 0" Echo /append design.net "Ib 0 B {Ib}" Echo /append design.net ".dc Vce 0" {VceMax} {VceMax/50} Echo /append design.net ".graph Vce#n curveLabel={curveLabel} graphName={traceid}" ylabel= { '"Collector current ' & device & '"'} if not ExistVec('global:traceid') then Let global:traceid=1 endif for global:Ib=IbMax/numSteps To IbMax step IbMax/numSteps Let global:curveLabel = 'Ib=' & global:Ib Run /file design.net next global:ib Let global:traceid=global:traceid+1