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:
- Name used to create dyno data channel key
- Operator that defines what the function will do
- Arguments that are used by the function – constants or data channels
- 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.
The shell command is executed in background without blocking the application when the function boolean value goes from false to true.
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:
|asin||1||arcus sine function|
|acos||1||arcus cosine function|
|atan||1||arcus tangens function|
|sinh||1||hyperbolic sine function|
|tanh||1||hyperbolic tangens function|
|asinh||1||hyperbolic arcus sine function|
|acosh||1||hyperbolic arcus tangens function|
|atanh||1||hyperbolic arcur tangens function|
|log2||1||logarithm to the base 2|
|log10||1||logarithm to the base 10|
|log||1||logarithm to base e (2.71828…)|
|ln||1||logarithm to base e (2.71828…)|
|exp||1||e raised to the power of x|
|sqrt||1||square root of a value|
|sign||1||sign function -1 if x<0; 1 if x>0|
|rint||1||round to nearest integer|
|min||var.||min of all arguments|
|max||var.||max of all arguments|
|sum||var.||sum of all arguments|
|avg||var.||mean value of all arguments|
|<=||less or equal||4|
|>=||greater or equal||4|
|^||raise x to the power of y||7|
|?:||if then else operator||C++ style syntax|