Basic Math Functions
Both program and logic banks allow for the following mathematical operations:
Operation | Format | Description |
= | P1.1=P2.1+V1.1 | Equals. Sets P1.1 to the result of the following operation |
+ | P1.1=P2.1+V1.1 | Addition. Sets P1.1 to the sum of P2.1 and V1.1 |
- | P1.1=P2.1-V1.1 | Subtraction. Sets P1.1 to the difference of P2.1 and V1.1 |
* | P1.1=P2.1*V1.1 | Multiplication. Sets P1.1 to the product of P2.1 and V1.1 |
/ | P1.1=P2.1/V1.1 | Division. Sets P1.1 to the quotient of P2.1 and V1.1 |
Advanced Math Functions
In addition to the above basic math functions, there are some advanced math functions available as well:
U1 | Sine |
This function will calculate the sine of the operand. The functions is scaled such that: | |
B1 X0 S1.1=U1(V1.1) V1.1=V1.1+1 X- END | This bank will set speed S1 to the sine of V1. V1 is then incremented. The bank is then looped indefinitely. |
U2 | Cosine |
This function will calculate the cosine of the operand.
The functions is scaled such that:
| |
B1 X0 S1.1=U2(V1.1) V1.1=V1.1+1 X- END | This bank will set speed S1 to the cosine of V1. V1 is then incremented. The bank is then looped indefinitely. |
U3 | Square Root |
This function will calculate the square root of the operand.
The value returned by this function is an integer value. For example √7=2. For higher accuracy it is suggested to scale the solution by orders of 10. | |
P1.1=P2.1+U3(V1.1) | Position one is equal to position two plus the square root of variable one. |
U5 | Polynomial Using N |
Performs a polynomial calculation on the desired operand using the N register as the polynomial coefficients.
N0 is the polynomial order, to a maximum of 25 N1-N25 are the polynomial coefficients
N0=n
| |
N0=4 V1.1=U5(P2.1) | V1.1=(N1)+(N2)(P2.1)+(N3)(P2.1)2 +(N4)(P2.1)3 |
U6 | Polynomial Using R |
Performs a polynomial calculation on the desired operand using the R register as the polynomial coefficients.
R0 is the polynomial order, to a maximum of 25 R1-R25 are the polynomial coefficients
R0=n | |
N0=4 V1.1=U5(P2.1) | V1.1=(R1)+(R2)(P2.1)+(R3)(P2.1)2 +(R4)(P2.1)3 |