Dyno2 Dynamometer Software – custom functions

Functions module enables user to create custom functions that can calculate values, check conditions and do some advanced tasks like PID control. Functions can be used to:

  • control physical dynamometer outputs
  • trigger actions like CAN message sending or software tasks
  • create mathematical channels that show new information in charts
  • provide data to be exported to CAN bus
  • create PID control loop

Functions can be created in SETTINGS / Functions. Functions are processed every 10ms from the top of the list. The software uses standard conversion from numbers to logical values: 0 = false, value other than 0 = true.
Shortcuts available in function list are:

  • N – new function
  • Enter – edit function
  • Del – delete function
  • Alt + Up – move function up – earlier in processing queue
  • Alt + Down – move function down – later in processing queue

Generic function configuration contains:

  1. Name used to create dyno data channel key
  2. Operator that defines what the function will do
  3. Arguments that are used by the function – constants or data channels
  4. Output physical quantity of the function – to provide adequate unit conversions when the function is displayed

The whole function system works on SI units when doing calculations, so you don’t have to worry about unit conversions. You know that Force = Torque / Distance. Just select correct quantity and unit for constants and correct function output quantity (4).
In above example, load cell channel (which is internally in Nm) is divided by distance 30cm (which is converted to 0.3m for internal calculation). The result in N is internally assigned to function, but it is converted to kN for display.

Data channels (variables) can be selected with double click on the variable name field. Only variables that has selected quantity are displayed in the selection list.
Constant values are entered manually.

Example function to control on / off type fan:

The function interface should be interpreted in the following way:

We are creating a function named „Fan control” (1) which uses > greater than operator (2).
Function result (3) = variable (4) of „speed” quantity (5) and key „dyno_speed” must be greater than (7) constant (8) of „speed” quantity (9) value „10” (10) and “km/h” unit (11).
New variable channel created by the function has logic quantity (12). This quantity must be used for functions that will be used to trigger controller outputs, to be visible in selection lists.
A newly created function can be assigned to control physical output in RUN tab.

Running shell commands

Functions module can run custom shell commands. As the Linux shell is very powerful, this enables the software to interact in many ways with other applications or systems. Among the possibilities there are file creation, copying, and interaction with network devices or internet services.

Shell command example in function.

The shell command is executed in background without blocking the application when the function boolean value goes from false to true.

Equations

To speed up creation of a function that operates on multiple variables, the function can be defined as an equation.

Functions and operators available for use in equations:

NameArgc.Explanation
sin1sine function
cos1cosine function
tan1tangens function
asin1arcus sine function
acos1arcus cosine function
atan1arcus tangens function
sinh1hyperbolic sine function
cosh1hyperbolic cosine
tanh1hyperbolic tangens function
asinh1hyperbolic arcus sine function
acosh1hyperbolic arcus tangens function
atanh1hyperbolic arcur tangens function
log21logarithm to the base 2
log101logarithm to the base 10
log1logarithm to base e (2.71828…)
ln1logarithm to base e (2.71828…)
exp1e raised to the power of x
sqrt1square root of a value
sign1sign function -1 if x<0; 1 if x>0
rint1round to nearest integer
abs1absolute value
minvar.min of all arguments
maxvar.max of all arguments
sumvar.sum of all arguments
avgvar.mean value of all arguments
OperatorDescriptionPriority
&&logical and1
||logical or2
<=less or equal4
>=greater or equal4
!=not equal4
==equal4
>greater than4
<less than4
+addition5
subtraction5
*multiplication6
/division6
^raise x to the power of y7
OperatorDescriptionRemarks
?:if then else operatorC++ style syntax

Units

The Dyno2 system is designed to save you the trouble of converting the units. Under the hood, everything works in SI units, and you should take advantage of that. If you’re using the software correctly, the input conversion from some units should take place at the sensor characteristics or CAN input definition, etc., and the conversion to your preferred units should take place when you display the data, by selecting the unit in channel setup. I’ll show this on an example of engine volumetric fuel rate that you get from the ECU through the OBD/UDS system.

The OBD standard specifies that when you take the raw digital number you get from ecu, you need to use the equation (1) to get the value in L/h. You specify this input unit in (2) to let the software know how to convert it to the internal SI units (which is m³/s). You want the flow displayed in gallons per minute? No problem. Set it in (3). That’s it.

I mention this in the functions article, because when working with functions, you need to be aware how the units system work to avoid frustration. Take, for example, the power calculation from torque and rotational speed.

If you’re working in units commonly used in Europe, it looks like this:
Power [kW] = Torque [Nm] * Rotational Speed [RPM] / 9549 [RPM * Nm / kW]
Nm is a basic SI unit, but the RPM and kW makes the problem and requires the magic number 9549 to make it work.

If you’re in the USA, the equation for you looks like this:
Power [HP] = Torque [ft-lb] * Rotational Speed [RPM] / 5252 [RPM * ft-lb / HP]
Your magic number is 5252 which is used to get power in HP from torque in ft-lb and speed in RPM.

Now, if you create a function in Dyno2 software, the equation you use is:
Power [W] = Torque [Nm] * Rotational Speed [rad/s]
Pure beauty of the SI system. You don’t need to use any magic numbers. Don’t be scared of the Watt at the output. You can display the power in any unit you want later. Don’t be scared of the rad/s for rotational speed. The software already has the speed in this unit internally.

The system can become a little tricky if you’re going to implement equations that assume that the input and output is in some specific units that are not SI and you use some constant to calculate one from another.
For example, you want to calculate theoretical Mass Fuel Flow from Power and BSFC. You know that your engine has a BSFC constant of 0.37 lb/(HP*h).
The equation basically should be:
Mass Fuel Flow [lb/h] = Power [HP] * BSFC [lb/(HP*h)]
I hope that you still remember, that even if you have the power displayed in HP everywhere in the software, then internally it is in SI unit (Watt). Because of this, the equation in this form won’t work. There are two ways to explain why it would not work:
1. Because the Power and Mass Fuel Flow that goes in and out of the equation is not in HP and lb/h but in SI units internally (W and kg/s).
2. Because the BSFC constant you’re going to put in the equation is not in SI units (kg/(W*s)).

If you know that your equations works on SI units, and you know that your constant (like BSFC) are in SI units, then you don’t need to do anything extra. If you know, it’s in other units, you have the way to tell this to the function module without figuring out the unit conversion yourself. To do this, you can convert your BSFC in lb/(HP*h) to SI units like this:

Example of constant with complicated quantity

Where A is the Engine Power, B is the BSFC in lb/(HP*h), C and D are used to convert the units of BSFC.

One final note, so you don’t overcomplicate things. BSFC in the previous example has a quantity that is a relation of power and mass flow. If the constant you are using in your equation has a more basic quantity that already exists in the system, like a distance, you can just select the appropriate quantity and unit and enter your constant.

Simple constant example