Changes
/* A Note on SPICE Simulation of Virtual Blocks */
[[File:rfspice_banner.png|right|640px]]
[[Image:Back_icon.png|40px]] '''[[RF.Spice_A/D | Back to RF.Spice A/D Wiki Gateway]]'''
[[Image:Tutorial_icon.png|40px]] '''[[RF.Spice_A/D#RF.Spice_A.2FD_Tutorials | RF.Spice A/D Tutorial Gateway]]'''
== An Introduction to Macromodeling in RF.Spice A/D ==
One of the great strengths of [[RF.Spice A/D]] is the ease of creating new user-defined devices or models. Most of RF.Spice's virtual blocks are indeed based on preloaded parameterized subcircuit models. You can open the Netlist code of these subcircuits, copy or modify them and package them into your own new virtual blocks. You can even convert an entire circuit into a model complete with your own symbol. There are also a number of virtual blocks whose underpinning models have been hard-coded into RF.Spice's simulation engines and device manager. An important difference between black-box virtual blocks and user-defined devices or simulation models is that virtual blocks typically use idealized devices/models and a combination of linear and nonlinear sources to minimize circuit complexity regardless of the feasibility of their hardware realization. In other words, they are primarily intended to represent functional behaviors rather than practical circuits.
[[Image:Tutorial_icon.png|40px]] '''[[RF.Spice_A/D#System-Level_Tutorial_Lessons| RF.Spice A/D System-Level Tutorial Lessons Gateway]]'''
== The Stages of a Macromodel Virtual Block ==
<table>
<tr>
<td> [[Image:Diff0.png|thumb|left|640px|A generic macromodel with input and output stages.]] </td>
</tr>
</table>
:<math> i(t) = C \frac{dv}{dt} </math>
where v(t) and i(t) are the voltage and current of the capacitor, respectively, and C is it its capacitance. Similarly for an inductor, one can write:
:<math> v(t) = L \frac{di}{dt} </math>
<table>
<tr>
<td> [[Image:Diff1.png|thumb|540pxleft|640px|An ideal differentiator using a capacitor.]] </td>
</tr>
</table>
<table>
<tr>
<td> [[Image:Diff2.png|thumb|540pxleft|640px|An ideal differentiator using an inductor.]] </td>
</tr>
</table>
== An Analog Differentiator Macromodel ==
:<math> \frac{ v_{out} }{ v_{in} } = - \frac{R_1}{1/sC_1} = -s \left( R_1C_1 \right) </math>
which represents a derivative operator in the Laplace s-domain.
<table>
<tr>
<td>
[[Image:Diff3.png|thumb|left|640px|A practical voltage differentiator circuit using an Op Amp.]]
</td>
</tr>
</table>
An equivalent macromodel of the above circuit is given in the following figure. This is RF.Spice's "Analog Differentiator Block". In this model, the ideal Op Amp has been replaced with the linear controlled voltage source E2:
<table>
<tr>
<td> [[Image:Diff4.png|thumb|700pxleft|720px|RF.Spice's "Analog Differentiator" block circuit.]] </td>
</tr>
</table>
== An Analog Integrator Macromodel ==
A practical voltage integrator circuit using an ideal Op Amp is shown in the opposite figure. The voltage transfer function of this circuit is given by:
which represents a integral operator in the Laplace s-domain. This circuit is very similar to the Op Amp differentiator except for the fact that the timing resistor and capacitor have switched places.
<table>
<tr>
<td>
[[Image:Integ1.png|thumb|left|640px|A practical voltage integrator circuit using an Op Amp.]]
</td>
</tr>
</table>
An equivalent macromodel of the above circuit is given in the following figure, which represents RF.Spice's "Analog Integrator Block". In this model, the ideal Op Amp has been replaced with the linear controlled voltage source E2:
<table>
<tr>
<td> [[Image:Integ2.png|thumb|700pxleft|720px|RF.Spice's "Analog Integrator" block circuit.]] </td>
</tr>
</table>
<table>
<tr>
<td> [[Image:Integ3.png|thumb|700pxleft|720px|The block diagram of a generalized analog filter with a rational s-domain transfer function.]] </td>
</tr>
</table>
<table>
<tr>
<td> [[Image:Integ4.png|thumb|left|560px|The property dialog of the generalized analog filter block.]] </td>
</tr>
</table>
<table>
<tr>
<td> [[Image:Integ5.png|thumb|700pxleft|720px|RF.Spice's "Digital Integrator" block circuit.]] </td>
</tr>
</table>
<table>
<tr>
<td> [[Image:Integ6.png|thumb|700pxleft|720px|The block diagram of a generalized IIR digital filter with a rational z-domain transfer function.]] </td>
</tr>
</table>
<table>
<tr>
<td> [[Image:Integ7.png|thumb|left|560px|The property dialog of the generalized digital filter block.]] </td>
</tr>
</table>
<table>
<tr>
<td> [[Image:Integ8.png|thumb|700pxleft|720px|The block diagram of a generalized FIR digital filter.]] </td>
</tr>
</table>
You can access all these blocks from the '''Parts Menu'''. Some of the waveform generator devices are categorized as "voltage source" devices in the Device Manager's point of view. A number of the virtual blocks are native XSPICE models. You can find their models as "process models" in the Device Manager. Many others are "subscircuit models". You can open up, view and even modify their Netlist codes. Some other blocks like the generalized analog and digital filters do not have editable Netlist codes.
== A Note on the SPICE Simulation of Virtual Blocks ==
When your circuit involves several interconnected virtual blocks, the SPICE simulation of your circuit is likely to encounter convergence problems. This is more frequent when you a transient analysis of such circuits. In those case, we recommend that you change the SPICE integration method. You can do this by opening the '''SPICE [[Simulation Options]]''' dialog from the Simulate Menu. There are two options available: trapezoidal or gear. The default option is "trap". Changing the integration method to "gear" can improve the convergence of the transient analysis. <table><tr><td> [[Image:Integ9.png|thumb|left|640px|Setting the integration method in the SPICE Simulation Options dialog.]] </td></tr></table>
<p> </p>
[[Image:Tutorial_icon.png|40px]] '''[[RF.Spice_A/D#RF.Spice_A.2FD_Tutorials | RF.Spice A/D Tutorial Gateway]]'''
[[Image:Back_icon.png|40px]] '''[[RF.Spice_A/D | Back to RF.Spice A/D Wiki Gateway]]'''