Multiple statements and variables – MTS Series 793 User Manual
Page 376
•
real tanh(real x)
•
int size(real x[])
•
int isize(int x[])
•
real shift(real x[],real y)
•
int ishift(intx[],int y)
•
real avg(real x[], int y)
•
real rate()
•
real pi()
•
real mod(real x, real y)
•
real clip(real x, realMin, realMax)
•
int iclip(int x, int iclipMin, int iclipMax)
•
int interlock(int b)
•
int programInterlock(int b)
•
int error(int id)
•
real myFIR(real input, real coef[], real state[])
•
real myIIR(real input, real num[], real den[], real state1[])
•
real FIR(real input, int fir[])
•
real IIR(real input, int iir[])
Multiple Statements and Variables
There is a limit to what any single equation can accomplish. It may be convenient or necessary to break the
calculation equation into multiple statements. This requires variables to store intermediate results. Variables
can also be used to remember data from one clock tick to the next.
Using variables for intermediate results
You can declare variables by specifying the data type followed by a comma-separated list of variable names.
For example, the following defines three floating-point variables (x, y, and z) and an integer variable (count):
real x, y, z;
int count;
The names of variables follow the same rules as other names. If they contain spaces or other special
characters, you must put them in quotes.
By using variables, intermediate results can be evaluated and used in the main equation. For example:
real x;
x = “Axial Force 1” * Area;
“Axial Stress” = p0 + (p1 + (p2 + p3 * x)* x) * x;
The variables p0, p1, p2, p3 and Area are calculated parameters.
While this could have been done in a single expression, it would have required that the multiplication x to be
done three times and that would have been much less readable.
376 MTS Series 793 Control Software
Calculated Signals