Test controller, math page

Math

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

Contents
    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

Areas

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



The columns


Add a formula

Add

Add a empty formula line.



Remove a formula

Delete

Remove one or more formula.



Calculation type


Source formula

MathMath

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

Edit

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.

Error

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.

Help

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

Example1

Power supplies seldom returns power, capacity or energy, but it is fairly easy to calculate.
The example uses a power supply called QL355



Decibel

Example2

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

Example3

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 25C), 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.

Example6

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

Example4

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

Example5

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.

ExampleDevice

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
A small program to set a parameter on fictive device while logging.

ExampleValue

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"