The hottest PLC monitoring system based on VB and

  • Detail

Design of PLC monitoring system based on VB and Mitsubishi MX components

in recent years, PLC (programmable logical controller) has become an absolute mainstream controller in the field of industrial control with its capabilities of analog quantity, digital quantity, man-machine interface and network communication, and continues to play an increasingly important role in other industries. In order to realize the real-time monitoring of the site, it is necessary to obtain the status and internal data of the controller, and realize the real-time communication between PLC and PC, so as to integrate the management, monitoring and control of the site. People usually choose to use configuration software to realize on-site monitoring! Temporary control, because most monitoring software needs to be paid, the cost is relatively high, and it can not give full play to the maximum benefits. Therefore, self-made monitoring software is a good choice. In this paper, Microsoft's Visual Basic 6.0 integrated development environment is used as the development platform of application software, and the third-party control MX component released by Mitsubishi company is used as the underlying driver interface to call various functions in act control to access PLC, and in terms of hardware, only a communication cable with a programming port is needed to develop the monitoring system. Such a communication mode has low requirements for the hardware of the communication module and does not need complex communication protocols. It can access the accessible data in the PLC by calling the functions in the act control, which is convenient for debugging, high programming efficiency and short development period

1 programming steps

according to the prompt that MX component control is applied to the book, establish the application according to the process shown in Figure 1. To use the act control in the development environment, you must first set it to improve the production efficiency and set it at the same time, which is divided into the following two steps:

1.1 set the include file

stepl: run Visual Basic 6.0, and select [Engineering] - [add module] menu in the menu bar

step2: select the "existing" tab and select "actdefine.bas". During installation, "actdefine.bas" the module is stored in act include under the user specified folder. Generally, the default path is: C: \ Mel sec \ act \ include

step3: register the newly added module "actdefme.bas" into modules (as shown in figure 2)

1.2 register act control

stepl: start visual basic and select [Engineering] - [component] menu in the menu bar

step2: select the control tab and select the DLL file to use (as shown in Figure 3)

step3: the act control contained in the DLL selected in the previous step is added to the speed limited wide toolbox of this kind of experimental machine with conventional electronic universal experimental machine (as shown in Figure 4). After completing the above two steps, paste the control in the toolbox

into the commercial body in the VB development environment to use the control. To use the function function in the control, you can select the [view] - [object browser] menu in the menu bar of VB or press "F2" to enter the object browser (as shown in Figure 5), and select the corresponding control to call up the function function in the control and use it

2 implementation of applications

the implementation of applications mainly includes three aspects: establishing communication lines, reading and writing data, and closing lines and systems

on the surface, 2.1 establish the communication line

the establishment of the communication line between PLC and PC only needs to use the 0pen0 function in the act control. Its format is: (), where object is just the control name used by the control. When the return value of the function is "0", it indicates that the communication line is successfully established; If the return value is not "0", it indicates that the communication line failed to be established for some reason. If the return value is just the establishment failure code, you can find the corresponding error information and solve the case by querying the MX component used in the book. Create a button on the form, named connect, as the connection button. The following is the code for establishing the communication connection:

2.2 data reading and writing

similarly, after the connection is successful, the access to the PLC becomes very simple, and you can directly call the software component reading and writing functions in the act control. The reading functions are: readdeviceblock (szdevicelist, 1Size, 1Data) and readdeviceblock2 (szdevice, 1Size, 1Data). The difference between them is that the number of bits of reading soft components is different. The first is 32-bit shaping, and the second is 16 bit shaping; Write functions include writedeviceblock (szdevicelist, 1Size, 1Data) and writedeviceblock2 (szdevicelist, 1Size, 1Data). Similarly, they are also the difference between reading the number of bits of soft components. They can read and write software components individually or in batches. By creating a text box and a button, the writing of soft components can be realized. The following is the implementation code

2.3 closing of lines and systems

the closing and establishment of lines are realized by using controls. A button named "disconnect" is established on the commercial body, and the following code is written in the click event of the button:

can be used for steel strand experiment (please note when ordering)

3 conclusion

is to monitor the data and status of various soft components in PLC in real time, The timer is used to refresh the data acquisition of PLC. When you need to obtain more monitoring information, you can collect data from the internal software components in the PLC, such as input relay x, output relay y, auxiliary relay m, stater s, data register D, timer T, and counter C. different kinds of PLCs choose their corresponding software components to improve the monitoring efficiency

experiments show that the communication system between PLC and PC without communication protocol established by act control can effectively and quickly obtain the status and data of the internal software components of PLC, and has certain real-time performance, which can meet the requirements. General system control and data acquisition and processing requirements

Copyright © 2011 JIN SHI