Sources

SignalGenerator Block

Generates various types of time-varying signals (sine, cosine, square, sawtooth, triangle)

Open SignalGenerator in BlockWerk →

# SignalGenerator Block

Description

The SignalGenerator block is a versatile signal source that generates various types of time-varying signals for simulation and testing purposes. It can produce sinusoidal waves, cosine waves, square waves, sawtooth waves, and triangular waves. This block is essential for creating test signals, reference inputs, and periodic disturbances in control systems and signal processing applications.

The SignalGenerator operates as a time-based function generator, producing output signals based on the current simulation time and the configured parameters. It has no input ports and continuously outputs the generated signal to its single output port.

Mathematical Model

All signals share the base argument:

θ(t) = 2π × f × t + φ

where φ is the phase converted from degrees to radians.

The normalized position within the cycle is:

n = ((θ / 2π) mod 1 + 1) mod 1

Sinusoidal Signal

y(t) = A × sin(θ) + offset

Cosine Signal

y(t) = A × cos(θ) + offset

Square Wave Signal

y(t) = A      if n < dutyCycle
y(t) = -A     if n >= dutyCycle
y(t) += offset

Sawtooth Wave Signal

y(t) = A × (2n - 1) + offset

Rises linearly from -A to +A over one period.

Triangular Wave Signal

y(t) = A × (4n - 1)       if n < 0.5
y(t) = A × (3 - 4n)       if n >= 0.5
y(t) += offset

Rises from -A to +A in the first half, falls from +A to -A in the second half.

Where:

Parameters

signalType

The type of waveform to generate.

amplitude

The peak amplitude of the generated signal. Controls the maximum deviation from the offset value.

frequency

The frequency of the generated signal in Hertz (Hz).

offset

The DC offset added to the signal. Shifts the entire signal up or down.

phase

The phase offset of the signal in degrees (0-360). The phase is converted to radians internally: φ_rad = phase × π / 180. A phase of 90° on a sine wave produces a cosine wave.

dutyCycle

The fraction of the period during which the square wave is at +amplitude. Only visible when signalType is "square".

Examples

1Hz Sine Wave

Generate a basic unit-amplitude sine wave:

SignalGenerator (signalType: "sine", frequency: 1) → NumericDisplay

PWM Signal

Generate a 10Hz PWM signal with 30% duty cycle:

SignalGenerator (signalType: "square", frequency: 10, dutyCycle: 0.3) → Controller

Phase-Shifted Cosine

Two equivalent ways to generate a cosine:

SignalGenerator (signalType: "cosine", frequency: 1) → Scope
SignalGenerator (signalType: "sine", frequency: 1, phase: 90) → Scope

Remarks

See Also