Modular co-simulation framework
Signal Generator

The Signal Generator node-type is a simple signal generator which can be used to generate sine, square, ramp, triangle or random signals at user definable frequencies, rates, amplitudes.

Most commonly it is used for testing when no real simulation data is available.

Note: There is also the villas-signal tool which has a similar purpose.


This node-type does not have any special library dependencies. It is always available.


The source code of the node-type is available here:


signal (string: "random" | "sine" | "square" | "triangle" | "ramp" | "counter" | "constant" | "mixed" | "pulse")

The type of signal which should be generated:

  • random: a random walk with normal distributed step sizes will be generated.
  • sine: a sine signal will be generated.
  • square: a square / rectangle wave will be generated.
  • triangle: a triangle wave will be generated.
  • ramp: the generator will produce a ramp signal in the interval [ 0, 1 / f ].
  • counter: increasing integer counter is generated.
  • constant: a constant value generated.
  • mixed: the signals of of each sample are generated by cycling over all remaing signal types.
  • pulse: generates pulses with a set frequency, phase and width

values (integer) = 1

The number of signals which each of the generated samples should contain.

rate (integer) = 10

The rate at which sample should be generated by the node.

amplitude (float) = 1.0

The amplitude of the signal when signal (string: "random" | "sine" | "square" | "triangle" | "ramp" | "counter" | "constant" | "mixed" | "pulse") is one of sine, square or triangle.

frequency (float) = 1.0

The frequency of the signal when signal (string: "random" | "sine" | "square" | "triangle" | "ramp" | "counter" | "constant" | "mixed" | "pulse") is one of sine, square, triangle,pulse or ramp.

phase (float) = 0.0

Tha pase of the signal when signal (string: "random" | "sine" | "square" | "triangle" | "ramp" | "counter" | "constant" | "mixed" | "pulse") is one of sine or pulse.

pulse_width (float) = 1.0

The width of the pulse, with respect to the rate

pulse_low (float) = 0.0

The low value of the pulse signal.

pulse_high (float) = 1.0

The high value of the pulse signal.

stddev (float) = 0.2

The standard deviation of the normal distributed steps if signal (string: "random" | "sine" | "square" | "triangle" | "ramp" | "counter" | "constant" | "mixed" | "pulse") is random.

offset (float) = 0.0

Adds a constant offset to each of the generated signals.

limit (integer) = -1

Limit the number of generated output samples by this node-type. A negative number disables the limitation.

realtime (boolean) = true

Wait 1 / rate seconds between emitting each sample.

monitor_missed (boolean) = true

If true, the Signal Generator node-type will count missed steps and warn the user during every iteration about missed steps. Especially at high rates, it can be beneficial for performance to set this flag to false. Warnings would namely cause system calls which will slow the node down even more, and thus cause even more missed steps.


nodes = {
signal_node = {
type = "signal",
# One of "sine", "square", "ramp", "triangle", "random", "mixed", "counter"
signal = [ "sine", "pulse", "square" ],
values = 3, # Number of values per sample
amplitude = [ 1.2, 0.0, 4.0 ], # Amplitude of generated signals
frequency = 10, # Frequency of generated signals
stddev = 2, # Standard deviation of random signals (normal distributed)
rate = 10.0, # Sample rate
offset = 1.0, # Constant offset
realtime = true, # Wait between emitting each sample
limit = 1000, # Only emit 1000 samples, then stop
monitor_missed = true # Count and warn about missed steps