pingspice.lib.active.PWM(Subcircuit)
class documentation
Part of pingspice.lib.active
(View In Hierarchy)
PWM square wave oscillator with duty cycle controlled by an input ranging from 0-1, where 1 is 100% duty cycle.
The nodes are:
- 'ctrl' - An inmput with voltage from 0 to 1, controlling the duty cycle.
- 'outp' - Positive output.
- 'outn' - Negative output (need not be tied to ground).
Instance Variable | Vhigh | The high output voltage. |
Instance Variable | Vlow | The low output voltage. |
Instance Variable | fs | The frequency (Hz). |
Instance Variable | tt | The transition time from Vlow to Vhigh and vice versa. |
Instance Variable | tRiseFall | Set to a rise/fall time in seconds to limit output slew rate for realism or convergence. |
Instance Variable | t0 | An optional delay (seconds) from TRAN start before the start of the pulse train. |
Method | setup_oscillator | Constructs a triangle-wave oscillator with my frequency fs and a ground-referenced output at n1. |
Method | setup_ctrl_atanh | Constructs a TABLE E-source that implements the following function, which Ngspice seems to have trouble calculating consistently for some stupid reason: |
Method | setup_comparator | Constructs a smooth-edged comparator intended for use with a triangle wave on input n1 and a (relatively) constant voltage between 0 and 1 on input n2. |
Method | setup | Defines the subcircuit netlist for a PWM oscillator with simulation-friendly transitions from Vlow to Vhigh and back again. |
Inherited from NodeStuff (via Subcircuit):
Instance Variable | shunts | A dict of current sensing V elements with the pairs of nodes they connect. |
Class Variable | debug | A Bag that gets set
True for all instances to log info about each setup
call. |
Class Method | autoName | Undocumented |
Method | setupResults | Undocumented |
Method | fill | Undocumented |
Method | nodeCheck | Call with the circuit building tool f and a sequence of
nodes provided to this Include or
Subcircuit . |
Method | rawNetlist | Get lines of a raw netlist from a search hierarchy of possible sources. |
Method | shunt | Call to insert a current-measuring shunt and add an entry to my Elements
baton's dict of shunts. |
Method | raw | See Elements.raw . |
Method | iNode | See Elements.iNode . |
Method | ground | See Elements.ground . |
Method | sca | See Elements.sca . |
Method | sca6 | See Elements.sca6 . |
Class Method | _libDir | Undocumented |
Method | _strippedLines | Undocumented |
Method | _call_setup | Calls my setup
method (almost always your override of that method, actually) and processes
any return value. |
Inherited from NodeStuff (via Subcircuit):
Instance Variable | shunts | A dict of current sensing V elements with the pairs of nodes they connect. |
Class Variable | debug | A Bag that gets set
True for all instances to log info about each setup
call. |
Class Method | autoName | Undocumented |
Method | setupResults | Undocumented |
Method | fill | Undocumented |
Method | nodeCheck | Call with the circuit building tool f and a sequence of
nodes provided to this Include or
Subcircuit . |
Method | rawNetlist | Get lines of a raw netlist from a search hierarchy of possible sources. |
Method | shunt | Call to insert a current-measuring shunt and add an entry to my Elements
baton's dict of shunts. |
Method | raw | See Elements.raw . |
Method | iNode | See Elements.iNode . |
Method | ground | See Elements.ground . |
Method | sca | See Elements.sca . |
Method | sca6 | See Elements.sca6 . |
Class Method | _libDir | Undocumented |
Method | _strippedLines | Undocumented |
Method | _call_setup | Calls my setup
method (almost always your override of that method, actually) and processes
any return value. |
Constructs a triangle-wave oscillator with my frequency fs and a ground-referenced output at n1.
Returns the rise/fall time, which is a little bit less than half the period, owing to non-zero pulse width.
Constructs a TABLE E-source that implements the following function, which Ngspice seems to have trouble calculating consistently for some stupid reason:
V(n2) = a*atanh(b*(V(n1)-0.5))
The output voltage appears at node n2. The voltage at input node n1 must be between 0 and 1. Both nodes are ground-referenced.
Constructs a smooth-edged comparator intended for use with a triangle wave on input n1 and a (relatively) constant voltage between 0 and 1 on input n2.
Specify the output rise/fall time by supplying a multiple of the triangle wave slope vs the output signal slope, slopeGain.
Input nodes n1 and n2 and output node n3 are all ground-referenced.
The zero-state output voltage is set by my Vlow attribute, and the one-state voltage by my Vhigh attribute.
Defines the subcircuit netlist for a PWM oscillator with simulation-friendly transitions from Vlow to Vhigh and back again.
This is the output voltage expression, where X
is a
triangle wave from -0.5 to +0.5 and ctrl
is an input node
whose value can range from 0 (0% duty cycle) to 1.0 (100%):
V = b + m*tanh(tGain*(X + aGain*atanh((1/aGain-2/tGain)*(ctrl-0.5))))