Math Blocks

[ 1 avg ] [ 2 div ] [ 3 isEven ] [ 4 isOdd ] [ 5 max ] [ 6 min ] [ 7 modulo ] [ 8 mult ] [ 9 neg ] [ 10 sineWave ] [ 11 sub ] [ 12 threshold ] [ 13 aboveBy ] [ 14 abs ] [ 15 belowBy ] [ 16 limit ] [ 17 pow ] [ 18 random ] [ 19 reset ] [ 20 sqrt ] [ 21 within ]
  • add - Addition: '∑ vals'. Any val which doesn't evaluate to a number is ignored. If no vals evaluate to a number then return null.

  • avg - Fold vals their standard average or arithmetic mean. Any val which doesn't evaluate to a number is ignored. If no vals evaluate to a number then return null.

  • div- Multiply: 'vals₀ × vals₁ × vals₂ ...'. Any val which doesn't evaluate to a number is ignored. If no vals evaluate to a number then return null.

  • isEven - Check if a number is even whole integer

  • isOdd - Check if a number is odd whole integer

  • max - Maximum of vals. Any val which doesn't evaluate to a number is ignored. If no vals evaluate to a number then return null.

  • min - Minimum of vals. Any val which doesn't evaluate to a number is ignored. If no vals evaluate to null

  • modulo - Modulo/remainder: 'a % b'. Return null if a or b doesn't evaluate to number.

  • mult - Multiply: 'vals₀ × vals₁ × vals₂ ...'. Any val which doesn't evaluate to a number is ignored. If no vals evaluate to a number then return null.

  • neg - Negate: '-val'. Return null if val doesn't evaluate to number.

  • sineWave - Generate a sine wave

  • sub - Subtract: 'a - b'. Return null if a or b doesn't evaluate to number.

  • threshold - Threshold returns true when input is above or below a setpoint with configurable deadband.

  • aboveBy - Check if the base number is above the input number by a threshold

  • abs - Return the absolute value of the number

  • belowBy - Check if the base number is below the input number by a threshold

  • limit - Limit val between an inclusive min and max

  • pow -  Power a^b. Returns null if a or b does not evaluate to a number

  • random - Generate a random number between min and max inclusive on every cycle

  • reset - Reset block computes output based on two linear equations. The input is clipped to inLo and inHi, the percentage of input along the linear segment between inLo and inHi is computed, and then that percentage is output as a Number between outLo and outHi.

  • sqrt -  Sqrt: '√val'. Return null if val does not evaluate to a number.

  • within - Verifies if the provided numbers are within an offset from the base

These Blocks can be found in the Block Library in the Math group.

 add

Calculates a total or sum of all inputs. Any value that doesn't evaluate to a number is ignored. If no values evaluate to a number then returns null.
In this example, we are adding currents A, B, and C to get Total Current.

avg

Calculates an average value of all inputs. Any value that doesn't evaluate to a number is ignored. If no values evaluate to a number then returns null.
In this example, we are creating an average of Currents A, B, and C to get the Average Current.

div

Divides input b from input a. (a divided by b). Any value that doesn't evaluate to a number is ignored. If no values evaluate to a number then returns null.
In this example, we are dividing the total current by the number of inputs (3) to calculate the Average Current.

isEven

Checks to see if a number is an even number (a multiple of 2). Also, the input must be a whole number (integer). 

isOdd

Checks to see if a number is an odd number (not a multiple of 2). Also, the input must be a whole number (integer).
In the example below, 2+5=7 which is an odd number. So isEven is false; and isOdd is true.

max

Extracts the largest of various number input values. Any value that doesn't evaluate to a number is ignored. If no values evaluate to a number then returns null.

min

Extracts the smallest of various number input values. Any value that doesn't evaluate to a number is ignored. If no values evaluate to a number then returns null. 
In the example below, the maximum (greatest) value of the three current inputs is 99.64, while the minimum (lowest) value is 58.37.

modulo

Modulo is the remainder (remaining whole number) after input a is divided by input b. Returns null if a or b doesn't evaluate to number.
In the example below (14 divided by 3), 3 goes into 14 four times to equal the number 12, which leaves a remainder of 2 (14-12=2).

mult

Multiply two or more input values. Any value that doesn't evaluate to a number is ignored. If no values evaluate to a number, then returns null.
There is no pre-defined limit to the number of input variables (though there may be a practical limit).  
In the example below (2x3x5), 2x3= 6 and then 6x5=30. So, the result (product) is 30.

neg

Negate reverses the math sign + or - of the input value to result in the opposite sign. Returns null if value doesn't evaluate to a number.
In the examples below, see how the math sign of both inputs have been reversed in their respective results.

sineWave

Generates a number output (result) based on a sine wave algorithm. min is the lowest number of the sinewave and max is the highest number of the sinewave. 
Period is in minutes and determines the amount of time it takes to complete one full cycle of the sinewave.  In the example below, the result will be a number between 70 and 90. The output will go up from 70 to 90 in 30 seconds; and then it will go back down from 90 to 70 in the next 30 seconds. That completes a full sinewave in a 1 minute period. The output is continuous. 

sub

Subtract: 'a - b'. Return null if a or b doesn't evaluate to number.

threshold

Threshold returns true when input is above or below a setpoint with configurable deadband. The deadband is only applied when the output is going from true to false.

aboveBy

Check if the base number is above the input number by a threshold

abs

Return the absolute value of the number\

belowBy

Check if the base number is below the input number by a threshold

limit

Limit val between an inclusive min and max

pow

Power a^b. Returns null if a or b does not evaluate to a number

random

Generate a random number between min and max inclusive on every cycle

reset

Reset block computes output based on two linear equations. The input is clipped to inLo and inHi, the percentage of input along the linear segment between inLo and inHi is computed, and then that percentage is output as a Number between outLo and outHi.

sqrt

Sqrt: '√val'. Return null if val does not evaluate to a number.

within

Verifies if the provided numbers are within an offset from the base