Skip to main content

Signal Generator (v1)

Deprecation

This node-type is deprecated. Please use the newer signal.v2 node-type.

The signal 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.

Prerequisites

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

Implementation

The source code of the node-type is available here: https://github.com/VILLASframework/node/blob/master/lib/nodes/signal.cpp

Configuration

signal
required
string
Enum: "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 remaining signal types.
  • pulse: generates pulses with a set frequency, phase and width
values
integer
Default: 1

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

rate
integer
Default: 10

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

amplitude
number
Default: 1

The amplitude of the signal when the signal setting is one of sine, square or triangle.

frequency
number
Default: 1

The frequency of the signal when the signal setting is one of sine, square, triangle,pulse or ramp.

phase
number
Default: 0

Tha pase of the signal when the signal setting is one of sine or pulse.

pulse_width
number
Default: 1

The width of the pulse, with respect to the rate

pulse_low
number
Default: 0

The low value of the pulse signal.

pulse_high
number
Default: 1

The high value of the pulse signal.

stddev
number
Default: 0.2

The standard deviation of the normal distributed steps if the signal setting is set to random.

offset
number
Default: 0

Adds a constant offset to each of the generated signals.

limit
integer
Default: -1

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

realtime
boolean
Default: true

Wait 1 / rate seconds between emitting each sample.

monitor_missed
boolean
Default: true

If true, the signal 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.

object (Input configuration (received by VILLASnode))
vectorize
integer
Default: 1

This setting allows to send multiple samples in a single message to the destination nodes.

The value of this setting determines how many samples will be combined into one packet.

Array of Hook Object (object) or Hook Name (string) (hook_list)
builtin
boolean (Builtin hook functions)
Default: true

By default, each node and paths has a couple of default hooks attached to them. With this setting the attachment of built-in hooks can be disabled.

object (Output configuration (sent out by VILLASnode))
{
  • "signal": "random",
  • "values": 1,
  • "rate": 10,
  • "amplitude": 1,
  • "frequency": 1,
  • "phase": 0,
  • "pulse_width": 1,
  • "pulse_low": 0,
  • "pulse_high": 1,
  • "stddev": 0.2,
  • "offset": 0,
  • "limit": -1,
  • "realtime": true,
  • "monitor_missed": true,
  • "in": {
    },
  • "vectorize": 1,
  • "hooks": [
    ],
  • "builtin": true,
  • "out": {
    }
}

Example

node/etc/examples/nodes/signal.conf
nodes = {
signal_node = {
type = "signal"

# One of "sine", "square", "ramp", "triangle", "random", "mixed", "counter"
signal = [ "sine", "pulse", "square" ]

# Number of values per sample
values = 3

# Amplitude of generated signals
amplitude = [ 1.2, 0.0, 4.0 ]

# Frequency of generated signals in Hz
frequency = 10

# Standard deviation of random signals (normal distributed)
stddev = 2

# Sample rate in Hz
rate = 10.0

# Constant offset
offset = 1.0

# Wait between emitting each sample
realtime = true

# Only emit 1000 samples, then stop
limit = 1000

# Count and warn about missed steps
monitor_missed = true
}
}