SignalGenerator

SignalGenerator produces a test waveform — sine, block, triangle, sawtooth, two smooth profiles, or Gaussian noise — for commissioning, system identification and frequency-response work.
3.30–3.34

SignalGenerator produces a test waveform — sine, block, triangle, sawtooth, two smooth profiles, or Gaussian noise — for commissioning, system identification and frequency-response work.

Every setting is faded in, not stepped. Amplitude, frequency, phase, offset, the enable, and the waveform itself each ramp to their new value over a configurable time. Changing the signal type mid-run cross-fades between the two shapes, so nothing this block does puts a discontinuity into a moving machine.

flowchart LR
    i1(["enable"]) --> B["SignalGenerator"]
    i2(["signalType"]) --> B
    i3(["frequency"]) --> B
    i4(["amplitude"]) --> B
    i5(["phase"]) --> B
    i6(["offset"]) --> B
    i7(["dwellTime"]) --> B
    i8(["noiseAmplitude"]) --> B
    i9(["resetEnableSwitch"]) --> B
    B --> o1(["output — the generated signal"])
    B --> o2(["allOutputs — all seven types at once"])
    B --> o3(["sincos — sine and cosine of the phase"])
    B --> o4(["isStable"])
    B --> o5(["stableCycleCnt"])
    B --> o6(["enableIsOn"])
    B --> o7(["enableIsOff"])
    B --> o8(["time — the phase, 0 to 2 pi"])

frequency is in rad/s, not hertz — 6.283 is 1 Hz. amplitude is the peak, so a sine swings ±amplitude around offset. For the noise type, amplitude is a 3σ bound: about 99.7% of samples fall inside it and the rest are clipped, so the noise’s RMS is roughly a third of what you set.

Nothing here survives a controller restart. Every signal setting is a live input, not a stored parameter, and the block comes back with amplitude and frequency at 0 — a flat line at offset. That is deliberate: a generator that resurrected itself at full amplitude would be dangerous. Keep your test settings somewhere else.

Wait for isStable before trusting a measurement. With the default five-second fades, a value you write now is not fully applied until five seconds later.

Signals

Inputs

Path Unit Range Description
enable - - Ramps the whole output up to the waveform, or down to offset, over enableFadeTime. Not persistent — the block starts disabled.
resetEnableSwitch - - Makes the enable ramp jump instead of fading, once. Use it to start a test from a known state. The block clears it itself.
signalType - 0 – 6 Which waveform. Changing it cross-fades between the old and new shape over newSettingFadeTime — during the change the output is a blend of both.
frequency rad/s any The waveform’s frequency. Defaults to 0, which gives a flat line.
amplitude signal unit any Peak value. Defaults to 0.
phase rad any Where in the cycle the waveform starts.
offset signal unit any Added to everything. The output sits here when the generator is disabled.
dwellTime s 0 upward Holds the waveform at each peak for this long, turning a sine into a rounded trapezoid. 0 is off.
noiseAmplitude signal unit 0 upward Gaussian noise added on top of whichever type is selected, so you can put noise on a sine. Also a 3σ bound.

Outputs

Path Unit Description
output signal unit The generated signal, including any added noise, faded by the enable and shifted by offset.
allOutputs signal unit All seven waveforms at once, in signal-type order — so you can see what a different type would look like without switching to it. These exclude the added noise.
sincos - The sine and cosine of the current phase, normalised. Useful as a reference for correlating a measurement.
isStable - True when the generator is fully enabled and every setting has finished fading. Do not trust a measurement until this is true.
stableCycleCnt cycles How many complete periods have passed since isStable went true. A frequency-response analyser uses this to know how much clean data it has.
enableIsOn - The enable ramp has fully reached the waveform.
enableIsOff - It has fully reached offset.
time rad The current phase, 0 to 2π. Reset to 0 once the generator is fully off.

Parameters

Path Unit Default Range Effect
newSettingFadeTime s 5.0 0 upward How long every setting change takes to apply — including a change of waveform. Lower it for quick commissioning, raise it for a machine that must not be disturbed.
enableFadeTime s 5.0 0 upward How long enabling and disabling take.
jlpAccFactor - see below 0 – 1 Shapes the JERK_LIMITED waveform: how much of each ramp is spent at constant acceleration.
jlpJerkFactor - see below 0 – 1 How much is spent changing acceleration. Together these set how rounded that waveform’s turns are.

These four are persistent and survive a restart.

signalType What the machine does Parameters that matter
0 SINE A pure sine. The default, and the right choice for frequency response frequency, amplitude, phase
1 BLOCK A square wave. Excites everything at once; hard on mechanics frequency, amplitude
2 TRIANGLE Constant slope, sharp turns frequency, amplitude
3 SAWTOOTH Ramp with a step back frequency, amplitude
4 JERK_LIMITED Triangle with rounded turns, bounded jerk. Gentle on a machine plus jlpAccFactor, jlpJerkFactor
5 QUINTIC Smooth throughout, zero slope at each turn. The gentlest of the periodic shapes frequency, amplitude
6 AWGN Gaussian noise. Excites a wide band at once amplitude as a 3σ bound

Setup

  1. Set offset to where the machine should sit at rest, and amplitude and frequency to 0.

  2. Set enable true. output should move to offset over enableFadeTime and enableIsOn should go true.

  3. Choose signalType. Start with 5, QUINTIC, or 4 — both are gentle on mechanics and neither excites a resonance the way a block wave does.

  4. Raise amplitude from 0 in steps, watching the machine. Remember each step takes newSettingFadeTime to apply.

    Step 4 moves the machine. The fade means the full amplitude arrives seconds after you write it, so raise it in small steps and wait for isStable between them rather than writing a large value and watching.

  5. Set frequency. Convert from hertz by multiplying by 6.283.

  6. Wait for isStable, then take your measurement. Use stableCycleCnt to confirm you have enough complete periods.

  7. To stop, set enable false. The output ramps down to offset — it does not step.

Tuning

  1. Choose the waveform for what you are measuring. Sine for frequency response one point at a time; noise for a whole band at once; a smooth profile when the mechanics matter more than the spectrum.
  2. Set newSettingFadeTime shorter — one second, say — while sweeping through many frequencies, so each point settles quickly. Set it longer on a delicate machine.
  3. Sweep by writing each new frequency and waiting for isStable, then counting periods on stableCycleCnt. That is the intended workflow and the two outputs exist for it.
  4. Use sincos as the correlation reference if you are computing a gain and phase yourself — it is the generator’s own phase, with no measurement lag.
  5. Use dwellTime when you want to hold at the extremes rather than pass through them, for example to check settling at both ends of travel.
  6. Add noiseAmplitude on top of a sine to test how a loop rejects noise while tracking.
  7. Watch allOutputs to compare shapes before committing to one — no need to switch and wait for a cross-fade.

Three signal types at 1 Hz and amplitude 1: a sine, a triangle with sharpturns, and the quintic profile which is smooth through eachturn.

Read how gentle a waveform is off how rounded its turns are.

Symptom Cause Action
The output is a flat line Expected after a restart: amplitude and frequency both default to 0 Set them; nothing here is persistent
Everything I set is gone after a restart Expected: the signal settings are live inputs, not stored parameters Keep your test settings in your own configuration
A change takes seconds to appear Expected: every setting fades over newSettingFadeTime Lower that time, or wait for isStable
The measurement does not match the settings You measured before the fades finished Wait for isStable, then count periods on stableCycleCnt
The waveform looks like neither type during a change Expected: a type change cross-fades, so the output is a blend Wait for isStable
The frequency is out by a factor of about six frequency is in rad/s, not hertz Multiply your hertz figure by 6.283
The noise looks smaller than the amplitude I set Expected: for the noise type amplitude is a 3σ bound, so the RMS is about a third of it Set three times the RMS you want
The noise is different on every run Expected: the noise is seeded from the system, so it is not repeatable Two runs cannot be compared sample by sample
The machine jolted when I disabled the generator Not possible — disabling ramps down over enableFadeTime Check resetEnableSwitch is not being held
The output jumped instead of fading resetEnableSwitch was set, which makes the enable jump Clear it
The waveform kept its phase across a disable Expected: the phase only resets once enableIsOff is true Wait for the fade to finish before re-enabling
The block wave shook the machine Expected: a square wave excites every frequency at once Use type 4 or 5 instead
The peaks are flat and I did not ask for that dwellTime is non-zero Set it to 0
I want to see another waveform without switching Read allOutputs — all seven are published continuously

A starting point for a gentle 1 Hz excitation, quick to retune:

signalType         = 5
frequency          = 6.283
amplitude          = 0.01
phase              = 0.0
offset             = 0.0
dwellTime          = 0.0
noiseAmplitude     = 0.0
newSettingFadeTime = 1.0
enableFadeTime     = 2.0
enable             = true

Raise amplitude from there as Setup step 4 describes.

Limits and errors

Limit Set by What happens Reported
Persistence Fixed No signal setting survives a restart. The block comes up disabled with zero amplitude and frequency Not reported
Setting changes newSettingFadeTime Every change ramps rather than steps, including a change of waveform isStable
Enabling and disabling enableFadeTime Ramps between offset and the waveform. resetEnableSwitch makes it jump instead enableIsOn, enableIsOff
amplitude, frequency Nothing Not checked. A negative amplitude inverts the waveform and a negative frequency runs the phase backwards; both are harmless Not reported
Fade times Nothing Not checked. A negative value is passed through unchecked Not reported
Noise amplitude Fixed Interpreted as a 3σ bound and clipped there, so about 0.3% of samples are clipped Not reported
Noise repeatability Fixed Seeded from the system, so the sequence differs on every run and two runs cannot be compared sample by sample Not reported
output Nothing Unbounded — whatever amplitude plus offset produces. Bound it downstream before it reaches an actuator Not reported
Non-numeric settings Nothing Not guarded Not reported
Channel count Fixed One channel per instance. Use the group block for several Not reported

The block raises no errors or warnings and logs nothing. Every failure above shows as a value on a trace, not as a message.


Verified against motorcortex-control3 3.30.0 (bc348fd).