<Comment>* Current Mode PWM Average Model</Comment><br/>
<Comment>*</Comment><br/>
<Preprocessor>.Subckt</Preprocessor><Normal Text> </Normal Text><Subckt Note>PWM-CM</Subckt Note><Normal Text> nA nC nP nVCtrl nD </Normal Text><Subckt Params>Params:</Subckt Params><Normal Text> Lsw</Normal Text><Symbol Operator>=</Symbol Operator><Number>100</Number><Unit>uH</Unit><Normal Text> Fsw</Normal Text><Symbol Operator>=</Symbol Operator><Number>100</Number><Unit>kHz</Unit><Normal Text> DCMax</Normal Text><Symbol Operator>=</Symbol Operator><Number>0.95</Number><Normal Text> DCMin</Normal Text><Symbol Operator>=</Symbol Operator><Number>0.05</Number><Normal Text> RISense</Normal Text><Symbol Operator>=</Symbol Operator><Number>1</Number><Normal Text> Slope</Normal Text><Symbol Operator>=</Symbol Operator><Number>100</Number><Unit>m</Unit><br/>
<Comment>*</Comment><br/>
<Comment>* Input Resistor on Control Pin</Comment><br/>
<Passives>RVCtrl</Passives><Normal Text> nVCtrl </Normal Text><Number>0</Number><Normal Text> </Normal Text><Number>1</Number><Unit>Meg</Unit><br/>
<Comment>*</Comment><br/>
<Comment>* ON Duty Cycle</Comment><br/>
<Source>EDuty</Source><Normal Text> nD </Normal Text><Number>0</Number><Normal Text> Value</Normal Text><Symbol Operator>=</Symbol Operator><Symbol>{</Symbol><Normal Text>V</Normal Text><Symbol>(</Symbol><Normal Text>nDPC</Normal Text><Symbol>)</Symbol><Symbol Operator>*</Symbol Operator><Normal Text>V</Normal Text><Symbol>(</Symbol><Normal Text>nCx</Normal Text><Symbol>,</Symbol><Normal Text>nP</Normal Text><Symbol>)</Symbol><Symbol Operator>/</Symbol Operator><Symbol>(</Symbol><Normal Text>V</Normal Text><Symbol>(</Symbol><Normal Text>nA</Normal Text><Symbol>,</Symbol><Normal Text>nP</Normal Text><Symbol>)</Symbol><Symbol Operator>-</Symbol Operator><Normal Text>V</Normal Text><Symbol>(</Symbol><Normal Text>nCx</Normal Text><Symbol>,</Symbol><Normal Text>nP</Normal Text><Symbol>)</Symbol><Symbol Operator>+</Symbol Operator><Number>1</Number><Unit>u</Unit><Symbol>)}</Symbol><Normal Text> </Normal Text><Comment>; EDuty</Comment><br/>
<Comment>*</Comment><br/>
<Preprocessor>.EndS</Preprocessor><Normal Text> </Normal Text><Subckt Note>PWM-CM</Subckt Note><br/>
<Normal Text></Normal Text><br/>
<Comment>** Includes</Comment><br/>
<Directive>.include</Directive><Normal Text> some_model.mod</Normal Text><br/>
<Directive>.include</Directive><Normal Text> models</Normal Text><Symbol Operator>/</Symbol Operator><Normal Text>test</Normal Text><Symbol Operator>/</Symbol Operator><Normal Text>BC550.mod</Normal Text><br/>
<Normal Text></Normal Text><br/>
<Normal Text></Normal Text><br/>
<Comment>** Comments</Comment><br/>
<Comment>* General SPICE.</Comment><br/>
<Comment>; PSpice</Comment><br/>
<Comment>$ ngspice</Comment><br/>
<Keyword>.param</Keyword><Normal Text> ... </Normal Text><Comment>; PSpice</Comment><br/>
<Keyword>.param</Keyword><Normal Text> ... </Normal Text><Comment>$ ngspice</Comment><br/>
<Normal Text></Normal Text><br/>
<Comment>** Parameters</Comment><br/>
<Keyword>.param</Keyword><Normal Text> TESTPARAM </Normal Text><Symbol Operator>=</Symbol Operator><Normal Text> </Normal Text><String>'2 * 1.5V'</String><br/>
<Keyword>.param</Keyword><Normal Text> TESTPARAM </Normal Text><Symbol Operator>=</Symbol Operator><Normal Text> </Normal Text><String>"2 * 1.5V"</String><br/>
<Keyword>.param</Keyword><Normal Text> TESTPARAM </Normal Text><Symbol Operator>=</Symbol Operator><Normal Text> </Normal Text><Symbol>{</Symbol><Normal Text> </Normal Text><Number>2</Number><Normal Text> </Normal Text><Symbol Operator>*</Symbol Operator><Normal Text> </Normal Text><Number>1.5</Number><Unit>V</Unit><Normal Text> </Normal Text><Symbol>}</Symbol><br/>
<Keyword>.param</Keyword><Normal Text> TESTPARAM </Normal Text><Symbol Operator>=</Symbol Operator><Normal Text> </Normal Text><Symbol>[</Symbol><Normal Text> </Normal Text><Number>2</Number><Normal Text> </Normal Text><Symbol Operator>*</Symbol Operator><Normal Text> </Normal Text><Number>1.5</Number><Unit>V</Unit><Normal Text> </Normal Text><Symbol>]</Symbol><br/>
<Keyword>.param</Keyword><Normal Text> TESTPARAM </Normal Text><Symbol Operator>=</Symbol Operator><Normal Text> </Normal Text><Symbol>(</Symbol><Normal Text> </Normal Text><Number>2</Number><Normal Text> </Normal Text><Symbol Operator>*</Symbol Operator><Normal Text> </Normal Text><Number>1.5</Number><Unit>V</Unit><Normal Text> </Normal Text><Symbol>)</Symbol><br/>
<Normal Text></Normal Text><br/>
<Simulation Command>.four</Simulation Command><Normal Text> </Normal Text><Number>1</Number><Unit>Meg</Unit><Normal Text> v</Normal Text><Symbol>(</Symbol><Normal Text>input</Normal Text><Symbol>)</Symbol><br/>
<Normal Text></Normal Text><br/>
<Source>Vinput</Source><Normal Text> input </Normal Text><Number>0</Number><Normal Text> </Normal Text><Function>SIN</Function><Symbol>(</Symbol><Number>500</Number><Unit>mV</Unit><Normal Text> </Normal Text><Number>1</Number><Unit>V</Unit><Normal Text> </Normal Text><Number>1</Number><Unit>k</Unit><Symbol>)</Symbol><br/>
<Source>vinput</Source><Normal Text> input </Normal Text><Number>0</Number><Normal Text> </Normal Text><Function>sin</Function><Symbol>(</Symbol><Number>500</Number><Unit>mV</Unit><Normal Text> </Normal Text><Number>1</Number><Unit>V</Unit><Normal Text> </Normal Text><Number>1</Number><Unit>k</Unit><Symbol>)</Symbol><br/>
<Normal Text></Normal Text><br/>
<Comment>* Input Sources</Comment><br/>
<Function>EXP</Function><Symbol>(</Symbol><Number>0</Number><Normal Text> </Normal Text><Number>2</Number><Unit>V</Unit><Normal Text> </Normal Text><Number>1</Number><Unit>ms</Unit><Normal Text> </Normal Text><Number>2</Number><Unit>ms</Unit><Normal Text> </Normal Text><Number>3</Number><Unit>ms</Unit><Normal Text> </Normal Text><Number>1</Number><Normal Text> </Normal Text><Number>2</Number><Symbol>)</Symbol><br/>
<Function>exp</Function><Symbol>(</Symbol><Number>0</Number><Normal Text> </Normal Text><Number>2</Number><Unit>V</Unit><Normal Text> </Normal Text><Number>1</Number><Unit>ms</Unit><Normal Text> </Normal Text><Number>2</Number><Unit>ms</Unit><Normal Text> </Normal Text><Number>3</Number><Unit>ms</Unit><Normal Text> </Normal Text><Number>1</Number><Normal Text> </Normal Text><Number>2</Number><Symbol>)</Symbol><br/>
<Comment>* lx is also a function</Comment><br/>
<Passives>Lx</Passives><Normal Text> node1 node2 </Normal Text><Number>200</Number><Unit>mH</Unit><br/>
<Normal Text></Normal Text><br/>
<Comment>** Sub-Circuit</Comment><br/>
<Comment>* Call</Comment><br/>
<Actives>X1</Actives><Normal Text> </Normal Text><A-device>inv</A-device><Normal Text> ninv out v</Normal Text><Symbol Operator>+</Symbol Operator><Normal Text> v</Normal Text><Symbol Operator>-</Symbol Operator><Normal Text> LM324</Normal Text><br/>
<Actives>x1</Actives><Normal Text> </Normal Text><A-device>inv</A-device><Normal Text> ninv out v</Normal Text><Symbol Operator>+</Symbol Operator><Normal Text> v</Normal Text><Symbol Operator>-</Symbol Operator><Normal Text> lm324</Normal Text><br/>
<Normal Text></Normal Text><br/>
<Keyword>.end</Keyword><br/>
