Share this

Communication Design of Wastewater Treatment System Based on KingSCADA

2026-04-06 04:47:46 · · #1
Abstract: This paper introduces the communication problem of a lower-level control system composed of a host computer (KingSCADA software) and a microcontroller in a sewage treatment system. The system communication is implemented using VB via DDE. Keywords: KingSCADA, VB, microcontroller, communication, DDE 1. Introduction In recent years, microcontrollers have been widely used in many fields. Many small and medium-sized enterprises, considering investment profit and performance-price ratio, often develop small microcontroller distributed systems as lower-level data acquisition and monitoring systems. A regular PC (or industrial control computer) acts as the host computer, and the microcontroller acts as the lower-level computer. Through communication between the microcontroller and the PC, bidirectional transmission of commands and data is achieved, thereby realizing effective system monitoring. Recently, we developed an automatic control system for sewage treatment. The host computer is a PC, and the system monitoring uses KingSCADA software; the lower-level computer is a microcontroller, responsible for collecting field data and issuing control commands. In the production workshop, the system stores various collected data in the microcontroller and periodically retrieves the data collected and stored by the microcontroller and transmits it to the host computer equipped with KingSCADA software. Technicians view data, curves, and reports, and perform detailed analysis of this data to set operating parameters and issue control commands, ultimately achieving control of the entire system. 2. System Composition and Characteristics In this system, the host PC and microcontrollers communicate via a 1:N link. The microcontrollers with RS-485 interface communication boards are directly connected to the RS-485 bus. The host PC is connected to the bus via an RS-232C/RS-485 converter, thus forming an independent small-scale distributed monitoring system. Other system devices are connected to the host PC in a similar manner. We easily constructed the monitoring screen for the entire system using the KingSCADA software package, displaying the status, alarms, and real-time trend curves of the controlled devices in an animated manner. KingSCADA can communicate with the microcontroller via a serial port, accessing the relevant registers of the microcontroller to obtain the status of the devices controlled by the microcontroller or modify the register values. It can also form a network for data exchange, but this requires both the client and server to be running the KingSCADA software simultaneously. 2.1 KingSCADA's DDE Features The KingSCADA software package consists of two main parts: TouchMak and TouchViev. TouchMak is the screen creation system; all interface design, variable and animation connection definitions are completed in TouchMak. TouchView is used to display animated graphics, responsible for data exchange between the database and the service program, and representing its changes with animation. To establish a DDE connection, a DDE variable needs to be created in the TouchView's data dictionary, and three identifier names need to be registered. The program name of the KingSCADA running system is "view", the theme is defined as "tagname", and the project is the project name defined when defining the DDE variable. 2.2 VB's DDE Features In the VB visual programming tool, DDE connections are achieved by setting the properties and methods of controls. For text boxes, labels, or picture boxes that act as "customers", three properties need to be set: Linktopic, linkitem, and linkmode. For example: Control.linktopic=server application name|theme name Control.linkitem=project name Control.linkmode=num Where control is the name of the text box, label, or picture box control, and num can be one of 0, 1, 2, or 3, representing closed DDE, hot connection, cold connection, and notification connection, respectively. The DDE connection between KingSCADA and VB is automatically completed when TOUCHVIEW starts. 2.3 Data Flow between KingSCADA and the Microcontroller A VB-written service program acts as an intermediary to transmit communication data between KingSCADA and the microcontroller. When the control command button in KingSCADA is active, the control command (such as motor start, stop, etc.) needs to be transmitted down to the microcontroller to achieve remote control. At this time, KingSCADA, as a server, provides data to the VB service program. A DDE variable and a project name for the VB service program to reference need to be defined in the data dictionary. [align=center] Figure 1 System Data Acquisition and Flow Diagram[/align] 2.4 Multi-Machine Communication between VB Service Program and MCS51 In VB communication, the communication control Mscomm is used to realize multi-machine communication between the service program and the microcontroller. In the field, in order to improve anti-interference and load-bearing capacity and increase communication distance, the RS-485 bus communication method is adopted. On the microcomputer side, an RS-232/RS-485 converter is used. Since all microcontrollers share a serial bus, a master-slave configuration is used to avoid contention. The microcomputer service program initiates the call, and the microcontrollers respond via interrupts. The master first sends an address frame. After each microcontroller's serial interrupt, it compares the received address with its own encoded address. If they don't match, it ignores the frame; if they match, it sends back its local identifier. Once the master receives the correct identifier, it sends the relevant command, and the microcontroller performs the corresponding processing. During on-site debugging, the following two points were summarized: 1. Due to interference in the field, if communication fails, the system retransmits the message and counts the number of failures. If the number of failures exceeds a specified limit, communication has failed. 2. Since the communication service program runs in the background, the master must relinquish CPU control while waiting for a response from the slave unit to avoid affecting the normal operation of KingSCADA. 3. Communication Software Design In the communication design of the wastewater treatment system, the monitoring screen constructed using the KingSCADA software package displays the start/stop control of each external pump motor, and data such as pressure, flow rate, temperature, liquid level, and frequency. A service program vbservice.exe, written in VB, obtains pressure and other display data from the microcontroller via serial communication, and uploads it to the monitoring screen PCI via DDE exchange for dynamic display. Motor start/stop control commands are sent from the monitoring screen to the service program via DDE data exchange, and then down to the microcontroller to control its actions. Specific details are as follows: 3.1 Wastewater Pressure Variable Settings in the Monitoring Screen PCI: Enter KingSCADA TouchManager, and define the variable: pressurel in the data dictionary of the PCI monitoring screen. pressurel represents the pressure of channel 1, defined as a DDE simulation. The remaining settings are as follows: Project Name: VB_pressure1_View; Node Type: Driver; Node Name: node; Service Program Name: vbservice1; Topic Name: Forml; Data Exchange Format: Standard Windows Project Exchange. On the PCI monitoring screen, enter the text symbol "%%%%" where the pressure1 value needs to be displayed, and set the pressure1 animation connection method to "Analog Value Output" to display the water pressure of channel 1. 3.2 DDE Settings in the VB Service Program Since the sewage pressure is monitored by the PCI monitor as a client requesting data exchange from the service program, the server-side service program is set as follows: Sub Form_Load() Linktopic="forml" Linkmode=1 End Sub 3.3 Service Program Receiving Data from Each Microcontroller The VB MSCOMM control initialization program summary is as follows: Mscomm1.Commport=1 ' Select COM1 Mscomm1.Settings="9600,N,7,2" ' Set communication parameters Mscomm1.Inputlen=0 ' Read all characters from the receive buffer Mscomm1.OutbufferSize=256 ' Set the send buffer size Mscomm1.InbufferSize=256 ' Set the receive buffer size Mscomm1.PortOpen=True ' Open COM1 ' Receive data main program Private sub Mscomm1_oncomm Select case NUMBER Case 1 In_buffer$=Receive data(NUMBER) Call mission2 Case 2. In_buffer$ = Received Data (NUMBER) Call mission3 Case 3 In_buffer$ = Received Data (NUMBER) … Call task n Receive Data = Inbuffer Mscomm1.Receive = False End Select … End Sub Furthermore, during initialization, vbservice1.exe sets the Rthreshold property to 1. When the receive buffer receives data, the Oncomm event is triggered to receive the data, and then the received data is analyzed and processed. In analyzing the accuracy of data communication, we found that due to external interference or voltage fluctuations, errors may occur in the communication between the PC and the microcontroller, such as receive buffer overflow or network port overspeed. These can all cause runtime errors. Therefore, an error handling subroutine is added to the program. Errors can be captured and handled through the OnComm event of the communication control. Specifically, the communication error information that occurs during the communication process is returned by the CommEvent property. When the value of the CommEvent property changes, it indicates a communication error, and an OnComm event is generated. Simultaneously, the automatic triggering of the OnComm event can be used to add status display codes during the receiving process. This allows monitoring of the communication line status, obtaining the communication progress between the microcontroller and the host, as well as between microcontrollers themselves. 4. Conclusion This paper was developed during the project development process. After the system was put into operation, the results were excellent. The communication system based on KingSCADA and the microcontroller has high practical value and is worth promoting in industrial control.
Read next

CATDOLL CATDOLL 115CM Saki TPE

Height: 115cm Weight: 19.5kg Shoulder Width: 29cm Bust/Waist/Hip: 57/53/64cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm An...

Articles 2026-02-22
CATDOLL 128CM Luisa

CATDOLL 128CM Luisa

Articles
2026-02-22
CATDOLL Yuki Soft Silicone Head

CATDOLL Yuki Soft Silicone Head

Articles
2026-02-22