The process simulation system of WEDM (WEDM) based on BP neural network needs the design function of process database management, process effect prediction and processing parameter optimization. With the help of MATLAB's Neural network toolbox, we can set up good prediction model of process effect and parameter optimization model, which is the main function requirement of process simulation software. VB is an excellent visual programming tool software under Windows operating system, which has unique advantages in user interface design and rapid development. At the same time, MATLAB simulation software with its powerful scientific calculation function and open development thought make it become the most popular simulation calculation tool at present. Combining the advantages of the two development environments, VB and MATLAB can be used to realize the programming development of process simulation software.
The foreground user interface is developed under the VB development environment, and the real-time simulation of the backstage model is realized by using the powerful calculation function of MATLAB. In order to realize the data transmission between the foreground interface and the background simulation environment, the interface between VB and MATLAB is designed by using ActiveX Automation technology, and the ActiveX Automation connection between VB application and MATLAB simulation environment is established. It realizes the call of MATLAB Simulation command in VB Environment, and displays the simulation result in real time in the VB friendly user interface.
1 interface analysis between VB and MATLAB
1.1 vb and Matlab interface form
In order to be able to fully utilize the MATLAB system provides the rich function library, MATLAB itself provides the application interface API (MATLAB application program Interface). Therefore, VB and MATLAB interface design has a variety of ways to achieve.
(1) Borrow C + + and MATLAB interface, MATLAB program file (*. M) compiled into a dynamic-link library (*. DLL), VB in the code to generate the function in the DLL, in order to achieve the algorithm, easy to users out of the MATLAB environment to use. Because the algorithm uses C + + statement, the running speed is faster, it can be applied to real-time operation. But this method has a higher requirement for developers in setting and programming.
(2) The interface is implemented by using the Matrixvb method of matrix function library embedded in VB. MATRIXVB is a Third-party plug-in, using the same functions as MATLAB, syntax embedded in VB, you can use the functions of VB, commands like the use of MATLAB functions. The syntax and function of this method is simple, the programming efficiency is very high, almost completely can integrate into the VB language, especially the processing of graphics is very convenient, make up for other methods in the graphics processing weaknesses. But because it still uses the explanation execution, the execution efficiency is low, therefore the real-time operation is difficult to realize, especially to MATLAB each kind of toolbox's invocation is especially difficult.
(3) In Visual Basic by invoking the engine interface of MATLAB, using Windows ActiveX technology and MATLAB data interaction. Through object. The EXECUTE statement uses the function libraries and graphics libraries provided by MATLAB directly in the program.
1.2 ActiveX Automation Technology
ActiveX is an automated technology that supports component integration with Microsoft Windows protocols that can integrate components developed under different environments into one application; ActiveX is also an object-oriented technology, belonging to the Component Object Model (COM) Subclass. COM defines the object model for all ActiveX objects, and each ActiveX object supports a certain interface, which supports different methods, properties, and events. Use these methods to carry out the corresponding action, to help the client achieve certain functions. MATLAB supports two types of ActiveX technologies: ActiveX control container and ActiveX Automation. ActiveX control containers can integrate different ActiveX controls into one application, while ActiveX Automation is a protocol that allows one application (client) to control another application (server-side). In this article, MATLAB is the server side, VB is the client, through Automation, the client can execute MATLAB command, and the work space with MATLAB data exchange, to achieve the call of MATLAB to train neural network purposes.
2 Application of ActiveX technology in interface design
The function of MATLAB ActiveX Automation service mainly includes the MATLAB command in the MATLAB working space, the access matrix operation directly to the working space.
MATLAB provides an Automation object, whose external name is MATLAB. Application, support COM technology. External programs (such as VB) provide a function via COM technology, get pointers supported by Automation server objects, and control and use automation objects by calling interface functions. In VB application, the creation of the ActiveX object of MATLAB, you can use this object contains various methods to achieve the call to MATLAB. Matlab. The Application object contains 3 methods, namely Execute,getfullatrix and Putfullmatrix.
(1) BSTR Execute ([in]bstr Command): BSTR represents a wide string type, which is the same as the data format used by the VB store string. The method receives the string command and executes it in MATLAB, returning the result as a string.
(2) void Getfullmatrix ([in]bstr name[in]bstr workspace,[in,out] SAFEARRAY (doume) *PR, [In,out]safearray (double) *pi) : The Getfullmatrix method retrieves a complete solid or virtual type Mxarray from the specified workspace, in fact the part and the imaginary part are stored in 2 separate double arrays respectively. The Getfullmatrix method can be used to transfer a matrix variable in MATLAB to a one-dimensional or two-dimensional array in VB program. In which, name specifies the matrix variable name in MATLAB; workspace specifies the Matlab workspace where the matrix is located; PR refers to the real part array in VB program, PI refers to the imaginary part of VB program.
(3) void Putfullmatrix ([In]bstr name,[in]bstrworkspaee,[in,out]safearray (Double) *PR, [In,out] SAFEARRAY (double) *pi) : The Putfullmatrix method puts a mxarray into the specified workspace. The meanings and calling methods of each parameter are similar to the Getfullmatrix method.
Application of 3 VB calling Matlab in the development of WEDM simulation software
The process simulation system of WEDM (WEDM) based on BP Neural network is mainly used to realize the management of process database, the prediction of process effect and the optimization of processing parameters. The neural network Toolbox called Matlab in VB Development environment is to establish the prediction model of process effect and the optimization model of processing parameters, which is the main function of simulation system. The core code for the modeling section is as follows:
The function of this part of the program is VB to the user input parameters to the MATLAB space, in the space of MATLAB using the Neural Network Toolbox Training Network, the results output. Then the modeling of several models of simulation system is realized. Array 1 is a sample input data for training neural networks, including workpiece thickness T (unit: MM), pulse width Ton (unit: s), pulse interval Toff (unit: s), peak current IP(unit: A), Gap Voltage vS(unit: v); Array 2 is the sample output data, including the cutting speed vw(unit: mm2/min) surface roughness Ra(unit: μm). Fig. 1 is the main control interface of WEDM process simulation system, including processing parameter database, system modeling, process effect prediction and parameter optimization. When establishing the model, the parameter training model in the database is used, and after the model training is completed, the processing effect corresponding to different processing parameters can be predicted, and the processing parameters of the given material and thickness are optimized, and the optimization results are given.