Short description
The mathematic instruction block calculates the value AQ of an equation formed from the user-defined operands and operators.
|
Connection |
Description |
|
Input En |
A positive edge at input En enables the mathematic instruction function block |
|
Parameter |
V1: Value 1: First operand V2: Value 2: Second operand V3: Value 3: Third operand V4: Value 4: Fourth operand Range of values: -32768 to 32767 Operator 1: First operator Operator 2: Second operator Operator 3: Third operator Priority 1: Priority of first operation Priority 2: Priority of second operation Priority 3: Priority of third operation p: Number of decimals Possible settings: 0, 1, 2, 3 |
|
Output AQ |
The output AQ is the result of the equation formed from the operand values and operators. AQ will be set to 32767 if a divide by 0 or overflow occurs, and -32768 if a negative overflow (underflow) occurs. |
|
|
0BA1- 0BA5: The mathematic instruction function block did not exist prior to 0BA6. |
Parameters V1, V2, V3, and V4
The values V1, V2, V3, and V4 can be provided by the actual value of another already-programmed function:
Analog comparator: Ax - Ay
Analog threshold trigger: Ax
Analog amplifier: Ax
Analog multiplexer: AQ
Analog ramp: AQ
Mathematic instruction: AQ
PI controller: AQ
Up/Down counter: Cnt
For the 0BA7 and later version devices, you can additionally use the actual values of the following already-programmed functions:
On-delay: Ta
Off-delay: Ta
On-/off-delay: Ta
Retentive on-delay: Ta
Wiping relay(pulse output): Ta
Edge triggered wiping relay: Ta
Asynchronous pulse generator: Ta
Stairway light switch: Ta
Multiple function switch: Ta
Stopwatch: AQ
Analog filter: AQ
Average value: AQ
Max/Min: AQ
Threshold trigger: Fre
You select the required function by the block number.
Parameter p (number of decimals)
Parameter p applies to the display of V1, V2, V3, V4 and AQ in a message text.
Description of the function
The mathematic instruction function combines the four operands and three operators to form an equation. The operator can be any one of the four standard operators: +, -, *, or /. For each operator, you must set a unique priority of High ("H"), Medium ("M"), or Low ("L"). The high operation will be performed first, followed by the medium operation, and then by the low operation. You must have exactly one operation of each priority. The operand values can reference another previously-defined function to provide the value. The mathematic instruction function rounds the result to the nearest integer value.
The number of operand values is fixed at four and the number of operators is fixed at 3. If you need to use fewer operands, use constructions such as " + 0" or " * 1" to fill the remaining parameters.
You can also configure the behavior of the function when the Enable parameter "En"=0. The function block can either retain its last value or be set to 0.
Possible errors: Zero division and overflow
If the mathematic instruction function block execution results in zero division or overflow, it sets internal bits that indicate the type of error that occurred. You can program an mathematic instruction error detection function block in your circuit program to detect these errors, and to control the program behavior as needed. You program one mathematic instruction error detection function block to reference one specific mathematic instruction function block.
Examples
The following tables show some simple example mathematic instruction block parameters, and the resulting equations and output values:
|
V1 |
Operator1 (Priority 1) |
V2 |
Operator2 (Priority 2) |
V3 |
Operator3 (Priority 3) |
V4 |
|
12 |
+ (M) |
6 |
/ (H) |
3 |
- (L) |
1 |
Equation: (12 + (6 / 3)) - 1
Result: 13
|
V1 |
Operator1 (Priority 1) |
V2 |
Operator2 (Priority 2) |
V3 |
Operator3 (Priority 3) |
V4 |
|
2 |
+ (L) |
3 |
* (M) |
1 |
+ (H) |
4 |
Equation: 2 + (3 * (1 + 4))
Result: 17
|
V1 |
Operator1 (Priority 1) |
V2 |
Operator2 (Priority 2) |
V3 |
Operator3 (Priority 3) |
V4 |
|
100 |
- (H) |
25 |
/ (L) |
2 |
+ (M) |
1 |
Equation: (100 – 25) / (2 + 1)
Result: 25