•   Topics

Gummi
I notice that math channels look different in Toolbox vs Toolset. Can anyone explain roughly the main differences and how to convert one to the other?
Quote 0 0
troberts
The maths functions between ToolBox and ToolSet are almost identical.
The only major difference between the two is the syntax used to define registers.

Although the function of registers is identical between Toolset and Toolbox, there are differences in the syntax (i.e. the way the code maths is written).

Within Toolbox, any name can be assigned to a register (such as @bright_# in the example below). Toolset cannot accept anything other than “@a#” for a register (as seen in example 1).

The flip side of this difference is the function “register” is not required (and therefore not valid) within Toolset. Registers are created simply from the “@a” function.

The way in which the value of a register is stated also differs between Toolset and Toolbox. An explicit “is equal to” is required in Toolbox using the “=” sign. This is seen in example 1. Within Toolset, the syntax acknowledges the existence and value of register in a single line of code, defined using brackets. See the example below.

The following example is the same register maths channel firstly written in Toolbox, and then written in Toolset:

register @bright_0; //register a variable called bright_0

register @bright_1; //register a variable called bright_1

register @bright_2; //register a variable called bright_2

//@bright_0 is given an initial value equal to the [Brightness] channel from the LDR,

@bright_0 = [Brightness];

//@bright_2 is given a historical value equivalent to @bright_1

@bright_2 = @bright_1;

//A function using the current and historical values of the [Brightness] channel applies a high pass filter to generate @bright_1

@bright_1 = ( @bright_2 + ( @bright_0 -@bright_2 ) * (( 0.02 * ( 2 * 3.142 ) * 0.02 ) /( ( 0.02 * ( 2 * 3.142 ) * 0.02 ) +1 )));

//@bright_1 is the output

@bright_1;

Things to note here are the initial generation of the registers using the “register” function, the naming convention for the registers and the requirement to use the “=” sign to give the registers value.

The same function in ToolSet is defined as follows:

a0 ( [Brightness] ) ;

a2 ( @a1 ) ;

a1 ( @a2 + ( @a0 -@a2 ) * ((0.02 * ( 2 * 3.142 ) * 0.02 ) / (  ( 0.02 * ( 2 * 3.142 ) * 0.02+1 ) ) ) ;

@a1

The important things to note here are the registers are generated simply by fact of their naming convention. Naming convention within Toolset must be of the form “@a” numbered accordingly. To generate a register and give a value to it the syntax “a0(x)” is used. This would generate a register named @a0 with value x.

The example given here happens to be an extremely powerful high pass filter function that gives a very slow transition for the ICD brightness. This channel could be altered and applied to any number of channels being logged. Changing the filter variable (in the given case, equal to 0.02) will speed up or slow down the reaction of the channel.

Cosworth Support
Cosworth Electronics

Quote 0 0