Skip to content

Transient sources

Luca Giaccone edited this page Nov 19, 2017 · 2 revisions

SpicePy handles the following transient sources:

  1. PWL: piecewise linear waveform
  2. PULSE: pulsed waveform
  3. SIN: damped sinusoidal waveform
  4. EXP: exponential waveform

Each waveform can be associated to an independent voltage generator or an independent current generator.

PWL

The PWL waveform can be defined using the following syntax:

pwl(T1 Val1 T2 Val2 <T3 Val3 T4 Val4 ...>)

where:

  • Tx is a time instant (x=1, 2, 3, ...)
  • Valx is the value of the function at time Tx (x=1, 2, 3, ...)

At leat two time-value pairs (T1-Val1 and T2-Val2) must be provided. The other pairs are optional. Below T1 the value is set to Val1 and above T2 the value is set to Val2.

The following generator in a netlist:

V1 1 0 pwl(0 1 10e-3 4 40e-3 4 60e-3 0.5 100e-3 0.5)

defines the voltage between nodes 1 and 0 in the figure below.

PULSE

The PULSE waveform can be defined using the following syntax:

pulse(Val1 Val2 <Td Tr Tf Pw Period>)

where:

  • Val1 is the low value
  • Val2 is the high value
  • Td is rise time delay (s) (optional. Default is zero)
  • Tr rise time (s) (optional. Default is time-step)
  • Tf fall time (s) (optional. Default is td1 + time_step)
  • Pw pulse width (s) (default is the end of the simulation)
  • Period period of the waveform (s) (default is the end of the simulation)

The waveform value is:

  • Val1 for t < Td
  • linear ramp from Val1 to Val2 for Td < t < Td + Tr
  • Val2 for Td + Tr < t < Td + Tr + Pw
  • linear ramp from Val2 to Val1 for Td + Tr + Pw < t < Td + Tr + Pw + Tf
  • Val2 for Td + Tr + Pw + Tf < t < (Period - Td + Tr + Pw + Tf)

The following generator in a netlist:

I2 3 4 pulse(1 5 10e-3 2e-3 5e-3 20e-3 40e-3)

defines the current from nodes 3 to 4 in the figure below.

SIN

The SIN waveform can be defined using the following syntax:

sin(V0 Va <freq Td Df Phase>)

where:

  • V0is the offset
  • Vais the amplitude
  • freq is the frequency (Hz) (optional. Default is 1/tstop)
  • Td is the delay (s)
  • Df is the damping factor (1/s)
  • Phase is the phase (deg)

The waveform value is :

  • Vo + Va * sin(Phase) for t < Td
  • Vo + Va * sin(2 * PI * freq * (t - Td) + Phase) * exp(-(t - Td) * Df) for t < Td for t > Td

The following generator in a netlist:

V3 A B sin(0 1 10e-3 4 40e-3 4 60e-3 0.5 100e-3 0.5)

defines the voltage between nodes A and B in the figure below.

EXP

The EXP waveform can be defined using the following syntax:

exp(Val1 Val2 <Td1 tau1 Td2 tau2>)

where:

  • Val1: initial value
  • Val2: peak value
  • Td1: rise time delay (s)
  • tau1: rise time constant (s)
  • Td2: fall time delay (s)
  • tau2: fall time constant (s)

The waveform value is:

  • Val1 for t < Td1
  • from Val1 to Val2 with exponential decay (time constant tau1) for Td1 < t < Td2 (if Td2 < 5*T1 the voltage reaches V(Td2) < Val2)
  • from Val2 to Val1 with exponential decay (time constant tau2) for t > Td2 (if V(Td2) < V2 the exponential decay is from V(Td2) to Val1)

The following generator in a netlist:

I4 C D sin(-3 4 10e-3 2e-3 50e-3 10e-3)

defines the current from nodes C to B in the figure below.