By Harvey Morehouse
- Modified Half Gudermannian Device
- Modified Full Gudermannian Device
- Smooth Transition Gudermannian Switch
Modified Half Gudermannian Device
About the writer: Harvey Morehouse is a contractor/consultant with many years of experience using circuit analysis programs. His primary activities are in Reliability, Safety, Testability and Circuit Analysis. He may be reached at email@example.com. Simple questions for which I know the answer are free. Complex questions, especially where I am ignorant of the answers, are costly!!!
Summary: A modified Gudermann function can be useful in SPICE modeling of devices that switch from one state to another. It provides a smooth transition between extremities. It is also continuously differentiable, and somewhat so in a SPICE numerical world, unlike some piecewise linear models. Use of this function in SPICE models is present in other variants of SPICE, however its implementation here was independently arrived at. This function will use a unipolar drive and this modified Gudermannian function will switch between zero and unity.
A shape of this function is shown in Figure 1 following:
Figure 1 was taken from reference 1. What is not shown are the limiting values, which are equal to Pi/2 in magnitude for large positive and negative excursions in 'x'.
To utilize this function in models, a switching device for one, there are two little problems. The first is that the midpoint of the curve, where x = 0, is a value of 0. Clearly this requires that the input or the output might be offset in order to get a smooth transition for extremes of either polarity.
The second is the scaling of the input for, as the graph in figure 1 reveals for the unmodified curve (the units for 'x' and 'y' axis are one per tick mark). The exponent argument of 'x' should be replaced by 'ax' to ensure the function fully reaches the extreme values desired for a given range of 'x'. One must scale the function such that it works with signals ranging from zero to some maximum, as well as for signals centered about zero with maximums of either polarity, and produces the desired output range.
Modified half Gudermann Function Model #1:
This curve varied between positive and negative one. To make it vary between zero and one we need to alter his equation slightly. The modified half Gudermann function becomes:
Because we wish the input control function, 'x', to vary from unity to some positive value, we must offset it by some amount in order to have exponent vary between positive and negative values. The value for the offset is problematic. One would like it to be about half of the maximum excursion of x. For some applications this may be well known. In other cases it may not be.
The derivative of this function is:
A circuit implementing the modified Gudermann function is shown in the following Figure 2.
Modified Gudermann hnormal Circuit
arriving at Figure 2 some additional changes were made which were
incorporated into the circuit. First, the circuitry below the dashed
lines includes test inputs. It is assumed that eventually these parameters,
'a' and 'Maxexc' will be passed as parameters to the function in order
to customize it for use in specific device models. The default values
for 'a' will be 12, and Maxexc, the maximum control signal input excursion,
will be unity.
Now the maximum excursion at the input can exceed this value with no detriment, dependent on 'a', but some value must be used in order to translate the input excursion from a unipolar input to a bipolar value.
The input 'x' is a 1v square wave. 'a' is swept value, and Maxexc is set equal to 1v. A graph of the output from the circuit is shown in the following Figure 3.
Modified Gudermann hnormal Test Circuit 1 Graph 1
The output switches nicely between a low and a high value in most instances. The output being a series of sweeps with 'a' varying in value from 2 (the red curve) to 12 in the case of the fastest rise for the maroon curve. The red, green and yellow curves are not well behaved. The reason is that the argument of the exponential function is not large enough in those instances to drive the function to the extreme values.
Therefore, in use of this circuit, it is recommended that the product of the 'a' and the Maxexc or maximum excursion value not be less than about 10 to guarantee smooth switching between extremes.
Now, given that a = 6, Maxexc = 1, what will happen when the input, instead of being a zero to 1V pulse becomes a zero to 5V pulse? A graph of the output when the peak of the v1 pulse generator is varied from 1 to 10V peak for these conditions is shown in Figure 4 following:
Modified Gudermann hnormal Test Circuit 1 Graph 2
In Figure 4 we see that with increasing pulse amplitude, we are in effect decreasing the rise time. Now, let us fix the pulse amplitude at 10v, 'a' at 6, and step the value of Maxexc from one to ten in steps of one. The output is shown in Figure 5 following.
Modified Gudermann hnormal Test Circuit 2 Graph 1
Here we see the effect is to modify the switching interval about. Remember that the input rise time is 1uSec.
One more task remains. Because of numerical errors, the output at the low level is not quite zero. Recalling the defining equation we are implementing, it is:
The output level when the input level is zero, is that function with the exponent argument equal to a constant '-a*off' as expressed above, or = '-a*v(Maxexc)/2'. To get a better result at the low level, we need to subtract this value from the output. A circuit which will do this is shown in Figure 6 following:
Modified Gudermann hnormal Test Circuit 2
change is rather unremarkable, however the effect is to reduce the
zero output level to the order of 1e-19, while the unity level is
1000 mV to three decimal places.
The circuit of Figure 6 should be converted into a parameterized subcircuit as shown. There will be one input and one output connection, with 'a' and 'Maxexc' being passed parameters having default values of 6 and 1 respectively. The device should be named gudhnor.
A Modified Half Gudermannian circuit model has been created which can be useful in creating devices or in functions that smoothly switch between low and high magnitude values. This device should be added to the standard library as a building block.
1 Wikopedia Article, Gudermannian function. http://en.wikipedia.org/wiki/Gudermannian_function
Modified Full Gudermannian Device
Summary: A Gudermann curve can be useful in SPICE modeling of devices that switch from one state to another. It provides a smooth transition between extremities. It is also continuously differentiable, and somewhat so in a SPICE numerical world, unlike some piecewise linear models. Use of this function in SPICE models is present in other variants of SPICE, however its implementation here was independently arrived at. This function will use a bipolar drive and the modified Gudermannian function will switch smoothly between equal positive and negative values through zero for equal amplitude positive and negative number inputs.
A shape of this function is shown in Figure 1 following:
The derivative of the function is
and the derivative of its inverse is given by
Figure 1 was taken from reference 1. What is not shown are the limiting values, which are equal to Pi/2 in magnitude for large excursions in 'x' .
To utilize this function in models, as perhaps an inductor, there are several problems. The first is the scaling of the input for, as the graph in figure 1 reveals for the unmodified curve (the units for 'x' and the output are one per tick mark), the exponent value of 'exp(x)' should be replaced 'ax', with 'a' chosen to ensure the function fully reaches the extreme values desired for a given range of 'x'.
Another is that one must scale the function such that it works with signals to produce the desired output range and also the proper shape between extremities. Unfortunately the value of 'a' affects both of these considerations.
Modified Full Gudermann Function Model #1:
Let us make a few assumptions as a basis for the model. The first is that the input signal will range in value from at least MinV as a minimum to MaxV as a maximum. At an input equal in magnitude to MinV the output should be minimum and at an input equal in magnitude to MaxV (= -MinV) the output should be maximum. Now the midpoint of the curve will be when the input is at the value Vmid = (MaxV + MinV)/2 = 0. To achieve this, the original Gudermannian curve will be slightly modified to become:
This will in B2SPICE format become:
v = atan(exp(v(a)*v(x) )) /(atan(1)) -1
Here, atan(1) = Pi/4. This function produces an output which varies smoothly from minus one to plus one in amplitude for a sufficiently large value of exponent, or v(a)*v(x) product. A circuit implementing this is shown in the following Figure 2.
Modified Full Gudermann Circuit
One other factor needs to be noted. We will be sweeping the value of 'a' provided by generator v1 in a test.
A netlist of the circuit is provided for reference and is as follows:
***** main circuit
V1 x 3 PULSE( -1.000000000000e+000 1.000000000000e+000 0.000000000000e+000 1.000000000000e-006 1.000000000000e-006 1.000000000000e-005 2.000000000000e-005)
R1 x 3 1K
R2 a 5 1K
R3 Gudax 0 1K
R4 3 0 10Meg
B1 Gudax 0 v = atan(exp(v(a)*v(x) )) /(atan(1)) -1
V2 a 5 0.000000000000e+000
R5 5 0 10Meg
.TRAN 1E-6 6E-5 0 1E-8 uic .OPTIONS method = gear
It is intended that the device model be named Gudpfn. The 'Gud' implying it is a Gudermann function, 'p' implying a zero to positive input level input level, and 'fn' implying that the output excursion although smooth as in a normal Gudermann function, changes from minus one in magnitude to positive 1 as limits.
A graph of the output from the circuit is shown in the following Figure 3.
Modified Gudermann full normal Test Circuit Graph 1
Here we are sweeping the value of 'a' from one to six, showing a positive to negative transition. The negative to positive transitions behave in a similar manner. As the input is a square wave with unity positive and negative values, this gives us an appreciation of how the curve varies with different extreme magnitudes of the exponent.
The red curve represents 'a' equaling one, the light blue curve represent 'a' = 6, and with unity increments in between. Clearly to reach values close to unity the v(a)*v(x) product should be equal to or greater than about 5 in magnitude as a minimum at the extremes, and the final values are less than one percent from the extremes.
Returning to the curve, it is again:
v = (2*atan(exp(v(a)*v(x) )) - 2*atan(1))/(2*atan(1))
In order to know how the slope of the curve varies as a function of 'a' and 'x', we need to differentiate the curve. After some work, we find that the derivative is:
Let us model this and see what this tells us. We will plot a derivative of the modified Gudermannian curve output and the analytical derivative using both SPICE and the above formula using the circuit as shown in Figure 4 as follows:
Modified Gudermann fnormal Test Circuit 2
A graph of the circuit in Figure 4, for 'a' = 5 is shown in Figure 5.
Modified Gudermann fnormal Test Circuit 2 graph
In Figure 5 we see a rather complex picture. The red trace is the input voltage. The green trace is the modified Gudermann output. The blue trace is the analytic derivative of the modified Gudermann function. The maroon trace, almost a trapezoid, is the SPICE derivative of the modified Gudermann generator.
The question arises why the SPICE derivative of the modified Gudermann function does not agree with the analytic derivative of the modified Gudermann function. With a little reflection, it is clear that SPICE creates a derivative with respect to time, whereas the analytic derivative of the modified Gudermann function does not include time. Thus, we are comparing from the equation:
y = f(x)
dy/dx = f'(x)
dy(t)/dy = f'(x,t)
Which brings to mind some thoughts about modeling in general.
When creating a circuit model, the BEST model in terms of accuracy and convergence is virtually ALWAYS created with SPICE primitive devices such as resistors, capacitors, inductors, transistors and so on. However certain devices such as abrupt switches can cause convergence problems.
Use of behavioral device models is equal to or intermediate between these abrupt discontinuous devices and discrete device models in terms of convergence. Just because a device can seemingly be well behaved, like a Gudermann function, does not mean that when used in place of a SPICE switch model, that it will be free from convergence problems.
In terms of speed, assuming that convergence problems are not present, the behavioral model is usually intermediate between an abrupt model such as a piecewise linear transfer function and discrete device models.
Also, it must be remembered that SPICE itself essentially produces a sampled data output, and thus a function, which is continuously differentiable in the real world, might not be in a time domain.
A circuit to be converted into a parameterized subcircuit model is shown in Figure 6 following.
Modified Gudermann fnormal mGudax model
It is assumed that this mGudax model will be added to the standard library, as it will be used to create some other devices in the future.
A modified full Gudermannian circuit model has been created which can be useful in creating devices or functions which smoothly switch between equal magnitude values of opposite sign, for a similarly varying input signal.
1 Wikopedia Article, Gudermannian function. http://en.wikipedia.org/wiki/Gudermannian_function
Smooth Transition Gudermannian Switch
Summary: A modified Gudermann function can be useful in SPICE modeling of devices that switch from one state to another. One such device is a switch function. This device will use a unipolar drive and will switch between a small value to a much higher value smoothly.
In a previous article I showed how to create what I called a half Gudermannian function. This function, using a unipolar control signal, was a function that varied smoothly between a very small value and unity. Here we shall use this function to create a smooth switch model.
The equation for such a smooth switch would be:
It was somewhat arbitrarily chosen to use a control signal that varied from zero to 1 volt. In that case, 'off' or offset equals 0.5V. In this case, 'a' must be equal to about 16 to get a close match to the desired value of Ron when x = 0, and Roff when x = 1. Additionally, there will be a small error term when x = 0. The term, -exp(a*(-off)) removes this error. This small error will also affect the value of y when x = 1, but typically it is a small percentage error, WHEREAS it is much more significant at the lower end of the function where the desired result is close to zero.
A test circuit that models this equation is shown in Figure 1 following:
STSNOT4 Test Circuit
In Figure 1 the switch is essentially represented by Generator B1, R3 and B2. The circuitry beneath the dashed line represent parameters that will later be passed to the parameterized switch circuit. The control voltage is represented by the voltage across resistor R1, along with its external to the switch generator V1.
V8 and R11 represent a source that is being switched by the STSNOT4 device (generator B2) which is between the nodes S1 and S2. The source and switch combination apply this 'chopped' voltage to what will be recognized as a Buck output filter and load. Here diode D2 is the flywheel diode for this filter. The filter is being operated in CCM (continuous conduction mode).
The switch equation, the B1 generator value, is:
v = v(Roff)*atan(exp(-v(a)*(v(x) -v(Offset))))/(2*atan(1)) + v(Ron)
Here the values which will be eventually passed to the model are clearly shown as Roff, a, Offset and Ron. A netlist for this circuit is:
Gud hanormal test 2.cpr
***** main circuit
V1 x 3 PULSE( 0.000000000000e+000 5.000000000000e+000 0.000000000000e+000 1.000000000000e-007 1.000000000000e-007 5.000000000000e-005 1.000000000000e-004)
R1 x 3 resistor 10Meg
R2 a 5 resistor 1K
R3 Gudax 0 resistor 10Meg
R4 3 0 resistor 10Meg
B1 Gudax 0 v = v(Roff)*atan(exp(v(a)*(v(x) -v(Offset))) -exp(-v(a)*v(Offset)))/(2*atan(1)) + v(Ron)
V2 a 5 1.600000000000e+001
R5 5 0 resistor 10Meg
V4 Offset 8 2.500000000000e+000
R6 Offset 8 resistor 1K
R7 8 0 resistor 10Meg
V6 Roff 0 1.000000000000e+008
V7 Ron 0 1.000000000000e-002
R8 Roff 0 resistor 1K
R9 Ron 0 resistor 1K
B2 S1 S2 i = v(S1,S2)/v(Gudax)
V8 12 0 2.000000000000e+001
L1 13 14 10m
C1 14 15 200u
R10 14 0 resistor 5
R11 S1 12 resistor .01
R12 S2 13 resistor 20m
R13 15 0 resistor 20m
D2 0 S2 mbrs340t3 off
.model resistor r res = 1
.model mbrs340t3 D is = 1.924e-05 rs = 0.03512 n = 1.034 tt = 1e-08 cjo = 4.92299e-10 vj = 0.451454
+ m = 0.443167 eg = 0.6 xti = 2 kf = 0 af = 1
+ fc = 0.5 bv = 100 ibv = 0.1
.TRAN 1E-6 0.1 0 1E-6 uic
.OPTIONS method = gear
A plot of the circuit performance is shown in the graph of the following Figure 2.
STSNOT4 Test Circuit graph
In Figure 2 we see the expected triangular waveform of inductor current (in red), the diode voltage in grey, and the output voltage in red.
Stripped of the test circuitry, the device to be modeled becomes as shown in Figure 3 following:
Figure 3 shows the simplicity of this device model. This should be added to the device library with a NO switch graphic symbol as a parameterized subcircuit device named STSNOT4. Additionally, one can create a STSNCT4 device model that is identical to that of the STSNOT4 device with the alteration of the B1 generator equation by changing the sign of 'a' in two places.
A smooth transition NO and NC switch model has been created using a modified Gudermannian function. Use of this device should eliminate some of the difficulties in using abrupt transition switches in many models.
1 Wikopedia Article, Gudermannian function:http://en.wikipedia.org/wiki/Gudermannian_function