Share this

Communication between RSView32 configuration software based on ActiveX protocol and MATLAB

2026-04-06 07:20:32 · · #1
Abstract: In the field of industrial control, configuration software has weak computing power when used for field monitoring, making it difficult to implement complex control strategies, while mathematical software Matlab can perform complex calculations. Establishing communication between configuration software and Matlab can achieve complementary advantages. This paper details the steps for communication between configuration software RSView32 and Matlab based on ActiveX technology. The research work in this paper opens up a new way to use configuration software to complete complex control algorithms in the field of industrial control, and provides new technical support for the integration of measurement and control systems and simulation systems. Keywords: Industrial control configuration software RSView32, mathematical software Matlab, communication 1. Introduction In the field of industrial control, how to more effectively implement control algorithms has always been a common concern. At present, industrial control configuration software has rich graphics functions and strong hardware communication capabilities, but its computing power is weak, making it difficult to implement complex control strategies. MATLAB language has powerful scientific computing capabilities, and with the help of its built-in toolbox, it can realize the calculation of various complex algorithms [1]. At the same time, in the process of developing industrial measurement and control systems, the integration of measurement and control systems and simulation systems is a current development direction [2]. Therefore, combining industrial control configuration software with MATLAB in industrial control to achieve complementary advantages has always been a hot topic in the field of automatic control. RSView32 is a configuration software package developed by Rockwell. It is the first MMI product to use ActiveX, Visual Basic Applications, and OPC (OLE for process control) in graphical display, providing monitoring, control and data acquisition functions. There are currently two ways to establish communication between RSView32 and MATLAB: DDE dynamic data exchange technology and ActiveX technology. ActiveX technology is developed on the basis of DDE, but there are still differences between them. ActiveX does not require the server to be running in advance when it is called. It is actually calling a component without requiring the program corresponding to the component to be running. This makes its functions more powerful and the statement structure simpler. Its only requirement is that MATLAB has been installed on the machine on which the program is running and can run successfully [3]. The use of DDE for communication has been mentioned many times in some papers, but there is rarely a detailed description of the use of ActiveX technology for communication between RSView32 and MATLAB. This paper introduces in detail the steps of ActiveX technology communication between the two [4]. 2. Communication Process First, input the required parameters in the main interface of RSView32. Data is then transmitted to Matlab for control calculations via communication. The results are then sent back to RSView32, and the results are displayed on its main interface. The communication process is shown in Figure 1 below . 3. Steps to Establish Communication Using ActiveX Controls: 3.1 Creating ActiveX Objects Before defining MATLAB objects in VBA, RSView32 and MATLAB 6.1 software must be installed on Windows, and the MATLAB program must be referenced in RSView32's VBA. The ActiveX object name of MATLAB is fixed as "Matlab.application". The specific program is as follows: ' Define the MATLAB instance object as a public variable Public objMATLAB As Object Private Sub form_initialize() ' Create a MATLAB instance Set objMATLAB = CreateObject("matlab.application") End Sub 3.2 Read a variable value into a tag in the RSView32 human-computer interface In order to receive input values, set a Solid Animation on the interface and assign it a tag. In VBA, associate the tag name with a variable: Set tAvalve7 = gTagDb("inoil\Avalve7") Here, Avalve7 is a tag name corresponding to Solid Animation, and tAvalve7 is a variable defined in VBA. In the human-computer interface, you can input data by dragging the scroll bar through the Solid Animation sliding animation. The data is stored in tAvalve7.value in VBA. 3.3 Using the PutFullMarix command in VBA to write the number into MATLAB. The format for writing data into MATLAB using the PutFullMarix command is: Call matlab.putfullMatrix("a", "base", Mreal, Mimag), where 'a' is the matrix variable name in MATLAB, 'base' is the variable type, 'Mreal' is the real matrix in the VBA program, and 'Mimag' is the imaginary matrix in VBA. To test the PutFullMarix command, a form was designed in RSView32 VBA, containing a CommandButton3. The CommandButton3_Click() event was programmed as follows. When running, clicking CommandButton3 in the form will transmit data from VBA to MATLAB via the PutFullMatrix() command, and then transmit it back to VBA via the getfullmatrix() command. Finally, the result "90" is displayed in Text1. Private Sub CommandButton3_Click() Dim matlab As Object Dim result As String Set matlab = CreateObject("matlab.application") Dim sita(1 To 6) As Double sita(1) = 0: sita(2) = 90: sita(3) = 0 sita(4) = -90: sita(5) = 0: sita(6) = 0 Dim Mreal(1 To 6, 1 To 1) As Double Dim Mimag() As Double Dim sitam() As Double Dim I As Integer Dim mreal2(1 To 6, 1 To 1) As Double Dim mimag2() As Double For I = 1 To 6 Mreal(I, 1) = sita(I) Next I Call matlab.PutFullMatrix("sitam", "base", Mreal, Mimag) Call matlab.getfullmatrix("sitam", "base", mreal2, mimag2) Text1 = mreal2(2, 1) End Sub 3.4 Executing a MATLAB command using the Execute command in VBA For example, the following program will open the MATLAB Command Windows window and display a 3D shaded surface graphic in the Figure No.1 window. Define the MATLAB instance object as a public variable Public objMATLAB As Object Private Sub form_initialize() 'Create a MATLAB instance Set objMATLAB = CreateObject("matlab.application") result = objMATLAB.execute("surf(peaks)") End Sub In the RSView32 interface, command buttons can be set, such as "Test". Open "Edit Button1" in the right-click menu of the button. In the interface shown in Figure 2, use Vbaexec begin to call the begin function in the VBA program. The program of the function is as follows: Private Sub CommandButton1_Click() Dim matlab As Object Dim result As String Set matlab = CreateObject("matlab.application") result = matlab.Execute("surf(peaks)") End Sub Public Sub begin() UserForm6.Show End Sub [align=center] Figure 2 Button setting interface in RSView32[/align] In this way, in the RSView32 interface, the "Test" button can be used to call the Command Windows in MATLAB. The window displays a three-dimensional shaded surface graphic in Figure No.1. 3.5 Using the GetFullMarix command in VBA to read the results. Executing this command transfers a matrix variable from MATLAB to a 1D or 2D array in a VBA program. The format is: Call matlab.getfullmatrix("a", "base", MReal, Mimag) For example, the following program will transfer data from the b array in MATLAB to the Mreal1 array in VB. MATLAB.execute "b=[1,2;4,7]" Dim mreal1(1 To 2, 1 To 2) As Double Dim mimag1() As Double Call MATLAB.getfullmatrix("b", "base", mreal1, mimag1) Text1 = mreal1(2, 2) 4. Conclusion This paper successfully established communication between RSView32 and MATLAB using the above steps, thus utilizing their respective advantages. Complex calculations are completed by MATLAB, while RSView32 provides a good human-computer interface and rich graphics display. This work opens up a new way for using configuration software to complete complex control algorithms in the field of industrial control, and provides new technical support for the integration of test system and simulation system. References [1] Shi Ying, Hong Rui, Qian Xiaolong. Data exchange technology between MATLAB and configuration software. Journal of Instrumentation. 2003, 24 (4): 337-340 [2] Wu Yuebin, Xie Shujun, Xu Li et al. The present and future of hydraulic simulation technology. Hydraulics and Pneumatics, 2002 (11): 1-3 [3] Wang Ying, Hu Zongjun, Zou Jietang et al. ActiveX: Implementation method of calling MATLAB from Visual Basic 6.0. Mechanical and Electrical Engineering. 1999 (5) [4] Xu Jianghua, Sun Rong, Shao Huihe. Doctoral dissertation: PID self-tuning simulation software based on KingSCADA, Excel and Matlab. Computer Engineering. 2003, 29 (3): 27-29
Read next

CATDOLL Katya Hard Silicone Head

The head made from hard silicone does not have a usable oral cavity. You can choose the skin tone, eye color, and wig, ...

Articles 2026-02-22