Setup Function Generator



This dialog allows to set up a new Function Generator. It is automatically invoked when starting a new Function generator calculation either from the channel dialog or from the menu. You may see more details on calculations and a detailed explanation of all supported calculation jobs here.

A lot of example waveforms can be found here.


Source Signals The list shows the selected channels for the calculation. You can select up to four channels but you can also create a function without a source signal. Please select the channels by double clicking on the channel name.
Destination Channel Defines a name under which the resulting signal should be accessed and shown inside SBench 6.
Destination File Store to cache tries to use the internal cache to speed up write process. If there is not enough free space in the cache the data is stored to a temporary file.
Store always to file stores data automatically under this file name on each calculation run. If Autostore is checked the result of the calculation is stored to a new file each time the calculation runs.
Function Contains the function to calculate. All values are calculated in Volts. The result of the example function will be an inverted sine wave of 16 kS length with 16 periods, 500 mV amplitude and an offset of 500 mV.
The function may contain whitespaces and line breaks.

Steady functions:
  • sin(a) Sine
  • cos(a) Cosine
  • tan(a) Tangent
  • asin(a) Arc sine
  • acos(a) Arc cosine
  • atan(a) Arc tangent
  • sinh(a) Hyperbolic sine
  • cosh(a) Hyperbolic cosine
  • tanh(a) Hyperbolic tangent
  • ln(a) Logarithmus naturalis (base e)
  • abs(a) Absolute
  • + Addition
  • - Subtraction
  • * Multiplication
  • / Division
  • % Modulo
  • ^ Power
Non-steady functions
  • tri(a,d) Triangle with d% of one period rising, the other 100-d% falling
  • rect(a,d) Rectangle with d% of one period high, the other 100-d% low
Signal access:
  • sig0(a) Value of Signal 0
  • sig1(a) Value of Signal 1
  • sig2(a) Value of Signal 2
  • sig3(a) Value of Signal 3
a is the argument of the function. You can use x (the current sample) or the result of a nested calculation as arguments. If a is outside the valid range for sigX the nearest valid value will be used, e.g. if a is smaller zero, the value for a = 0 will be used.
Some examples:
To create a copy of Signal 0 with half the original amplitude, use 0.5*sig0(x)
To create a signal with every even sample of Signal 0, use sig0(2*x). Here you have to make sure that Length is set to the appropriate value.

Parentheses can be used to define precedence.

You can define custom constants with the following syntax:
const SpeedOfLight=299792458;
Valid characters for the constant's name: characters (A-Z, a-z), numbers (0-9) and underscore (_).
There are also some pre-defined constants:
  • e Euler's number
  • pi
  • length Length of the resulting signal
  • post Posttrigger of the resulting signal
  • range Range of the resulting signal
  • resolution Resolution of the resulting signal
  • samplerate Samplerate of the resulting signal
x is used as the number of the sample.

rand() generates a random value in the interval [-1, 1]. This can be used to add noise to generated signals.

Results of single-value calculations (those that appear in the Info Dialog, e.g. Maximum) can be used for calculations. It uses the same syntax as the Report Generator. To access a result prepend the Report Template Name of a calculation result with "Calculation.", e.g. Calculation.AnalogCh#0.Maximum#0 will be replaced with the result of the first Maximum calculation on the first analog channel.

Non-steady functions:
  • if(a,b,c) is 1.0 if b <= a <= c, otherwise it's zero. Each of a,b and c can be the result of a calculation, e.g. if(x,8*1024,8*1024+4096).
  • sign(a) is -1 if argument is negative, +1 if argument is positive and zero if argument is zero.

Bitwise operations:
  • & Bitwise AND
  • | Bitwise OR
  • << Bitwise left shift
  • >> Bitwise right shift
Due to the internal structure bitwise operations can only be used on sigX() or on other bitwise operations, e.g. (sig0(x)&0xFF)<<4 is ok, but sin(x)<<4 is not possible.

You can add comments by enclosing the text in /* */: /*This is a comment*/.

You can also add functions by using the context menu for the function input field. If you click the dashed area on top of the "Add function" submenu you will get a floating menu. It works the same as the normal menu but saves you from opening the context menu over and over again.
Load function Using this button you can load a formula from a text file.
SBench6 provides some example functions that show some common waveforms.
Store function Using this button you can store the current formula to a text file. It can be loaded again using the "Load function" button.
Samplerate Defines the samplerate of the generated signal and thus the resolution in time. This setting is only available if manual setup is enabled, otherwise the value of the first source channel will be used.
Length Defines the number of samples to generate. This setting is only available if manual setup is enabled, otherwise the value of the first source channel will be used.
Resolution Defines the resolution of the generated signal. This setting is only available if manual setup is enabled, otherwise the value of the first source channel will be used.
Amplitude Defines the amplitude of the generated signal. This setting is only available if manual setup is enabled, otherwise the value of the first source channel will be used.
Keep in loop If this option is checked the calculation is automatically updated if the source signal has changed. If it is not checked the result is calculated once and stays fixed afterwards.
Add to displays If this option is checked the newly generated signal is automatically added to a matching analog display. If no analog display is yet available a newly generated display is automatically added showing this plot.

When you edit an existing channel the setup window will look slightly different: at the top of the dialog a section appears that allows you to edit the name, color and custom unit (if available) for the calculated channel. Below the calculation settings can be edited as described above.


Copyright © Spectrum Instrumentation GmbH Back to top
SBench 6 Documentation