你现在位置:首页>技术论文>软件知识>正文
基于SCL语言的矩阵计算
日期:2009-12-2 8:21:56 点击:
来源:本站整理
作者:
点击【】放大字体.

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.

W1WW_P4LCJS_COM-PLC-技.术_网

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.
WWcW_PLCJS_COM-PLC-技.术_网

Solution:
WWW.PLCJS.COM——可编程控制器技术门户

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:
WWW_P※LCJS_COM-PLC-)技.术_网

Matrix Addition and Subtraction
WWW_PL※CJS_COM-PLC-技.术_网

Matrix Multiplication
WW.W_PLCJS_COM-PLC-技.术_网

Transposition
W1WW_P4LCJS_COM-PLC-技.术_网

Inversion
WWW_PLCJ-S_COM-PLC-技.术_网(可-编程控-制器技术-门户)

Functions are also provided to generate a zero matrix or a unit matrix of preset dimensions
WWW_PLC※JS_COM-PmLC-技.术_网

User-defined data type (UDT): "Matrix"
WWW_PLC※JS_COM-PmLC-技.术_网

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.
plcjs.技.术_网

Function for matrix addition: FC "MxAdd"
WWW※PLCJS_COM-PL#C-技.术_网(可编※程控※制器技术门户)

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.
WWW_PL※CJS_COM-PLC-技.术_网

Example for calculating AplusB = Am + Bm in the S7-SCL source text (sh.TestMatrixOperationen.SCL) with the function call:
WWW_P※LCJS_CO※M-PLC-技-.术_网

MxAdd( MxA:= Am, MxB:= Bm, MxC:= AplusB);
P_L_C_技_术_网——可——编——程——控-制-器-技——术——门——户

Function for matrix subtraction: "FC MxSub"
WWW_PLC※JS_COM-PmLC-技.术_网

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.
WWW_PLCJS※COM-PLC-技×术_网(可编程控※制器技术门户)

Function for matrix multiplication: FC "MxMul"
WW.W_PLC※JS_C,OM-PL,C-技.术_网

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.

本新闻共2页,当前在第11 2  
P_L_C_技_术_网——可——编——程——控-制-器-技——术——门——户

评论内容
载入中...
载入中...
P
L
C



|










|


P
L
C









·最新招聘信息
·最新求职信息
·推荐产品
·推荐厂商
·栏目热门排行
·站内热门排行