本人愿和同道中人共同探讨西门子技术范围包括(200/300/400/Wincc/Hmi)
技术文章参考博客! http://jiansiting.gkbk.com
to xiaolou, sorry , i only using english.
Many different high-performance functions for process control process multiple input and output sizes and therefore in the relevant specialist literature they are formulated mathematically using matrices and matrix operations. Examples include state regulators, monitors, Kalman filters, predictive regulators and process simulators.
Such functions are relatively easy to implement on a PC by incorporating prepared numerical libraries, but are very complicated to realize on the SIMATIC systems (S7 or PCS 7), because all matrix operations must be programmed manually through nested loops in the high-level language SIMATIC S7-SCL.
Solution:
As a solution we are offering you a small library of prepared functions for processing matrices in S7-SCL. A matrix is declared as a UDT (User-Defined Data Type), that contains header information about the number of rows and columns and the matrix elements in the form of a two-dimensional array. Vectors are handled as special cases of matrices with a column number of 1. At least the following prepared functions are provided as FCs for all variables of this data type:
Matrix Addition and Subtraction
Matrix Multiplication
Transposition
Inversion
Functions are also provided to generate a zero matrix or a unit matrix of preset dimensions
User-defined data type (UDT): "Matrix"
The user-defined data type "MATRIX" is a data structure (STRUCT), which consists of two integer variables and a two-dimensional array of the Real type. The integer variables specify the number of rows and columns of the matrix concerned and the array contains the matrix elements. Since it is not possible to change the dimensions of the array dynamically, the size of the field must be defined beforehand in the variable declaration. Here you must make sure that the dimensions selected match at least the largest matrix occurring in the S7 program. An array size of 4 x 4 has been chosen as the presetting. To simplify matters no separate data type has been defined for the vectors, but the data type "MATRIX" has been used as well.
Function for matrix addition: FC "MxAdd"
The function "MxAdd" is for adding two matrices of the data type MATRIX. Before calculation a check is made as to whether both matrices have the same dimensions. In case of error, a matrix with the dimensions 0x0 is returned as a result.
Example for calculating AplusB = Am + Bm in the S7-SCL source text (sh.TestMatrixOperationen.SCL) with the function call:
MxAdd( MxA:= Am, MxB:= Bm, MxC:= AplusB);
Function for matrix subtraction: "FC MxSub"
The function "MxSub" subtracts two matrices of the data type MATRIX from each other. Here, too, before calculation a check is made as to whether both matrices have the same dimensions and in case of error a 0x0 matrix is returned as a result.
Function for matrix multiplication: FC "MxMul"
The function "MxMul" is for multiplying two matrices. The calculation is executed only if the number of columns of the first matrix matches the number of rows of the second matrix. Otherwise the return value of the function is once again a matrix with the dimensions 0x0.
Function for matrix transposition: FC "MxTrans"
The function "MxTrans" returns the transpose of a transferred matrix.
Function for matrix inversion: FC "MxInv"
The function "MxInv" is for inverting a regular, quadratic matrix. Since the dimensions of the matrix to be inverted in the estimation algorithm are too small, and the difference in efficiency between various inversion procedures is therefore practically negligible, a very simple procedure is implemented: the so-called Shipley-Coleman procedure. Besides its simplicity, the characteristic of this inversion algorithm is that it is an "in-place" procedure, there is no need for any other auxiliary variable for inverting the MATRIX type. If the function is called with a non-quadratic matrix, then a 0x0 matrix is returned as a result.
Function for generating zero matrices: FC "MxNull"
The function "MxNull" is used for generating a quadratic zero matrix. The dimensions of the zero matrix are transferred to the routine via the input parameter "dim". If a value less than or equal to zero is selected by mistake for "dim", then this function also returns a 0x0 matrix as a result.
Function for generating unit matrices: "FC MxEin"
The function "MxEin" is for generating a quadratic unit matrix. The dimensions here are also defined via the input parameter "dim". Error handling is identical to that of the "MxNull" function.
Billable software (payment by SIMATIC Card / Automation Value Card AVC):
The attached download contains a STEP 7 library with the functions described above. The library contains the blocks and the source code with German and English comments.
剑工:
我想用S7-200PLC与富士变频器进行通讯,我没有做过通讯,想用S7-200的自由口通讯,不知道您能不能帮指点下。谢谢!liruitu@sina.com