Modelica.Electrical.Spice3.Sources

Time dependent SPICE3 voltage and current sources

Information


This package contains the SPICE sources.

Note: There are differences between SPICE3 and Modelica concerning the default values of the parameter. Therefore it is recommended to specify all parameters of the source.

Extends from Modelica.Icons.SourcesPackage (Icon for packages containing sources).

Package Content

NameDescription
Modelica.Electrical.Spice3.Sources.V_constant V_constant Constant independent voltage sources
Modelica.Electrical.Spice3.Sources.V_sin V_sin Sinusoidal voltage source
Modelica.Electrical.Spice3.Sources.V_exp V_exp Exponential voltage source
Modelica.Electrical.Spice3.Sources.V_pulse V_pulse Pulse voltage source
Modelica.Electrical.Spice3.Sources.V_pwl V_pwl Piece-wise linear voltage source
Modelica.Electrical.Spice3.Sources.V_sffm V_sffm Single-frequency FM voltage source
Modelica.Electrical.Spice3.Sources.I_constant I_constant Constant independent current sources
Modelica.Electrical.Spice3.Sources.I_sin I_sin Sinusoidal current source
Modelica.Electrical.Spice3.Sources.I_exp I_exp Exponential current source
Modelica.Electrical.Spice3.Sources.I_pulse I_pulse Pulse current source
Modelica.Electrical.Spice3.Sources.I_pwl I_pwl Piece-wise linear current source
Modelica.Electrical.Spice3.Sources.I_sffm I_sffm Single-frequency FM current source


Modelica.Electrical.Spice3.Sources.V_constant Modelica.Electrical.Spice3.Sources.V_constant

Constant independent voltage sources

Modelica.Electrical.Spice3.Sources.V_constant

Information


The V_constant source is a source is a simple constant voltage source for an ideal constant voltage which is provided by a parameter.

Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).

Parameters

TypeNameDefaultDescription
VoltageV1Value of constant voltage [V]

Connectors

TypeNameDescription
PositivePinpPositive pin (potential p.v > n.v for positive voltage drop v)
NegativePinnNegative pin

Modelica definition

model V_constant "Constant independent voltage sources"
  parameter SI.Voltage V=1 "Value of constant voltage";
  extends Modelica.Electrical.Analog.Interfaces.OnePort;
equation 
  v = V;
end V_constant;

Modelica.Electrical.Spice3.Sources.V_sin Modelica.Electrical.Spice3.Sources.V_sin

Sinusoidal voltage source

Modelica.Electrical.Spice3.Sources.V_sin

Information


Damped sinusoidal source

Note:

Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).

Parameters

TypeNameDefaultDescription
VoltageVO0.0Offset [V]
VoltageVA0.0Amplitude [V]
FrequencyFREQ Frequency [Hz]
TimeTD0.0Delay [s]
DampingTHETA0.0Damping factor [s-1]

Connectors

TypeNameDescription
PositivePinpPositive pin (potential p.v > n.v for positive voltage drop v)
NegativePinnNegative pin

Modelica definition

model V_sin "Sinusoidal voltage source"
  extends Modelica.Electrical.Analog.Interfaces.OnePort;
  parameter SI.Voltage VO=0.0 "Offset";
  parameter SI.Voltage VA=0.0 "Amplitude";
  parameter SI.Frequency FREQ(start=1) "Frequency";
  parameter SI.Time TD=0.0 "Delay";
  parameter SI.Damping THETA=0.0 "Damping factor";
protected 
    constant Real pi=Modelica.Constants.pi;
equation 
    assert(FREQ>0, "Frequency less or equal zero");
    v = VO + (if time < TD then 0 else VA*
    Modelica.Math.exp(-(time - TD)*THETA)*Modelica.Math.sin(2*pi
    *FREQ*(time - TD)));
end V_sin;

Modelica.Electrical.Spice3.Sources.V_exp Modelica.Electrical.Spice3.Sources.V_exp

Exponential voltage source

Modelica.Electrical.Spice3.Sources.V_exp

Information


Rising and falling exponential source.

Note:

Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).

Parameters

TypeNameDefaultDescription
VoltageV10Initial value [V]
VoltageV20Pulsed value [V]
TimeTD10.0Rise delay time [s]
TimeTAU11Rise time constant [s]
TimeTD21Fall delay time [s]
TimeTAU21Fall time constant [s]

Connectors

TypeNameDescription
PositivePinpPositive pin (potential p.v > n.v for positive voltage drop v)
NegativePinnNegative pin

Modelica definition

model V_exp "Exponential voltage source"
 extends Modelica.Electrical.Analog.Interfaces.OnePort;

  parameter SI.Voltage V1=0 "Initial value";
  parameter SI.Voltage V2=0 "Pulsed value";
  parameter SI.Time TD1=0.0 "Rise delay time";
  parameter SI.Time TAU1=1 "Rise time constant";
  parameter SI.Time TD2=1 "Fall delay time";
  parameter SI.Time TAU2=1 "Fall time constant";

equation 
v = V1 + (if (time < TD1) then 0 else if (time < (TD2)) then 
          (V2-V1)*(1 - Modelica.Math.exp(-(time - TD1)/TAU1)) else 
          (V2-V1)*(1 - Modelica.Math.exp(-(time - TD1)/TAU1)) +
          (V1-V2)*(1 - Modelica.Math.exp(-(time - TD2)/TAU2)));
end V_exp;

Modelica.Electrical.Spice3.Sources.V_pulse Modelica.Electrical.Spice3.Sources.V_pulse

Pulse voltage source

Modelica.Electrical.Spice3.Sources.V_pulse

Information


Periodic pulse source with not limited number of periods.

A single pulse is described by the following table:

time

value

0

V1

TD

V1

TD+TR

V2

TD+TR+PW

V2

TD+TR+PW+TF

V1

TSTOP

V1

Intermediate points are determined by linear interpolation.

A pulse it looks like a saw tooth, use this parameters e.g.:

Parameter

Value

V1

0

V2

1

TD

0

TR

1

TF

1

PW

2

PER

1

Note:

Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).

Parameters

TypeNameDefaultDescription
VoltageV10Initial value [V]
VoltageV20Pulsed value [V]
TimeTD0.0Delay time [s]
TimeTR Rise time [s]
TimeTFTRFall time [s]
TimePWModelica.Constants.infPulse width [s]
TimePERModelica.Constants.infPeriod [s]

Connectors

TypeNameDescription
PositivePinpPositive pin (potential p.v > n.v for positive voltage drop v)
NegativePinnNegative pin

Modelica definition

model V_pulse "Pulse voltage source"
extends Modelica.Electrical.Analog.Interfaces.OnePort;

  parameter SI.Voltage V1 = 0 "Initial value";
  parameter SI.Voltage V2 = 0 "Pulsed value";
  parameter SI.Time TD = 0.0 "Delay time";
  parameter SI.Time TR(start=1) "Rise time";
  parameter SI.Time TF = TR "Fall time";
  parameter SI.Time PW = Modelica.Constants.inf "Pulse width";
  parameter SI.Time PER= Modelica.Constants.inf "Period";

protected 
  parameter SI.Time Trising=TR "End time of rising phase within one period";
  parameter SI.Time Twidth=Trising + PW 
    "End time of width phase within one period";
  parameter SI.Time Tfalling=Twidth + TF 
    "End time of falling phase within one period";
  SI.Time T0(final start=TD) "Start time of current period";
  Integer counter(start=-1) "Period counter";
  Integer counter2(start=-1);

equation 
  when pre(counter2) <> 0 and sample(TD, PER) then
    T0 = time;
    counter2 = pre(counter);
    counter = pre(counter) - (if pre(counter) > 0 then 1 else 0);
  end when;
  v = V1 + (if (time < TD or counter2 == 0 or time >= T0 +
    Tfalling) then 0 else if (time < T0 + Trising) then (time - T0)*
    (V2-V1)/Trising else if (time < T0 + Twidth) then V2-V1 else 
    (T0 + Tfalling - time)*(V2-V1)/(Tfalling - Twidth));

end V_pulse;

Modelica.Electrical.Spice3.Sources.V_pwl Modelica.Electrical.Spice3.Sources.V_pwl

Piece-wise linear voltage source

Modelica.Electrical.Spice3.Sources.V_pwl

Information


This model generates a voltage by linear interpolation in a given table. The time points and voltage values are stored in a matrix table[i,j], where the first column table[:,1] contains the time points and the second column contains the voltage to be interpolated. The table interpolation has the following proporties:

Example:

   table = [0  0
            1  0
            1  1
            2  4
            3  9
            4 16]
If, e.g., time = 1.0, the voltage v =  0.0 (before event), 1.0 (after event)
    e.g., time = 1.5, the voltage v =  2.5,
    e.g., time = 2.0, the voltage v =  4.0,
    e.g., time = 5.0, the voltage v = 23.0 (i.e., extrapolation).

Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).

Parameters

TypeNameDefaultDescription
Realtable[:, :][0, 0; 1, 1; 2, 4]Table matrix (time = first column, voltage = second column)

Connectors

TypeNameDescription
PositivePinpPositive pin (potential p.v > n.v for positive voltage drop v)
NegativePinnNegative pin

Modelica definition

model V_pwl "Piece-wise linear voltage source"
  extends Modelica.Electrical.Analog.Interfaces.OnePort;
  parameter Real table[:, :]=[0, 0; 1, 1; 2, 4] 
    "Table matrix (time = first column, voltage = second column)";
  Modelica.Blocks.Sources.TimeTable tab(table=table);
equation 
  v = tab.y;
end V_pwl;

Modelica.Electrical.Spice3.Sources.V_sffm Modelica.Electrical.Spice3.Sources.V_sffm

Single-frequency FM voltage source

Modelica.Electrical.Spice3.Sources.V_sffm

Information


The single-frequency frequency modulation source generates a carrier signal of the frequency FC. This signal is modulated by the signal frequency FS. See the formula in the modelica text.

Attention:

Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).

Parameters

TypeNameDefaultDescription
VoltageVO0Offset [V]
VoltageVA0Amplitude [V]
FrequencyFC Carrier frequency [Hz]
RealMDI0Modulation index
FrequencyFSFCSingnal frequency [Hz]

Connectors

TypeNameDescription
PositivePinpPositive pin (potential p.v > n.v for positive voltage drop v)
NegativePinnNegative pin

Modelica definition

model V_sffm "Single-frequency FM voltage source"
  extends Modelica.Electrical.Analog.Interfaces.OnePort;
  parameter SI.Voltage VO = 0 "Offset";
  parameter SI.Voltage VA = 0 "Amplitude";
  parameter SI.Frequency FC( start=0) "Carrier frequency";
  parameter Real MDI=0 "Modulation index";
  parameter SI.Frequency FS= FC "Singnal frequency";
protected 
    constant Real pi=Modelica.Constants.pi;
equation 
  v = VO + VA *Modelica.Math.sin( 2 *pi * FC *time + MDI *Modelica.Math.sin(2 *pi *FS *time));
end V_sffm;

Modelica.Electrical.Spice3.Sources.I_constant Modelica.Electrical.Spice3.Sources.I_constant

Constant independent current sources

Modelica.Electrical.Spice3.Sources.I_constant

Information


The I_constant source is a simple constant current source for an ideal constant current which is provided by a parameter.

Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).

Parameters

TypeNameDefaultDescription
CurrentI1Value of constant voltage [A]

Connectors

TypeNameDescription
PositivePinpPositive pin (potential p.v > n.v for positive voltage drop v)
NegativePinnNegative pin

Modelica definition

model I_constant "Constant independent current sources"
   parameter SI.Current I=1 "Value of constant voltage";
   extends Modelica.Electrical.Analog.Interfaces.OnePort;
equation 
   i = I;
end I_constant;

Modelica.Electrical.Spice3.Sources.I_sin Modelica.Electrical.Spice3.Sources.I_sin

Sinusoidal current source

Modelica.Electrical.Spice3.Sources.I_sin

Information


Damped sinusoidal source

Note:

Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).

Parameters

TypeNameDefaultDescription
CurrentIO0Offset [A]
CurrentIA0Amplitude [A]
FrequencyFREQ Frequency [Hz]
TimeTD0.0Delay [s]
DampingTHETA0.0Damping factor [s-1]

Connectors

TypeNameDescription
PositivePinpPositive pin (potential p.v > n.v for positive voltage drop v)
NegativePinnNegative pin

Modelica definition

model I_sin "Sinusoidal current source"

  extends Modelica.Electrical.Analog.Interfaces.OnePort;
  parameter SI.Current IO=0 "Offset";
  parameter SI.Current IA=0 "Amplitude";
  parameter SI.Frequency FREQ(start=1) "Frequency";
  parameter SI.Time TD=0.0 "Delay";
  parameter SI.Damping THETA=0.0 "Damping factor";
protected 
    constant Real pi=Modelica.Constants.pi;
equation 
    assert(FREQ>0, "Frequency less or equal zero");
    i = IO + (if time < TD then 0 else IA*
    Modelica.Math.exp(-(time - TD)*THETA)*Modelica.Math.sin(2*pi
    *FREQ*(time - TD)));
end I_sin;

Modelica.Electrical.Spice3.Sources.I_exp Modelica.Electrical.Spice3.Sources.I_exp

Exponential current source

Modelica.Electrical.Spice3.Sources.I_exp

Information


Rising and falling exponential source.

Note:

Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).

Parameters

TypeNameDefaultDescription
CurrentI10Initial value [A]
CurrentI20Pulsed value [A]
TimeTD10.0Rise delay time [s]
TimeTAU11Rise time constant [s]
TimeTD22Fall delay time [s]
TimeTAU21Fall time constant [s]

Connectors

TypeNameDescription
PositivePinpPositive pin (potential p.v > n.v for positive voltage drop v)
NegativePinnNegative pin

Modelica definition

model I_exp "Exponential current source"
extends Modelica.Electrical.Analog.Interfaces.OnePort;
  parameter SI.Current I1=0 "Initial value";
  parameter SI.Current I2=0 "Pulsed value";
  parameter SI.Time TD1=0.0 "Rise delay time";
  parameter SI.Time TAU1=1 "Rise time constant";
  parameter SI.Time TD2=2 "Fall delay time";
  parameter SI.Time TAU2=1 "Fall time constant";
equation 
i = I1 + (if (time < TD1) then 0 else if (time < (TD2)) then 
          (I2-I1)*(1 - Modelica.Math.exp(-(time - TD1)/TAU1)) else 
          (I2-I1)*(1 - Modelica.Math.exp(-(time - TD1)/TAU1)) +
          (I1-I2)*(1 - Modelica.Math.exp(-(time - TD2)/TAU2)));
end I_exp;

Modelica.Electrical.Spice3.Sources.I_pulse Modelica.Electrical.Spice3.Sources.I_pulse

Pulse current source

Modelica.Electrical.Spice3.Sources.I_pulse

Information


Periodic pulse source with not limited number of periods.

A single pulse is described by the following table:

time

value

0

I1

TD

I1

TD+TR

I2

TD+TR+PW

I2

TD+TR+PW+TF

I1

TSTOP

I1

Intermediate points are determined by linear interpolation.

A pulse it looks like a saw tooth, use this parameters e.g.:

Parameter

Value

I1

0

I2

1

TD

0

TR

1

TF

1

PW

2

PER

1

Note:

Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).

Parameters

TypeNameDefaultDescription
CurrentI10Initial value [A]
CurrentI20Pulsed value [A]
TimeTD0.0Delay time [s]
TimeTR Rise time [s]
TimeTFTRFall time [s]
TimePWModelica.Constants.infPulse width [s]
TimePERModelica.Constants.infPeriod [s]

Connectors

TypeNameDescription
PositivePinpPositive pin (potential p.v > n.v for positive voltage drop v)
NegativePinnNegative pin

Modelica definition

model I_pulse "Pulse current source"
 extends Modelica.Electrical.Analog.Interfaces.OnePort;

  parameter SI.Current I1 = 0 "Initial value";
  parameter SI.Current I2 = 0 "Pulsed value";
  parameter SI.Time TD = 0.0 "Delay time";
  parameter SI.Time TR(start=1) "Rise time";
  parameter SI.Time TF = TR "Fall time";
  parameter SI.Time PW = Modelica.Constants.inf "Pulse width";
  parameter SI.Time PER= Modelica.Constants.inf "Period";

protected 
  parameter SI.Time Trising=TR "End time of rising phase within one period";
  parameter SI.Time Twidth=Trising + PW 
    "End time of width phase within one period";
  parameter SI.Time Tfalling=Twidth + TF 
    "End time of falling phase within one period";
  SI.Time T0(final start=TD) "Start time of current period";
  Integer counter(start=-1) "Period counter";
  Integer counter2(start=-1);

equation 
  when pre(counter2) <> 0 and sample(TD, PER) then
    T0 = time;
    counter2 = pre(counter);
    counter = pre(counter) - (if pre(counter) > 0 then 1 else 0);
  end when;
  i = I1 + (if (time < TD or counter2 == 0 or time >= T0 +
    Tfalling) then 0 else if (time < T0 + Trising) then (time - T0)*
    (I2-I1)/Trising else if (time < T0 + Twidth) then I2-I1 else 
    (T0 + Tfalling - time)*(I2-I1)/(Tfalling - Twidth));

end I_pulse;

Modelica.Electrical.Spice3.Sources.I_pwl Modelica.Electrical.Spice3.Sources.I_pwl

Piece-wise linear current source

Modelica.Electrical.Spice3.Sources.I_pwl

Information


This model generates a current by linear interpolation in a given table. The time points and current values are stored in a matrix table[i,j], where the first column table[:,1] contains the time points and the second column contains the current to be interpolated. The table interpolation has the following proporties:

Example:

   table = [0  0
            1  0
            1  1
            2  4
            3  9
            4 16]
If, e.g., time = 1.0, the current i =  0.0 (before event), 1.0 (after event)
    e.g., time = 1.5, the current i =  2.5,
    e.g., time = 2.0, the current i =  4.0,
    e.g., time = 5.0, the current i = 23.0 (i.e., extrapolation).

Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).

Parameters

TypeNameDefaultDescription
Realtable[:, :][0, 0; 1, 1; 2, 4]Table matrix (time = first column, voltage = second column)

Connectors

TypeNameDescription
PositivePinpPositive pin (potential p.v > n.v for positive voltage drop v)
NegativePinnNegative pin

Modelica definition

model I_pwl "Piece-wise linear current source"
   extends Modelica.Electrical.Analog.Interfaces.OnePort;
  parameter Real table[:, :]=[0, 0; 1, 1; 2, 4] 
    "Table matrix (time = first column, voltage = second column)";
  Modelica.Blocks.Sources.TimeTable tab(table=table);

equation 
  i = tab.y;

end I_pwl;

Modelica.Electrical.Spice3.Sources.I_sffm Modelica.Electrical.Spice3.Sources.I_sffm

Single-frequency FM current source

Modelica.Electrical.Spice3.Sources.I_sffm

Information


The single-frequency frequency modulation source generates a carrier signal of the frequency FC. This signal is modulated by the signal frequency FS. See the formula in the modelica text.

Note:

Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).

Parameters

TypeNameDefaultDescription
CurrentIO0Offset [A]
CurrentIA0Amplitude [A]
FrequencyFC Carrier frequency [Hz]
RealMDI0Modulation index
FrequencyFSFCSingnal frequency [Hz]

Connectors

TypeNameDescription
PositivePinpPositive pin (potential p.v > n.v for positive voltage drop v)
NegativePinnNegative pin

Modelica definition

model I_sffm "Single-frequency FM current source"
  extends Modelica.Electrical.Analog.Interfaces.OnePort;
  parameter SI.Current IO = 0 "Offset";
  parameter SI.Current IA = 0 "Amplitude";
  parameter SI.Frequency FC( start=0) "Carrier frequency";
  parameter Real MDI=0 "Modulation index";
  parameter SI.Frequency FS= FC "Singnal frequency";

protected 
    constant Real pi=Modelica.Constants.pi;
equation 
  i = IO + IA *Modelica.Math.sin( 2 *pi * FC *time + MDI *Modelica.Math.sin(2 *pi *FS *time));
end I_sffm;

Automatically generated Fri Nov 12 16:29:46 2010.