## Modelica.Electrical.Analog.Sources

### Information

This package contains time-dependend and controlled voltage and current sources.

Main Authors:
  Christoph Clauß <clauss@eas.iis.fhg.de>
  André Schneider <schneider@eas.iis.fhg.de>
  Fraunhofer Institute for Integrated Circuits
  Design Automation Department
  Zeunerstraße 38
  D-01069 Dresden

Version:
  $Id: Modelica_Electrical_Analog_Sources.html,v 1.10 2002/12/18 08:44:19 Hans Exp $

Copyright:
  Copyright © 1998-2002, Modelica Association and Fraunhofer-Gesellschaft.
  The Modelica package is free software; it can be redistributed and/or modified under the terms of the Modelica license, see the license conditions and the accompanying disclaimer in the documentation of package Modelica in file "Modelica/package.mo".

## Modelica.Electrical.Analog.Sources.TrapezoidVoltage

Trapezoidal voltage source

### Parameters

Name | Default | Description
--- | --- | ---
V | 1 | Amplitude of trapezoid [V]
rising | 0 | Rising duration of trapezoid [s]
width | 0.5 | Width duration of trapezoid [s]
falling | 0 | Falling duration of trapezoid [s]
period | 1 | Time for one period [s]
nperiod | -1 | Number of periods (< 0 means infinite number of periods)
offset | 0 | Voltage offset [V]
startTime | 0 | Time offset [s]

### Modelica definition

    model TrapezoidVoltage "Trapezoidal voltage source"
      parameter SI.Voltage V=1 "Amplitude of trapezoid";
      parameter SI.Time rising(final min=0) = 0 "Rising duration of trapezoid";
      parameter SI.Time width(final min=0) = 0.5 "Width duration of trapezoid";
      parameter SI.Time falling(final min=0) = 0 "Falling duration of trapezoid";
      parameter SI.Time period(final min=Modelica.Constants.small) = 1
        "Time for one period";
      parameter Integer nperiod=-1
        "Number of periods (< 0 means infinite number of periods)";
      extends Interfaces.VoltageSource(redeclare Modelica.Blocks.Sources.Trapezoid signalSource(
          amplitude={V},
          rising={rising},
          width={width},
          falling={falling},
          period={period},
          nperiod={nperiod}));
    end TrapezoidVoltage;

## Modelica.Electrical.Analog.Sources.ExpSineVoltage

Exponentially damped sine voltage source

### Parameters

Name | Default | Description
--- | --- | ---
V | 1 | Amplitude of sine wave [V]
freqHz | 2 | Frequency of sine wave [Hz]
phase | 0 | Phase of sine wave [rad]
damping | 1 | Damping coefficient of sine wave [s-1]
offset | 0 | Voltage offset [V]
startTime | 0 | Time offset [s]

### Modelica definition

    model ExpSineVoltage "Exponentially damped sine voltage source"
      parameter SI.Voltage V=1 "Amplitude of sine wave";
      parameter SI.Frequency freqHz=2 "Frequency of sine wave";
      parameter SI.Angle phase=0 "Phase of sine wave";
      parameter SI.Damping damping=1 "Damping coefficient of sine wave";
      extends Interfaces.VoltageSource(redeclare Modelica.Blocks.Sources.ExpSine signalSource(
          amplitude={V},
          freqHz={freqHz},
          phase={phase},
          damping={damping}));
    end ExpSineVoltage;

## Modelica.Electrical.Analog.Sources.RampVoltage

Ramp voltage source

### Parameters

Name | Default | Description
--- | --- | ---
V | 1 | Height of ramp [V]
duration | 2 | Duration of ramp [s]
offset | 0 | Voltage offset [V]
startTime | 0 | Time offset [s]

### Modelica definition

    model RampVoltage "Ramp voltage source"
      parameter SI.Voltage V=1 "Height of ramp";
      parameter SI.Time duration(min=Modelica.Constants.small) = 2 "Duration of ramp";
      extends Interfaces.VoltageSource(redeclare Modelica.Blocks.Sources.Ramp signalSource(final height={V}, final duration
            ={duration}));
    end RampVoltage;

## Modelica.Electrical.Analog.Sources.RampCurrent

Ramp current source

### Parameters

Name | Default | Description
--- | --- | ---
I | 1 | Height of ramp [A]
duration | 2 | Duration of ramp [s]
offset | 0 | Current offset [A]
startTime | 0 | Time offset [s]

### Modelica definition

    model RampCurrent "Ramp current source"
      parameter SI.Current I=1 "Height of ramp";
      parameter SI.Time duration(min=Modelica.Constants.small) = 2 "Duration of ramp";
      extends Interfaces.CurrentSource(redeclare Modelica.Blocks.Sources.Ramp signalSource(final height={I}, final duration
            ={duration}));
    end RampCurrent;

## Modelica.Electrical.Analog.Sources.SignalVoltage

Generic voltage source using the input signal as source voltage

### Modelica definition

    model SignalVoltage
      "Generic voltage source using the input signal as source voltage"
      extends Interfaces.OnePort;

      Modelica.Blocks.Interfaces.InPort inPort(final n=1);
    equation
      inPort.signal[1] = v;
    end SignalVoltage;

## Modelica.Electrical.Analog.Sources.ConstantVoltage

Source for constant voltage

### Parameters

Name | Default | Description
--- | --- | ---
V | 1 | Value of constant voltage [V]

### Modelica definition

    model ConstantVoltage "Source for constant voltage"
      parameter SI.Voltage V=1 "Value of constant voltage";
      extends Interfaces.OnePort;
    equation
      v = V;
    end ConstantVoltage;

## Modelica.Electrical.Analog.Sources.StepVoltage

Step voltage source

### Parameters

Name | Default | Description
--- | --- | ---
V | 1 | Height of step [V]
offset | 0 | Voltage offset [V]
startTime | 0 | Time offset [s]

### Modelica definition

    model StepVoltage "Step voltage source"
      parameter SI.Voltage V=1 "Height of step";
      extends Interfaces.VoltageSource(redeclare Modelica.Blocks.Sources.Step signalSource(height={V}));
    end StepVoltage;

## Modelica.Electrical.Analog.Sources.SineVoltage

Sine voltage source

### Parameters

Name | Default | Description
--- | --- | ---
V | 1 | Amplitude of sine wave [V]
phase | 0 | Phase of sine wave [rad]
freqHz | 1 | Frequency of sine wave [Hz]
offset | 0 | Voltage offset [V]
startTime | 0 | Time offset [s]

### Modelica definition

    model SineVoltage "Sine voltage source"
      parameter SI.Voltage V=1 "Amplitude of sine wave";
      parameter SI.Angle phase=0 "Phase of sine wave";
      parameter SI.Frequency freqHz=1 "Frequency of sine wave";
      extends Interfaces.VoltageSource(redeclare Modelica.Blocks.Sources.Sine signalSource(
          amplitude={V},
          freqHz={freqHz},
          phase={phase}));
    end SineVoltage;

## Modelica.Electrical.Analog.Sources.ExponentialsVoltage

Rising and falling exponential voltage source

### Parameters

Name | Default | Description
--- | --- | ---
vMax | 1 | Upper bound for rising edge
riseTime | 0.5 | Rise time [s]
riseTimeConst | 0.1 | Rise time constant [s]
fallTimeConst | riseTimeConst | Fall time constant [s]
offset | 0 | Voltage offset [V]
startTime | 0 | Time offset [s]

### Modelica definition

    model ExponentialsVoltage
      " Rising and falling exponential voltage source"
      parameter Real vMax=1 "Upper bound for rising edge";
      parameter SI.Time riseTime(min=0) = 0.5 "Rise time";
      parameter SI.Time riseTimeConst(min=Modelica.Constants.small) = 0.1
        "Rise time constant";
      parameter SI.Time fallTimeConst(min=Modelica.Constants.small) = riseTimeConst
        "Fall time constant";
      extends Interfaces.VoltageSource(redeclare Modelica.Blocks.Sources.Exponentials signalSource(
          outMax={vMax},
          riseTime={riseTime},
          riseTimeConst={riseTimeConst},
          fallTimeConst={fallTimeConst}));
    end ExponentialsVoltage;

## Modelica.Electrical.Analog.Sources.PulseVoltage

Pulse voltage source

### Parameters

Name | Default | Description
--- | --- | ---
V | 1 | Amplitude of pulse [V]
width | 50 | Width of pulse in % of period
period | 1 | Time for one period [s]
offset | 0 | Voltage offset [V]
startTime | 0 | Time offset [s]

### Modelica definition

    model PulseVoltage "Pulse voltage source"
      parameter SI.Voltage V=1 "Amplitude of pulse";
      parameter Real width(
        final min=Modelica.Constants.small,
        final max=100) = 50 "Width of pulse in % of period";
      parameter SI.Time period(final min=Modelica.Constants.small) = 1
        "Time for one period";
      extends Interfaces.VoltageSource(redeclare Modelica.Blocks.Sources.Pulse signalSource(
          amplitude={V},
          width={width},
          period={period}));
    end PulseVoltage;

## Modelica.Electrical.Analog.Sources.SawToothVoltage

Saw tooth voltage source

### Parameters

Name | Default | Description
--- | --- | ---
V | 1 | Amplitude of saw tooth [V]
period | 1 | Time for one period [s]
offset | 0 | Voltage offset [V]
startTime | 0 | Time offset [s]

### Modelica definition

    model SawToothVoltage "Saw tooth voltage source"
      parameter SI.Voltage V=1 "Amplitude of saw tooth";
      parameter SI.Time period=1 "Time for one period";
      extends Interfaces.VoltageSource(redeclare Modelica.Blocks.Sources.SawTooth signalSource(amplitude={V}, period={
              period}));
    end SawToothVoltage;

## Modelica.Electrical.Analog.Sources.TableVoltage

Voltage source by linear interpolation in a table

### Information

This block generates a voltage source by linear interpolation in a 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:

- The time points need to be monotonically increasing.
- Discontinuities are allowed, by providing the same time point twice in the table.
- Values outside of the table range, are computed by extrapolation through the last or first two points of the table.
- If the table has only one row, no interpolation is performed and the voltage value is just returned independantly of the actual time instant, i.e., this is a constant voltage source.
- Via parameters startTime and offset the curve defined by the table can be shifted both in time and in the voltage.
- The table is implemented in a numerically sound way by generating time events at interval boundaries, in order to not integrate over a discontinuous or not differentiable points.

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).

### Parameters

Name | Default | Description
--- | --- | ---
table[:, :] | [0, 0; 1, 1; 2, 4] | Table matrix (time = first column, voltage = second column)
offset | 0 | Voltage offset [V]
startTime | 0 | Time offset [s]

### Modelica definition

    model TableVoltage
      "Voltage source by linear interpolation in a table"
      parameter Real table[:, :]=[0, 0; 1, 1; 2, 4]
        "Table matrix (time = first column, voltage = second column)";
      extends Interfaces.VoltageSource(redeclare Modelica.Blocks.Sources.TimeTable signalSource(table=table));
    end TableVoltage;

## Modelica.Electrical.Analog.Sources.SignalCurrent

Generic current source using the input signal as source current

### Modelica definition

    model SignalCurrent
      "Generic current source using the input signal as source current"
      extends Interfaces.OnePort;

      Modelica.Blocks.Interfaces.InPort inPort(final n=1);
    equation
      i = inPort.signal[1];
    end SignalCurrent;

## Modelica.Electrical.Analog.Sources.ConstantCurrent

Source for constant current

### Parameters

Name | Default | Description
--- | --- | ---
I | 1 | Value of constant current [A]

### Modelica definition

    model ConstantCurrent "Source for constant current"
      parameter SI.Current I=1 "Value of constant current";
      extends Interfaces.OnePort;
    equation
      i = I;
    end ConstantCurrent;

## Modelica.Electrical.Analog.Sources.StepCurrent

Step current source

### Parameters

Name | Default | Description
--- | --- | ---
I | 1 | Height of step [A]
offset | 0 | Current offset [A]
startTime | 0 | Time offset [s]

### Modelica definition

    model StepCurrent "Step current source"
      parameter SI.Current I=1 "Height of step";
      extends Interfaces.CurrentSource(redeclare Modelica.Blocks.Sources.Step signalSource(height={I}));
    end StepCurrent;

## Modelica.Electrical.Analog.Sources.SineCurrent

Sine current source

### Parameters

Name | Default | Description
--- | --- | ---
I | 1 | Amplitude of sine wave [A]
phase | 0 | Phase of sine wave [rad]
freqHz | 1 | Frequency of sine wave [Hz]
offset | 0 | Current offset [A]
startTime | 0 | Time offset [s]

### Modelica definition

    model SineCurrent "Sine current source"
      parameter SI.Current I=1 "Amplitude of sine wave";
      parameter SI.Angle phase=0 "Phase of sine wave";
      parameter SI.Frequency freqHz=1 "Frequency of sine wave";
      extends Interfaces.CurrentSource(redeclare Modelica.Blocks.Sources.Sine signalSource(
          amplitude={I},
          freqHz={freqHz},
          phase={phase}));
    end SineCurrent;

## Modelica.Electrical.Analog.Sources.ExpSineCurrent

Exponentially damped sine current source

### Parameters

Name | Default | Description
--- | --- | ---
I | 1 | Amplitude of sine wave
freqHz | 2 | Frequency of sine wave [Hz]
phase | 0 | Phase of sine wave [rad]
damping | 1 | Damping coefficient of sine wave [s-1]
offset | 0 | Current offset [A]
startTime | 0 | Time offset [s]

### Modelica definition

    model ExpSineCurrent "Exponentially damped sine current source"
      parameter Real I=1 "Amplitude of sine wave";
      parameter SI.Frequency freqHz=2 "Frequency of sine wave";
      parameter SI.Angle phase=0 "Phase of sine wave";
      parameter SI.Damping damping=1 "Damping coefficient of sine wave";
      extends Interfaces.CurrentSource(redeclare Modelica.Blocks.Sources.ExpSine signalSource(
          amplitude={I},
          freqHz={freqHz},
          phase={phase},
          damping={damping}));
    end ExpSineCurrent;

## Modelica.Electrical.Analog.Sources.ExponentialsCurrent

Rising and falling exponential current source

### Parameters

Name | Default | Description
--- | --- | ---
iMax | 1 | Upper bound for rising edge
riseTime | 0.5 | Rise time [s]
riseTimeConst | 0.1 | Rise time constant [s]
fallTimeConst | riseTimeConst | Fall time constant [s]
offset | 0 | Current offset [A]
startTime | 0 | Time offset [s]

### Modelica definition

    model ExponentialsCurrent
      " Rising and falling exponential current source"
      parameter Real iMax=1 "Upper bound for rising edge";
      parameter SI.Time riseTime(min=0) = 0.5 "Rise time";
      parameter SI.Time riseTimeConst(min=Modelica.Constants.small) = 0.1
        "Rise time constant";
      parameter SI.Time fallTimeConst(min=Modelica.Constants.small) = riseTimeConst
        "Fall time constant";
      extends Interfaces.CurrentSource(redeclare Modelica.Blocks.Sources.Exponentials signalSource(
          outMax={iMax},
          riseTime={riseTime},
          riseTimeConst={riseTimeConst},
          fallTimeConst={fallTimeConst}));
    end ExponentialsCurrent;

## Modelica.Electrical.Analog.Sources.PulseCurrent

Pulse current source

### Parameters

Name | Default | Description
--- | --- | ---
I | 1 | Amplitude of pulse [A]
width | 50 | Width of pulse in % of period
period | 1 | Time for one period [s]
offset | 0 | Current offset [A]
startTime | 0 | Time offset [s]

### Modelica definition

    model PulseCurrent "Pulse current source"
      parameter SI.Current I=1 "Amplitude of pulse";
      parameter Real width(
        final min=Modelica.Constants.small,
        final max=100) = 50 "Width of pulse in % of period";
      parameter SI.Time period(final min=Modelica.Constants.small) = 1
        "Time for one period";
      extends Interfaces.CurrentSource(redeclare Modelica.Blocks.Sources.Pulse signalSource(
          amplitude={I},
          width={width},
          period={period}));
    end PulseCurrent;

## Modelica.Electrical.Analog.Sources.SawToothCurrent

Saw tooth current source

### Parameters

Name | Default | Description
--- | --- | ---
I | 1 | Amplitude of saw tooth [A]
period | 1 | Time for one period [s]
offset | 0 | Current offset [A]
startTime | 0 | Time offset [s]

### Modelica definition

    model SawToothCurrent "Saw tooth current source"
      parameter SI.Current I=1 "Amplitude of saw tooth";
      parameter SI.Time period=1 "Time for one period";
      extends Interfaces.CurrentSource(redeclare Modelica.Blocks.Sources.SawTooth signalSource(amplitude={I}, period={
              period}));
    end SawToothCurrent;

## Modelica.Electrical.Analog.Sources.TrapezoidCurrent

Trapezoidal current source

### Parameters

Name | Default | Description
--- | --- | ---
I | 1 | Amplitude of trapezoid [A]
rising | 0 | Rising duration of trapezoid [s]
width | 0.5 | Width duration of trapezoid [s]
falling | 0 | Falling duration of trapezoid [s]
period | 1 | Time for one period [s]
nperiod | -1 | Number of periods (< 0 means infinite number of periods)
offset | 0 | Current offset [A]
startTime | 0 | Time offset [s]

### Modelica definition

    model TrapezoidCurrent "Trapezoidal current source"
      parameter SI.Current I=1 "Amplitude of trapezoid";
      parameter SI.Time rising(final min=0) = 0 "Rising duration of trapezoid";
      parameter SI.Time width(final min=0) = 0.5 "Width duration of trapezoid";
      parameter SI.Time falling(final min=0) = 0 "Falling duration of trapezoid";
      parameter SI.Time period(final min=Modelica.Constants.small) = 1
        "Time for one period";
      parameter Integer nperiod=-1
        "Number of periods (< 0 means infinite number of periods)";
      extends Interfaces.CurrentSource(redeclare Modelica.Blocks.Sources.Trapezoid signalSource(
          amplitude={I},
          rising={rising},
          width={width},
          falling={falling},
          period={period},
          nperiod={nperiod}));
    end TrapezoidCurrent;

## Modelica.Electrical.Analog.Sources.TableCurrent

Current source by linear interpolation in a table

### Information

This block generates a current source by linear interpolation in a 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:

- The time points need to be monotonically increasing.
- Discontinuities are allowed, by providing the same time point twice in the table.
- Values outside of the table range, are computed by extrapolation through the last or first two points of the table.
- If the table has only one row, no interpolation is performed and the current value is just returned independantly of the actual time instant, i.e., this is a constant current source.
- Via parameters startTime and offset the curve defined by the table can be shifted both in time and in the current.
- The table is implemented in a numerically sound way by generating time events at interval boundaries, in order to not integrate over a discontinuous or not differentiable points.

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).

### Parameters

Name | Default | Description
--- | --- | ---
table[:, :] | [0, 0; 1, 1; 2, 4] | Table matrix (time = first column, current = second column)
offset | 0 | Current offset [A]
startTime | 0 | Time offset [s]

### Modelica definition

    model TableCurrent
      "Current source by linear interpolation in a table"
      parameter Real table[:, :]=[0, 0; 1, 1; 2, 4]
        "Table matrix (time = first column, current = second column)";
      extends Interfaces.CurrentSource(redeclare Modelica.Blocks.Sources.TimeTable signalSource(table=table));
    end TableCurrent;