q

Formulas and calculations - with examples

Find the formula editor

You can access the formula editor by checking the Formula editor option in the main menu. It will then open as a pop-up window.

 

 

Writing formulas

The structure of a formula should always look like the following:

GRAPH “formula name” (unit) = formula

Or:

GRAPH “formula name” = formula (if (unit) is left out no graph will be plotted but the values are calculated, for use in other formulas for example.)

  • GRAPH is a so-called keyword.
  • “formula name” is how you wish to describe the formula
  • formula is a mathematical expression that is constructed using operators, variables, etc.

You can create a formula by clicking on the desired operator, variable, etc, in the menu to the left, or you can write it by hand.

If you choose to write it by hand, consider the following:

  • Functions, operators, etc, has to be written in CAPITAL letters
  • Formula names that contains spaces has to be market “by quotes”
  • Variables has to be entered exactly as they appear in the variable list

 

Functions

ABS(r)

Returns absolute values
Ex: ABS(-10) ® 10 

ACOS(rR

Returns the angle whose Cosine is (r)
Ex: ACOS(1) 0 ® (0°C)

ASIN(r)

Returns the angle whose Sine is (r)
Ex: ASIN(1) 1,57 ® (90°C)

ATAN(r)

Returns the angle whose Tangent is (r)
Ex: ATAN(1)  0,785 ® (45°C)

COS(r)

Returns the Cosine of r
Ex: COS(3,14) ® -1

DEG(r)

Transforms radians to degrees
Ex: DEG(3,14) ® 180°

EXP(r)

Calculates the exponential function
Ex: EXP(4) ® e4 = 54,6

FAC(r)

Calculates the factorial
Ex: FAC(4) ® 1*2*3*4=24

FRAC(r)

Returns the fractional part of a floating-point number
Ex: FRAC(31,232) ®0.232

INT(r)

Returns the integer part of a floating-point number® 31
Ex: INT(31,232)

LN(r)

Returns the logarithm of values greater than zero
Ex: LN(10) ® 2,30..

LOG(r)

Returns the base-10 logarithm of values greater than zero
Ex: LOG(10) ® 1

PWR(x;y)

Returns the result of y raised to the power of x
Ex: PWR(2;ID1) ® Square of channel 1

RAD(r)

Transforms degrees to radians
Ex: RAD(180) ® 3,141592653589793238462..

RND(r)

Returns a random number between zero and r
Ex: RND(30)

SGN(r) +1 if the number is positive and -1 if it is negative
SIN(r)

Returns the Sine of r
Ex: SIN(3,14)  ® 0

SQRT(r)

Returns the square root of the value
Ex: SQRT(144) ® 12

TABLE(ID;r) Returns a transformed value by interpolating between entries in Tabler.txt (where r is a row number)
TAN(r)

Returns the Tangent of r
Ex: TAN(π/4) ® 1,548

 

 

Vector functions


Features that are preceded by V are called vector functions. These are used to make calculations with respect to a number of sample points.

Funktion Beskrivning
VAVEL(ID;n)

Returns the average of 2n + 1 samples at each measurement point.

Example: VAVEL (ID1; 5) returns an average of 11 points, five back five forward and the point calculated.

VDER(ID) Returns the derivative calculated as follows:
(F (t-2DT) - 8 * f (t-dt) + 8 * f (t + dt)) - f (t + 2DT)) / 12
Ex: VDER (ID1)
VDER2(ID)

Returns the second derivative calculated as the slope of the chord from t to t + dt dt of the first derivative.
Ex: VDER2(ID1)

VMEDL(ID;n) Returns the median of 2n + 1 values ​​Ex: VMEDL (ID1; 3) results in a median of 7 values ​​from channel 1
VPOS(ID)

Returns the relative time as a float. The unit is in days.

Ex: VPOS (ID1) ® instance. 2.1323 which means 2 days, 3 hours, 10 m and 31 seconds (approximately).

VREV(ID) Returns the value of a curve with inverse time. The end time specified as the start time.
VSIZE(ID) Returns a float for the length of the recording.
VSKEWL(ID;n) Creates an offset curve "x" number of sample points
Ex: VSKEWL (ID1; 5)
VSKEWT(ID;t) Creates an offset curve "t" number of seconds. Do not confuse this with the "Shift" in the info table. It has a similar function.

 

 

 

Operators

Many of the operators is pretty obvious, such as +, -, = etc., While others like the GT, LT, etc. may need a short presentation. AND (&), BIT, OR (|) and XOR is the Boolean operators. The characters in brackets can be used instead of writing out the whole word. They are used in conventional ways to handle binary signals.

  Aritmetiska operatorer

+

-

*

/

^

Addition

Subtraction

Multiplication

Division

Used as the exponent operator.
Ex. GRAPH Expo (kPa) = ID1 + 3 (study as CH1 cubed)

  Boolean operators

AND

&

Does one-conditions between two binary values.
Ex: GRAPH mesh (sat) = ID31 AND 4 (Returns 4 if bit 2 is set to Channel 31; zero otherwise)

OR |

Or-conditions:

Ex .: GRAPH mesh (sat) = ID31 OR 4 (Returns ID31 + 4 if bit 3 was not set; otherwise ID31)

BIT Used to see if a bit is set or not.
Ex: GRAPH mesh (sat) = ID31 BIT 4 (Returns a one if bit 3 is set on channel 31; zero otherwise)
XOR

The best way to describe a so-called. half adder is a truth table. The terms for each position in a binary number:

0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0

Ex .: GRAPH add (bin) = 5 XOR 3 (Returns 6)

˜ This function "invert". A zero becomes a one and all nonzero becomes zero.
  Comparison operators
> If the condition is met retuneras 1, otherwise 0th
Ex: GRAPH "greater than" (bit) = ID1> 5 (Is 1 when ID1 is greater than 5, otherwise 0)
< If the condition is met retuneras 1, otherwise 0th
Ex: GRAPH "less than" (bit) = ID1> 100 (Is 1 when ID1 is greater than 100, otherwise 0)
= If the left side is equal to the right side returns 1, otherwise 0
>= Greater than or equal to the returns 1, otherwise 0
<= Less than or equal to the returns 1, otherwise 0
GT

"The largest of .. and .."

Ex: Greater GRAPH (° C) = ID1. GT 30

(If the ID1 is greater than 30 retuneras ID1 otherwise retuneras 30.)

LT

 

"The smallest of .. and .."

Ex: GRAPH lesser (° C) = ID1 LT 30 (If ID1 is less than 30 retuneras ID1 otherwise retuneras 30.)

 

Finally, we provide a number of special characters that can be good to have:

°

μ

²

Degrees sign

My, micro-

Powers 2, quadratic

 

Variables

If you have a recording where you've used a combination of mean, min, or max, the corresponding suffix will also be added:

ID1.min, ID1.max, etc.

Formulas can also be used as variables. Just make sure they are defined “before” they are used, i.e., they appear on a line above. Especially formulas without a sort are intended to be used this way.

 

 

Key Words

The six key words that can be used in the formulas are always written first.

The following key words must be used.

CONST

 

This keyword declares a constant that can be used in a formula.
Ex: CONST PI=3,141592653

GRAPH

Declares a formula.

Ex: GRAPH "My value"(°) = SIN(DEG(ID1))

KEYVAL

Declares the mathematical expressions that generate ratios, i.e. new columns in the data table.

ex: KEYVAL test = SUM/N

FN

 

Declares a function. Common features are, for example, f (x), v (t) mm. You can also have a function with more operands, such as Y (z; x) and so on.
Ex: FN f(x;y) = (5*x) - y

GRAPH function tests (r / min) = f (ID1.med, ID2.med)

REM

 

Used to write a comment. Can also be used to prevent a formula from being executed.
Ex: REM GRAPH test(°C) = Tempinne.max - Tempute.min

SET

 

 

 

 

Used to give your channels more manageable names in the formula.

Ex: SET U2 = 'voltage R2'

SET I1 = 'Power R1'

CONST R1 = 50000

GRAPH test (V) = U2 - R1 * I1

 

Key Figures

The key figures that can be used to create new columns in the info table are:

  • AVE: The average value of the signals during the displayed time.
  • MIN: The minimum value of the signals during the displayed time.
  • MAX: The maximum value of the signals during the displayed time.
  • IDT: The integrals of the signals during the displayed time. Δt is in seconds.
  • SUM: The arithmetic sum of the measured values during the displayed time. Σx
  • SQRSUM: The sum of the squares of the measured values. Σx²
  • N: The number of displayed measurements.
  • CURSOR1: The measurement value at the position of cursor 1.
  • CURSOR2: The measurement value at the position of cursor 2.
  • ONLINE: The most recent measurement value in online measurement. The last value.

The syntax for creating key figures is illustrated by this formula, which actually calculates variance:
KEYVAL Variance = (SQRSUM – 2 * SUM * MEAN + (MEAN²) * N) / N
You can then easily create a column that gives the standard deviation. It looks like this:
KEYVAL Standard Deviation = SQRT(Variance)

As you can see, all these key figure calculations begin with the keyword "KEYVAL". This tells the program what to do with the following expression. In summary, the syntax looks like this:
KEYVAL name = expression
Allowed operators in "expression" are arithmetic operators. Variables in "expression" are keywords. Note that signals (= variables, channels) and vector functions cannot be used.

 

Examples of Formulas

Average Value

In EasyView, you can see the average value for the zoomed-in time period in the information table, where it is abbreviated as "Med."

It is also possible to calculate averages over different time periods so you can track changes in the average, for example, per hour or day. This is done using the data reduction function in the data table.

Double-click in the data table and select the "time column" tab.

The average is then calculated from the time listed in the time column. If part of the measurement is zoomed in, it means the average calculation begins where the time axis starts in the time diagram.

If you want the average per week, day, minute, or second for your entire measurement, you should zoom out before selecting the average calculation.


 

Globe Temperature and Operative Temperature

The globe temperature and the operative temperature are relatively close to each other. Read more about it here. Below is the calculation for the operative temperature:

Operativ temperatur

FN MRT(gt; v; e; d; ta) = ((gt + 273) ^ 4 + (1.1 * 10 ^ 8 * v ^ 0.6) / (e * d ^ 0.4) * (gt - ta)) ^ (1 / 4) - 273 FN Operative(gt; v; e; d; ta) = (MRT(gt; v; e; d; ta) + (ta * SQRT(10 * v))) / (1 + SQRT(10 * v))

 

GRAPH 'Operative Temperature' (°C) = Operative(ID2; 0.1; 0.98; 0.05; ID1)

In this formula, ID2 represents the globe temperature, and ID1 is the room temperature. The air velocity is estimated to be 0.1 m/s, the emissivity factor is set to 0.98, and the diameter is set to 0.05 m.

 

Lux Hours

When measuring lux, you might want to take measurements every second and then present the data in lux hours, which is a common unit used in museums. Museums often sum up lux hours over, for example, a year to track how much light an object has been exposed to.

Here's how to calculate lux hours in EasyView:

You simply divide IDT by 3600.

KEYVAL Lux hours = IDT/3600

IDT is similar to the key figure SUM. The difference is that SUM is the total of each sampling, while IDT is the total of each sampling per second (regardless of the sampling interval). In other words, with a sampling interval of 1 second, IDT and SUM have the same value. Therefore, IDT is independent of the sampling interval, unlike SUM. IDT alone gives you "lux seconds," IDT/60 gives you "lux minutes," and IDT/3600 gives you lux hours. kWh is calculated in a similar way.

 

Ventilation Index

CO2 levels can provide an indication of air quality. To properly assess air quality, it is important to also test the ventilation system (according to Nordtest VVS 114).

Once the CO2 levels in the incoming air, the air in the room, and the outgoing air have stabilized, it is best to use 15-minute averages.

The formula for this is as follows:

  • Supply air concentration (Ct)
  • Exhaust air concentration (Cf)
  • Room CO2 concentration (Cr)

Exhaust air difference (ΔCf):

ΔCf = Cf (exhaust air concentration) - Ct (supply air concentration)

Room concentration difference (ΔCr):

ΔCr = Cr (room concentration) - Ct (supply air concentration)

Local ventilation index in percentage:

Ventilation index = ΔCf / ΔCr * 100

This compares how much the CO2 level in the occupied zone and the exhaust air differ from the supply air.

Note: In many cases, it is assumed that the supply air concentration is 400 ppm.

In EasyView, the formula looks like this:
SET SupplyAir = ID1 SET ExhaustAir = ID2 SET OccupiedZone = ID3 GRAPH VentilationIndex(%) = (ExhaustAir - SupplyAir) / (OccupiedZone - SupplyAir) * 100

This calculation provides a percentage value of how effectively the ventilation system is working based on the CO2 concentrations.

 

Splitting the Digital Inputs of a PC Logger

A PC logger with a digital card has 8 digital inputs and 4 digital outputs. One exception is the PC logger 2100, which has three digital/pulse counting inputs, where input one can be used as a digital output. The digital inputs and outputs are presented in EasyView as an integer. This integer represents a binary value and can be split using the formulas below so that each digital input and output is displayed as a separate curve in the chart.

Here's the formula for splitting the digital inputs: 
SET DigIn = ID31 GRAPH "DigIn 1"(Din) = DigIn BIT 0 GRAPH "DigIn 2"(Din) = DigIn BIT 1 GRAPH "DigIn 3"(Din) = DigIn BIT 2 GRAPH "DigIn 4"(Din) = DigIn BIT 3 GRAPH "DigIn 5"(Din) = DigIn BIT 4 GRAPH "DigIn 6"(Din) = DigIn BIT 5 GRAPH "DigIn 7"(Din) = DigIn BIT 6 GRAPH "DigIn 8"(Din) = DigIn BIT 7

Here's the formula for splitting the digital outputs:

SET DigOut = ID32 GRAPH "DigOut 1"(Dout) = DigOut BIT 0 GRAPH "DigOut 2"(Dout) = DigOut BIT 1 GRAPH "DigOut 3"(Dout) = DigOut BIT 2 GRAPH "DigOut 4"(Dout) = DigOut BIT 3

These formulas allow you to break down the binary value into individual digital inputs and outputs, which can then be represented as separate curves in your EasyView charts.

 

Dew Point

By writing the following formula in the Formula Manager available in EasyView Pro, you can calculate the dew point. The dew point is calculated based on the measured temperature and relative humidity.


REM The following conditions apply:
REM 0°C < T < 60°C
REM 0.01 < RH < 1.00
REM 0°C < Td < 50°C

REM Adjust the ID numbers so that T is the temperature channel and RH is the relative humidity
SET T = ID2 SET RH = ID1 CONST a = 17.27 CONST b = 237.7 GRAPH alpha = (a * T) / (b + T) + LN(RH / 100) GRAPH Dew Point (°C) = (b * alpha) / (a - alpha)


Dew point according to the National Encyclopedia:
Dew point, or dew point temperature, is the temperature to which air must be cooled, without changing the air pressure or water vapor content, for water condensation to begin.

This formula allows for the accurate calculation of the dew point based on temperature and humidity data in EasyView Pro.

 

Derivation in EasyView

Derivation can be useful when you have a constantly rising curve and are interested in the change over time. For example, if you have a pulse counter that records the number of pulses from an electricity meter, and the meter emits 1000 pulses per kWh, you may want to derive a curve that shows how the power output has changed over time. The formula for this would be:

GRAPH Power (kW) = VDER(ID1) / 1000 * 3600

In this formula:

  • VDER(ID1) represents the derivative of the pulse count (ID1).
  • Dividing by 1000 converts the pulses into kilowatt-hours (kWh).
  • Multiplying by 3600 converts it into kilowatts (kW), accounting for time in seconds.

Another application where derivation might be useful is when measuring volume and deriving a curve that shows flow rate based on the change in volume over time. Derivation helps to analyze how fast the volume or another parameter is changing, providing insights into trends and patterns over time.

 

kWh

Energy Consumption (Watt-Hours) in EasyView

Energy consumption, measured in watt-hours, is the average power multiplied by the number of hours. For example, an average power of 2 kW over one hour results in the same energy consumption as an average power of 1 kW over two hours.

To calculate kilowatt-hours (kWh) in EasyView, use the following formula:

KEYVAL kWh = IDT / 3600

You can add this key value to the information table properties and use it in other formulas.

Explanation:

IDT is similar to the key figure SUM. The difference is that SUM represents the total of all samples without considering elapsed time. In contrast, IDT is based on the sampling interval, assuming one second intervals, meaning time is factored into the total. With a one-second sampling interval, IDT and SUM will provide the same value.

Only IDT gives you:

  • "Kilowatt-seconds" directly.
  • Dividing by 60 gives you "kilowatt-minutes."
  • Dividing by 3600 gives you kilowatt-hours (kWh).

This approach ensures that time is properly accounted for in your energy consumption calculations, making it useful for energy analysis and reporting.

The formula editor can be found in EasyView Pro, allowing you to create and apply such formulas to your analysis.

 

Smooth a choppy curve

When measuring, you may sometimes capture temporary spikes or have a choppy signal. In these cases, you're often looking for trends and would prefer a smoother curve. This can be achieved by calculating the average over a certain number of samples ahead and a certain number of samples behind using the following formula:

GRAPH SmootherCurve (Bar) = VAVEL(ID1; 5)

Here, we have smoothed the curve ID1 by averaging 5 samples before and 5 samples after each data point. This method helps to reduce noise and provide a clearer view of the underlying trend in the data.

 

 

Absolute Humidity

In EasyView Pro, you can use formulas to calculate various measurements. Here's the formula to calculate absolute humidity. To do this, you need to measure temperature and relative humidity.

FN SaturationVaporPressure(Temp) = (Temp < 0) * (4.689 * (1.486 + (Temp / 100)) ^ 12.3) * (18.02 / (8314.3 * (273.15 + Temp))) * 1000 + (Temp >= 0) * (288.68 * (1.098 + (Temp / 100)) ^ 8.02) * (18.02 / (8314.3 * (273.15 + Temp))) * 1000 GRAPH "Absolute Humidity" (g/m³) = SaturationVaporPressure(ID2) * (ID1 / 100)

In this formula:

  • We assume that ID2 is the temperature and ID1 is the relative humidity.

You can use this formula in EasyView Pro to calculate the mass of water vapor per cubic meter of air (g water/m³). The formula assumes a pressure of 1000 hPa.

Explanation of Absolute Humidity:

Absolute humidity refers to the mass of water vapor in a cubic meter of air (g/m³). The maximum amount of water vapor the air can hold varies with temperature. At higher temperatures, the air can contain more water vapor before condensation occurs than at lower temperatures. Therefore, absolute humidity is three to four times higher in summer compared to winter.

For example:

  • At -10°C, the maximum absolute humidity is 2g/m³.
  • At 30°C, it is 30g/m³.
  • At 70°C, it is 200g/m³.

This variation is due to the higher rate of water evaporation in warmer conditions.

 

Convert Temperature Units

Do you want to convert your temperature measurements to another unit?

Here are the formulas for doing so. FN stands for function, followed by the formula for converting between different units. Below are six different functions, such as Celsius to Fahrenheit and Kelvin to Celsius.

The graph you want to create is generated after GRAPH. In the example below, Celsius is converted to Fahrenheit from values on channel ID1. If another conversion is needed, use one of the functions below.

FN CelsiusToFahrenheit(input) = input * 9/5 + 32 FN CelsiusToKelvin(input) = input + 273.15

FN FahrenheitToCelsius(input) = 5/9 * (input - 32) FN FahrenheitToKelvin(input) = 5/9 * (input - 32) + 273.15

FN KelvinToCelsius(input) = input - 273.15 FN KelvinToFahrenheit(input) = 9/5 * (input - 273.15) + 32

GRAPH DegreesFahrenheit (°F) = CelsiusToFahrenheit(ID1)

In the image below, the black line represents Celsius, and the red line represents Fahrenheit.

 

A0 Value for Disinfection

To ensure the quality of the cleaning process for surgical instruments, the A0 value is used. To verify that the proper conditions of time and temperature are met, the A0 value should be at least 600.

The A0 value represents the time in seconds at 80°C during which the number of microorganisms is reduced by one log (tenfold) with a 10°C temperature increase.

The A0 value is calculated as follows:

  • t = selected time in seconds
  • T = temperature in °C
  • A0 = A value when z is 10°C

Examples of A0 value 600:

  • 100 minutes at 70°C
  • 10 minutes at 80°C
  • 1 minute at 90°C

In EasyView, the A0 value can be calculated using the following formula:

SET Channel = ID1 GRAPH Time = VPOS(Channel) * 60 * 60 * 24 GRAPH A0(A0) = (10 ^ ((Channel - 80) / 10) * (Time - Time[-1])) + A0[-1]

This formula calculates the A0 value based on the temperature (channel ID1) over time. The time is computed in seconds, and the formula accounts for the reduction in microorganisms due to temperature increases.

For measurements where electronics are exposed to high temperatures, a durable logger with a special battery, such as the Tinytag Splash 2, is required. This logger has an IP68 rating and can withstand temperatures up to 105°C.

 

Recursion – Integration

The computational power in EasyView is significantly enhanced by the introduction of a "recursive operator." This allows you to refer to a "previous" or a "future" value relative to the one being processed "right now." The use of this operator is versatile, and the syntax is simple. You just add an index to the signal: ID1[-1]. Note that square brackets are used. The minus sign points to the past, and a plus sign or no sign refers to the "future."

An example:

GRAPH difference (°C) = ID1 – ID1[-1]

This formula will plot the differences between the "current" measurement and the previous one. The difference shows an increase or decrease, which is closely related to the derivative.

In the following example, we integrate to calculate the accumulated volume of a flow:

GRAPH integral (l) = integral[-1] + ID2 * interval

This formula will draw a curve that rises toward the final value, which represents the total accumulated volume. Make sure to perform a dimensional analysis before mixing variables, like apples and oranges.