Analog behavioral modelling (ABM) allows designers to implement their own devices when only first order effects are necessary. In-line equation syntax differs from editor to editor. IsSpice4 uses the original Berkeley B elements, while PSpice has modified the standard E/G sources to either generate voltage or current. Although the style is different, the results are similar. To use these equations without falling into “syntax error” traps, a brief review is necessary. Let's begin with simple multiplications:
IsSpice4: B1 1 0 V=V(2,3)×4; multiply voltage of V(2,3) by 4 and deliver voltage
B1 1 0 I=I(V1)×5; the current flowing through V1 is multiplied by 5
PSpice: E1 1 0 Value={ V(2,3)×4}
G1 1 0 Value={ I(V1)×5 }
More complicated equations involving mathematical functions can be written here like a simple 100 kHz oscillator where the keyword time represents the simulation internal timer:
IsSpice4: B1 1 0 V=2×sin (time×100k×6.28)
PSpice: E1 1 0 value={2×sin (time×100k×6.28)}
Use if-then-else expressions as the real basis when you write your own models including logical operations:
IsSpice4: B1 1 0 V=V(plus)> V(minus)? 10 : 100m; the simplest comparator
PSpice: E1 1 0 Value={if (V(plus) >V(minus), 10, 100m)}
You read this as: if V(plus) is greater than V(minus), then V(1,0) =10V else V(1,0)=100mV. Those perfect generators toggle in a zero time span. It's good practice to slow down their output by inserting an RC network (e.g. 10Ω/100pF) before connecting them to other elements.
More complicated expressions are possible, nesting two expressions into one line — e.g. for a limiter that clamps a voltage between 5V and 100mV:
IsSpice4: B1 1 0 V=V(3)>5 ? 5 : V(3)<100m ? 100m : V(3)
PSpice: E1 1 0 Value={if (V(3)> 5, 5, if (V(3)<100m, 100m, V(3)))}
PSpice: E1 1 0 Value={limit (V(3), 5,100m)}
You read this as: If V(3) is greater than 5V, then V(1,0)=5V else if V(3) is less than 100mV, then V(1,0) =100mV else V(1,0)=V(3).
If IsSpice4 needs no parentheses, PSpice does and the parser will notify you if you position them improperly.
IsSpice4: B1 69 14 V=V(27,14)> V(18,14)/2 ? V(18,14) : V(26,14)>0.44 ?
+ V(18,14) :
(V(13,14)+V(26,14)+V(12,14)) > V(31,14) ? V(18,14) : 0
PSpice: E1 69 14 Value={if (V(27,14) > V(18,14)/2, V(18,14), if ( V(26,14) > 0.44, + V(18,14), if ((V(13,14)+V(26,14)+V(12,14)) > V(31,14), V(18,14), 0 ) ) )}
IsSpice4 accepts parameter passing for SPICE primitives like E or G; however, PSpice doesn't. Thus, you must adapt them with a VALUE keyword:
IsSpice: E1 1 2 3 4 { gain }
G1 1 2 3 4 { gm }
Pspice: E1 1 2 Value ={V(3,4) × gain}
G1 1 2 Value={ V(3,4)×gm }
To illustrate in-line equations, use the input-to-output transfer ratio of a BOOST converter operating in continuous conduction mode (CCM), which is affected by some ohmic losses. The traditional equation states:
Where:
D'=1 — D
Rlf=inductor series resistance
Rload the converter load.
An interesting exercise is to sweep the duty-cycle D for different ratios
Fig. 1 shows how to implement this equation via a simple in-line equation, whereas the duty-cycle is obtained using the current simulator time in seconds and bounded below 1 for a 100µs run. When sweeping the ratio parameter, the Fig. 2 family of curves shows the standard BOOST behavior, where latch-up takes place sooner for lossy inductors.
For more information on this article, CIRCLE 339 on Reader Service Card