This page is used to define math channels, this is values calculated from measured values.

What is on the screen

The columns

Add a formula

Remove a formula

Calculation type

Source formula

Some examples

Power, capacity & energy

Decibel

Temperature

Removing noise

Convert a value to digital

Alternate use of Math

Recording extra device data

Including a control variable in the data

Scripting

Functions for use in calculator and definitions

Main page

What is on the screen

In the above picture I have labelled the different areas of this page, in the following I will go more into details.

The columns

- Name: The name of this value, "Math." is added before this name when it is used on the different pages.
- Enable: When checked the formula will be calculated for each value. A "Math" column in the table will not be removed when this value is unchecked, but it will not be recalculated either.
- Unit: Optional unit.
- Type: Perform a advanced operation of the calculated value, often involving multiple samples.
- Samples: How many samples is used for the operation specified above (in a few cases samples is not samples, but have a different meaning).
- Source formula: The formula calculated the value, this formula can use data from all measured columns.

Add a formula

Add a empty formula line.

Remove a formula

Remove one or more formula.

Calculation type

- Formula: Use the result from the formula directly
- FormulaNU: Use the result from the formula directly, this version will never update/recalculate (NU stands for No Update) a table, only fill it when it is recorded.
- Average: Calculate a rolling average over the specified number of samples. See also RollingSum
- Slope: Calculate slope using a least square method over the specified number of samples.
- Min: Find the minimum value over the specified number of samples.
- Max: Find the maximum value over the specified number of samples.
- RollingSum: Calculate a rolling sum over the specified number of samples. See also Average
- TotalSum: Calculate the sum of all samples. See also RollingSum
- SumTimeSec: Calculate the sum of all samples and weight by time. This is used to get As, Ws or similar. See also SumTimeMin, SumTimeHour
- SumTimeMin: Calculate the sum of all samples and weight by time. This is used to get Am, Wm or similar. See also SumTimeSec, SumTimeHour
- SumTimeHour: Calculate the sum of all samples and weight by time. This is used to get Ah, Wh or similar. See also SumTimeSec, SumTimeMin
- Change: Returns the difference between the first and last sample over the specified number of samples.
- Delta: Returns the larges difference between two successive samples over the specified number of samples.
- Range: Return the difference between min and max over the specified number of samples.
- RMS: Calculates a Root Means Square (RMS) value over the specified number of samples. I.e. squares all samples, add all squares, divide by number of samples and then takes the square root.
- FilterLP: Remove higher frequencies from the data. Math: (sum*(samples-1)+lastValue)/samples. See also FilterHP, Average
- FilterHP: Remove lower frequencies from the data. Math: (sum*(samples-1)+lastValue)/samples. Returns the difference between lastValue. and the sum. See also FilterLP
- Digital: Convert a value to digital channels, samples specifies number of digital channels. It is using the bits from the integer part of the value. The operators == > < can be useful for a single channel
- DropOutFilter: Tries to eliminate a few samples that is well outside the average of the specified number of samples. It do that by using a average when the last values is outside 3 time the variance in the data.
- StdDev: Calculate standard deviation for all data.
- StdDevRunning: Calculate standard deviation for specified number of samples.

Source formula

The formula part is where data is collected from the measured values and combined to a new value.

Click on the field and start typing or press F2 to enter edit mode.

It is possible to use all the normal operators and brackets in the formula.

The formula is not checked for error while typing, first when trying to use the formula, i.e. enabling it and selected "Current values" or "Table" page. If there is an error the formula will be disabled again and marked with red.

There is a help popup that shows the most common functions that can be used in formula, see the link above for a more complete function list.

Some examples

Power, capacity & energy

Power supplies seldom returns power, capacity or energy, but it is fairly easy to calculate.

The example uses a power supply called QL355

Decibel

Any voltmeter value can be converted to decibel with a simple formula. In the audio world the dBu value is based on 1mW in 600ohm or 0.775V. The first formula handles that.

The second formula calculated dB with 1 volt as reference.

The example uses a DMM called K34461

Temperature

Many DMM's can measure temperature, often with thermocouplers where the precision is within a couple of degrees. To make more precise temperature measurements on any DMM use a precision thermistor.

The first example uses the beta value (3950) and the reference point (10kOhm at 25°C), it will be fairly precise around the reference point.

The second example can do much better but requires that the "ntc1" value is defined first. It is done with the expression:

Code:

globalvar ntc1=ntcCoef(24.94k,5,10k,25,4.363k,45)

That defines 3 reference points. These points are selected from the datasheet for the used ntc with values that covers the desired range.

The above expression can be executed in the calculator or on the command line with a = before it. The best place to put it is probably in the "...\Documents\TestController\Settings\autorun.txt" file with a = before it.

Thermistors are not the only sensors supported, both RTD and thermocouplers can also be used.

With RTD there is support for PT, ITS-90 (Nearly the same as PT), CU and NI. The PT and ITS-90 uses 3 coefficients math, CU & NI only uses 1 coefficient.

The thermocouplers are based on NIST polynomials, cold junction compensation must be added manually (The 25 in the above example). All eight standard types (JEBNRSTK) are supported. Thermocouple sensors requires the meters as 10uV or better resolution.

Removing noise

Sometimes it can be necessary to remove noise from a measurement, the LP filter can be used for that (A average would do nearly the same).

Adjust the samples to get the best filtering. With high values of samples output will change very slowly.

Convert a value to digital

All digital values only count as one curve on the chart, this makes it very useful to show some a couple of status values/curves.

The above formula will show 1 when the voltage is with 4.9V to 5.1V and 0 at all other times.

Alternate use of Math

In addition to calculating on the recorded data, it is also possible to use Math channels for extra device data or some control value from a script.

Recording extra device data

For this to work use the type "FormulaNU", this prevents TestController from updating the data in the table at a later time, destroying the recorded data.

To collect data use "deviceRead(handle,scpiCommand)" as the source formula, it may also be necessary to add some text filtering on the received data (See String function)

Collecting data this way will slow down the sample rate, because Math is first calculated after all device data has been collected (With multiple devices this is done in parallel). The Math data collection will be done in series, i.e. one at a time, until all are collected.

An example with a fictive device where I filter all the numbers from the answer and ignores any other characters.

Including a control variable in the data

When using scripts to control the devices it may sometimes be useful to record some of the control value in the table. For this to work the control variable must be declared "globalvar" instead of "var", then it can be directly used in the Math definition. The definition must be of type "formulaNU" to prevent prevents TestController from updating the data in the table at a later time, destroying the recorded data.

Code:

=globalvar myParameter=0; #log 1 #while (myParameter<10) X1230:PARAMETER:SPECIAL (myParameter) #HasLogged =myParameter=myParameter+0.1 #endwhile #log 0

For the parameter to be recorded a math channel is used.

Scripting

Math can be controlled with the following script commands:

#MATH {name {unit type samples sourceFormula}}

#MATHDELETE name {name {...}}

This is include in the right click menu in the log window: "Generate scripts, Layout"