Equation Tutorial: Diode DC Sweep

advertisement
Equation Tutorial: Diode DC Sweep
The most basic model of an ideal diode is a simple on-off switch; when the voltage across the
diode exceeds the built-in potential plus the bias voltage, the idealized diode acts as a short
circuit. This tutorial demonstrates a basic usage of Genesys equations to compare results for this
ideal model to calculated results from nonlinear DC analysis.
Figure 1. DC Sweep Diode Circuit.
To create an analytic approximation of the circuit’s Vout vs. Vin characteristic, we can observe
that at Vin = 0 V, the voltage drop across both diodes is certainly less than the Bias + Vj = 6 V
required for the diodes to short-circuit. This holds true around between +6 V and -6V. Once Vin
exceeds 6 V, the output will depend on the values of resistors.
Thus the ideal Vout(Vin) is:
1
1
Vin  (6  6)
11
11
Vout  Vin
1
1
Vout  Vin  (6  6)
11
11
Vout 
When Vin   6V
When  6 V  Vin   6V
When Vin  6V
Implementing Ideal Equation in Genesys
(Note: this walkthrough assumes the user can create and run analyses / sweeps )
After a sweep of a DC analysis is performed, equations can be used to check the validity of the
idealized Vin vs. Vout relationship. The goal is to use the Vin that is saved in the Sweep’s dataset
and calculate the ideal Vout; this is stored in a variable that can be plotted and compared with the
measured results.
1. Allocate variable of correct size
theSize = size(Sweep1_Data.V1)
This statement returns an array that holds the sizes of the variable Sweep1_Data.V1 in
each dimension. In this case theSize is a 1x1 array because the voltage variable has only
one dimension.
iMax = theSize[1]
We would like a single scalar quantity for the length; additionally, this makes the iMax
variable show up in the variable display of the equation editor so the user can see on the
fly what the size of the array is.
idealVout = array(iMax)
This statement creates idealVout as a one-dimensional array of the same size as Vin from
the sweep; this allows it to dynamically re-size if the user then changes the number of
sweep points.
2. Find points of interest
point1 = Sweep1_Data.V1@(-6)
The @ operator returns the index at which the variable preceding the @ takes on a value
that is after the @. In this case, it will return the index of the Swept Vin at which Vin is 6V. Note: using a single argument to @ requires that the variable be exactly that value;
see the user’s guide equation section for more information on the @ operator.
point2 = Sweep1_Data.V1@6
The other point we need is when the input is at 6 V. Note that both point1 and point2 are
visible in the variable view.
3. Calculate ideal Vout at each point as a piece-wise function of Vin
(Note: statement is NOT word-wrapped in actual equations)
for i = 1 to (point1)
idealVout[i] = (1/11)*Sweep1_Data.V1[i] - (6 +
(1/11)*Sweep1_Data.V1[point1])
next
The first subsection is when Vin is less than -6 V; ie the index of Sweep1_Data.V1 is less
than point1. In this region we apply the equations for the ideal diode circuit, with a 1/11
slope and -6 V y-intercept. The for statement increments the variable i from 1 to point1;
everything between for and next is calculated at each step and is typically a function of
the increment variable.
for i = (point1+1) to (point2-1)
idealVout[i] = Sweep1_Data.V1[i]
next
In the second piece-wise section, from just after -6V to just before 6V, Vout = Vin. Note
that in this case the y-intercepts are carefully chosen so the +1 and -1 aren’t necessary,
but are a good practice to avoid off-by-one errors in calculation.
for i = (point2) to iMax
idealVout[i] = (1/11)*Sweep1_Data.V1[i] + (6 (1/11)*Sweep1_Data.V1[point2])
next
The final piece-wise section goes from 6V to the maximum index (end) of
Sweep1_Data.V1.
4. Set units and dependency of the calculated variable
setunits("idealVout","V")
Before this statement, idealVout was just MKS numerical values; now it has a unit of
measure and will plot as such when on a graph.
setindep("idealVout","Sweep1_Data.V1")
This makes idealVout explicitly a function of Sweep1_Data.V1; this statement will
match-up the value of the independent variable ( Sweep1_Data.V1) at each index point to
the value of the dependent variable (idealVout) at each point. After this statement is
executed, idealVout becomes a “Swept Variable”.
Graphing and Comparing
Now that the ideal variable has been calculated, it can be plotted along with the simulated
nonlinear diode. Set the default measurement context of a graph to “Equations” and plot the
simulated output voltage along with “re(idealVout)”. Note: variables from equations generally get
created as complex and plot as magnitude by default; using re() lets us see the variable go
negative.
Figure 2. Graph Properties.
The resulting graph shows a “good fit”:
Figure 3. DC Sweep Results.
We can see that in the diode’s “off” state, the ideal equations closely match those of the circuit
model, while during “on” operation there is a difference. We can quantify this by looking at the
difference between the two and plotting Sweep1_Data.VVout – re(idealVout).
As one may expect, the difference is largest around the +6V and -6V critical points, where the
ideal equations have a sharp discontinuity, while a real diode will gradually shift. The error then
decays logarithmically with increasing Vin.
Such usage of equations in other cases allows one to measure a hypothesis of underlying causes
of simulation results via user-created variables.
Figure 4. Difference Result.
Download