Setup Formula



This dialog allows to set up a new Formula. It is automatically invoked when starting a new Formula 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.


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 calculation will be displayed in the Info dialog. The result of the example function will look like this:

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 a number 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:
Calculate the mean value of the cursors in a display:
Display.AnalogDisplay#0.CursorB.y + (Display.AnalogDisplay#0.CursorA.y - Display.AnalogDisplay#0.CursorB.y)/2

Parentheses can be used to define precedence.

You can define custom constants with the following syntax:
const SpeedOfLight=299792458;
There are also some pre-defined constants:
  • e Euler's number
  • pi
rand() generates a random value in the interval [-1, 1].

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.
Result description You can define strings that will be shown in front of the result (Pre) and after the Result (Post). You can use these to show a name for the result and append a unit.
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.

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