Research on the Co-simulation System of Subway Control Circuits

In order to solve the problems of complex control logic and the difficulty of simulating function modules due to the high coupling degree of subway control circuits, a subway control circuit co-simulation system is designed in this paper. By analysing the components data and connection relationship in the subway control circuit schematic diagrams, the network topologies are automatically generated, and the mathematical relationships between nodes, branches and components states are established, so as to build a complete logical control model. The depth-first search (DFS) algorithm is adopted to search the effective path across the topology, the event management unit is added to solve the linkage control of the relay, and the logic function simulation of the function module is realized by embedded script. Finally, the feasibility of the simulation system is verified through the simulation test of the subway door control circuits and the analysis of the simulation results. The system is conducive to the functional test and algorithm verification at the subway design stage, and has a good application prospect in the field of subway driver training.


Introduction
In order to alleviate the pressure of urban traffic, China has been vigorously promoting the development of urban rail transit.With the expansion of subway scale and the increase of operation time, upgrading and maintenance have become the primary tasks [1].Computer simulation technology is a research tool throughout the whole life cycle from subway development to post-maintenance.Reference [2] developed the training simulator for operation and maintenance of an electrical control system by means of software and hardware combination, which can realize the functions of operation program control, simulation process demonstration, etc. Reference [3] built a TCU control logic simulation platform through LabVIEW, which can effectively verify various control functions in a pure software environment.Reference [4] constructed an electronic control circuit teaching simulation system to realize the simulation of typical control circuits, focusing on the design of teaching system.Reference [5] analysed the network topology and hardware circuit principle of the subway control system, and built a semi-physical simulation platform of the subway control system, which can realize the simulation from the subsystem to the whole train.In this paper, a co-simulation system of subway control circuits is designed based on Visual Studio2022.According to the established logic control model of subway control circuits, components states are calculated in real time.The effect of power-on/off of components is displayed on display equipment dynamically.Then, the functional simulation verification of the door control circuit is accomplished.The simulation system provides a good experimental platform for driver training, committed to becoming an auxiliary development tool for subway designers.

High voltage systems middle voltage systems
Low voltage 110V

Control circuits co-simulation system design
Because of the highest coupling degree and the most complex logic of the subway control circuits, they are selected as the research object in this paper.The subway control circuit co-simulation system can be divided into simulation calculation subsystem, console simulation subsystem and display subsystem.Figure 2 shows the system design scheme.

Simulation calculation subsystem.
It reads in the schematic diagram of subway control circuits, analyses the component data, electrical and physical connection relationship, and then automatically generates network topologies.It receives the command from the simulation console and converts it into the corresponding master component action after analysis.According to the effective path search algorithm, the logical path of the circuit diagram is generated.The power-on and power-off states of the components are calculated in cooperation with the linkage control of the relays and the logic simulation of the function modules.Then the component states are sent to the display device in the form of network communication for dynamic display.

Logic control modelling
The power-on and power-off states of components in the subway control circuits depend on whether the branches where the components are located constitute a logical path.Therefore, it is necessary to automatically generate the network topology according to the component data and connection relationships in the drawing information, and to calculate the electrical states of components through the mathematical relationship between nodes, branches and components.

Automatic network topology Generation
The subway control circuit is a typical complex coupling network.It is an effective method to transform the circuit into network topology for simulation analysis.A network topology with n nodes and b branches is automatically generated from the circuit diagram with k components.Firstly, after determining the node sets, all branches can be obtained by the traversal algorithm, where the incidence matrix of branches and components is denoted as R: where rij = 1 represents that the branch i contains component j, and rij = 0 represents that the branch i does not contain component j.Secondly, input drawings are automatically converted into local directed graphs described by the incidence matrix A according to their connection relationship.The elements aij in the incidence matrix are defined as in equation ( 2): where aij = 1 indicates that the node i is associated with the branch j and the current out of node i can flow through branch j; aij = -1 indicates that the node i is associated with the branch j and the current out of node i cannot flow through branch j; aij = 0 indicates that the node i is not associated with branch j.The effective adjacency matrix Dv is defined to represent conduction states between nodes: where dij = 1 indicates that there is a path between node i and node j; dij = 0 indicates that there is no path between node i and node j.When all the components contained in the branch are conductive, the branch conducts.Based on this rule, the physical state matrix of the branch set BP can be obtained.The node set composed of ordered nodes from source node to ground node is called the effective path, and the power on/off states of components are determined according to the conductive branches between the effective paths.

Mathematic relationship establishment
To realize the required circuit functions, the power on/off states of branches are changed by the action of components such as buttons, switches, contacts, etc.Therefore, it is necessary to establish the mathematical relationship between nodes, branches and component states.An effective incidence matrix Av is obtained by removing the non-conducting branch from the incidence matrix A: where & represents the logic AND of the corresponding elements of the matrix; I is a n-dimensional column vector whose elements are all 1.
The effective adjacency matrix Dv can be obtained from the effective incidence matrix Av, but the effective incidence matrix Av needs to be processed to solve the problem of existence of directional branches.Equation ( 5) calculates the effective adjacency matrix.
Among them, AL is obtained by replacing the -1 in Av with 0; AR is obtained by replacing the -1 in Av with 1.According to matrix Dv, DFS is adopted to search for the next node utilizing the accessibility of the effective adjacency matrix, until all paths have been traversed.The effective paths are determined by the terminal node, so as to obtain all effective path sets VP = {vP1, vP2, …, vPm}.
An effective path represents an ordered set of nodes from the initial node through the intermediate node to the terminal node.For the effective path k as an example, the indexes of two adjacent nodes are taken in order, and the conductive branches between these two nodes are powered.By logic AND operation of row vi of matrix AL and row vi+1 of matrix AR, it is judged whether the branches between nodes are conductive, as in equation ( 6).
( ) ( ) In the above formula, Σ represents the logic OR of the corresponding elements of the matrix.
According to equation ( 6), the electric states of branches corresponding to all effective paths are calculated, and then the electric state matrix of all branches can be obtained by logic OR operation.
[ ] Based on the electrical state matrix BE of the branches and the incidence matrix R, the electrical states matrix E of components can be obtained: 1 It is necessary for effective path search to set the starting and ending nodes.Subsequently DFS is used to perform path search for each network topology.Multiple drawings are connected by correlation references of breakpoints, which causes a valid path to appear on multiple network topologies, so the searched paths are mainly composed of the following three types.
• Paths without breakpoint node; • Paths with a breakpoint node at one end; • Paths with breakpoint nodes at both ends.The first type of path means that it only exists on a topology and can be directly determined as an effective path.For the latter two types of paths, it is necessary to perform a joint analysis with the paths corresponding to their breakpoints.The main process is shown in figure 3. The cross-topological path search can be realized through the processing of the three types of paths.Combined with the established mathematical relationship, the multi-drawing co-simulation of the subway control circuits can be also implemented.

Relay linkage control
The relays and contacts are coupled by mechanical or electromagnetic physical relations.In the drawing stage, the physical connection relationships between the relays and contacts are established through specific naming rules.When the electrical state of a relay changes, the corresponding contacts act.Therefore, an event management unit is added to achieve relay linkage control.Once the electrical state of a relay change, an event will be added to the event management unit.If it is a normal relay, the

Effective path search
event will be handled immediately, and if it is a time-delay relay, the event will be added to the corresponding moment of event queue.When handling relay events, it updates the physical states of the corresponding contacts according to the established physical connection relationships, and then searches for the effective paths again to calculate the electrical states of the components.

Method of function module simulation
The function module mainly includes door control unit, main controller and other equipment, which have complex logic function and large difference between different Therefore, in order to improve the universality of the simulation system, the logic function of function module is described by embedding Lua scripts.The electrical states of the function module input pins are transmitted to the virtual machine through the virtual stack [6].By executing the logic function script, the calculated electrical states of the output pins are returned to the main program.Thus, the logic function simulation of the function module can be achieved.The simulation method is shown in figure 4.  Before the simulation, the function module is bound to the Lua script file.During the simulation process, the logical code of the script file is compiled into instruction sets through the Lua virtual machine.According to the states of the current function module input pins, the output pins states are obtained after executing the instruction sets.The data interaction between the simulation main program and the script program is realized through the virtual stack.

Software relationships
The drawing software can be mainly utilized to draw circuit schematic diagrams and to design console interface.The drawn circuit diagrams are respectively loaded into the display subsystem and the simulation calculation subsystem.

Software design
In the Visual Studio2022 programming environment, the subway control circuits co-simulation system is developed by using MFC basic class library programming, and the integrated simulation software design from drawing to model generation and dynamic simulation is realized.

Drawing software design.
The main functions of the drawing software are as follows: • Draw electric schematic diagrams to build the graphic model of the circuit; • Establish the electrical connection relationships according to wire connection; • Establish the physical connection relationship between relays, contacts and compound buttons, etc. according to specific naming rules; • Save and export the component data and connection relationship contained in the drawing information.Figure 6 shows the main interface of the drawing software.Because of the symmetry of the subway control circuit, only the first half of the train diagrams need to be drawn.The second half of the train diagrams will be automatically completed through the mirror technology.Writing and binding of logical functional programs of function modules are also supported.

Simulation Calculation Software Design.
As the core of the simulation system, the simulation calculation software has main functions including drawing data analysis, network topology generation, logic function operation, data interaction and simulation process control.Therefore, the simulation calculation software is selected as the server, and the data interaction is carried out through network communication.The main interface is shown in figure 7. By clicking the button "Load model" and selecting the control circuit simulation model to be loaded, the component data and connection relationship are analyzed in turn, and the network topology is automatically generated.The simulation parameters such as simulation step and speed can also be configurated.The start-stop control of the simulation is realized by the "Start", "Pause" and "Stop" buttons.Fault, error and prompt information is output on the "Test output" box, and interactive data is displayed on the "Data transfer" box.

Simulation platform
The subway control circuits co-simulation system is built through three computer devices.Clicking the buttons or switches of the simulation console, control instructions will be sent to the simulation calculation computer.The effective paths are searched by the simulation calculation computer and then logical calculation is carried out.The states of the components are sent to the display device for dynamic demonstration.The data interaction between deferent devices is carried out through network communication.The Simulation platform is shown in figure 8.

Simulation example
The door control circuit is selected as an example to verify the co-simulation system.The door control circuit is one of the basic control systems of train.The hardwire control of the door system is realized through the door opening and closing button on the console.Through the modeling software, the relevant drawings of the door system are drawn, and the logical functions of the door control unit are bound with script file.Because of the high coupling between the drawings, it is also necessary to conduct co-simulation in combination with drawings such as the cab preparation, master controller.Firstly, drawing software calls the component library to draw the half-car drawings, and then automatically completes the drawing model of the whole train.They are loaded by the simulation calculation system and display system respectively.The "110V Permanent Train Line" powers on after clicking the "Start" Button.Figure 9 shows the control circuit of a specific door in the door opening state.When the train has stopped stably, the door opening train line will be powered on after pressing the door opening button.The door opening command takes effect if the power-on time lasts more than 0.5s, then the motor turns forward to open the door.At the same time, the buzzer gives a prompt tone, and the indicator light flashes at 1Hz.The door opens in place when the limit switch is reached.In the test, the flashing frequency of the indicator lamp is 5Hz, and the door action time is 3s.Measure some pins of EDCU through waveform observation function, and the waveform is shown in figure 10.

Figure 4 .
Figure 4. Function module simulation method

Figure 5 .
Figure 5. Software relationshipsThe simulation calculation subsystem analyses the component data and connection relationships of the drawings to generate the network topology.The display subsystem parses the graphic data of the drawings, and demonstrates the dynamic effect according to the component states obtained by the simulation calculation.The designed console interface is imported into the console simulation subsystem, and the devices on the console are triggered by mouse click.The independence between modules is improved by the subsystem design method.

Figure 6 .
Figure 6.Drawing software interface It has the basic drawing functions such as component editing, scaling, wire connection and so on.Because of the symmetry of the subway control circuit, only the first half of the train diagrams need to be drawn.The second half of the train diagrams will be automatically completed through the mirror technology.Writing and binding of logical functional programs of function modules are also supported.

Figure 10 .
Figure 10.Waveform in door opening process 3s after the "Door Closing Train Line" is triggered, the motor reversely rotates to close the door until it is in place, and the buzzer and indicator light also give a prompt.The measured simulation waveform is shown in figure 11.

Figure 11 .Figure 12 .Figure 13 .
Figure 11.Waveform in door closing process If the "Door Closing Train Line" cancels the command and the "door opening train line" is triggered during door closing, the door closing action will stop, and the door will open 1s later, and the waveform is shown in figure 12.