Method, device and storage medium for implementing PLC control logic through circuit simulation

By generating a circuit tree structure and calculating node voltages, the PLC control logic is directly simulated, solving the problems of long circuit simulation time and low efficiency in the existing technology, and achieving efficient circuit simulation without compilation.

CN116339223BActive Publication Date: 2025-09-19ANHUI GUOXUN CORE MICROTECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310040018.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-11
Publication Date
2025-09-19
Estimated Expiration
2043-01-11

AI Technical Summary

Technical Problem

Existing circuit simulation methods require converting circuit description files into C language programs, which is time-consuming, inefficient, and highly complex, and relies on a C language compiler.

Method used

By obtaining the circuit description file, generating the circuit tree structure, calculating the node voltage and simulating the PLC control logic, program compilation is avoided and the operation of the functional module is simulated directly according to the node voltage.

Benefits of technology

This eliminates the need for program compilation, saves time, improves circuit simulation efficiency and reduces software complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116339223B_ABST
    Figure CN116339223B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, and storage medium for implementing PLC control logic through circuit simulation, relating to the field of circuit simulation technology. The method comprises: obtaining a circuit description file of a target circuit, wherein the target circuit includes a functional module; generating a circuit tree structure of the target circuit according to the circuit description file; calculating the node voltages of each node in the target circuit according to the circuit tree structure; and simulating the operation of the PLC control logic of the functional module according to the calculated node voltages. The method solves the problems of long time required for circuit simulation, low efficiency, and high software complexity in the prior art, thereby achieving the effect of saving time and improving efficiency without the need for program compilation. At the same time, the present application does not need to rely on a compiler, thereby achieving the effect of reducing software complexity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method, a device and a storage medium for realizing PLC control logic through circuit simulation, and belongs to the technical field of circuit simulation. Background Art

[0002] Currently, in the design and development stage, after the circuit design is completed, it is usually necessary to simulate the designed circuit to test the circuit's functions.

[0003] Existing circuit simulation methods include: drawing a circuit through a ladder diagram, generating a circuit description file of the circuit based on the drawing result, converting the circuit description file into a C language program, compiling the converted C language program through a C language compiler, and running the C language program.

[0004] In the above solution, the circuit description file needs to be converted into a C language program and then run, which takes a long time and is inefficient. In addition, the above solution needs to rely on a C language compiler, and the software complexity is relatively high. Summary of the Invention

[0005] The object of the present invention is to provide a method, device and storage medium for realizing PLC control logic through circuit simulation, so as to solve the problems existing in the prior art.

[0006] In order to achieve the above object, the present invention provides the following technical solutions:

[0007] According to a first aspect, an embodiment of the present invention provides a method for implementing PLC control logic through circuit simulation, the method comprising:

[0008] Obtaining a circuit description file of a target circuit, wherein the target circuit includes functional modules;

[0009] identifying, according to the circuit description file, components of the target circuit, wherein the components include any one of a bus power supply, a power connection point, an element, and a functional module, and generating a circuit tree structure of the target circuit according to the identified components;

[0010] Calculating a node voltage of each node in the target circuit according to the circuit tree structure, specifically comprising initializing a power supply voltage of a bus power supply in the circuit tree structure, taking the bus power supply as a starting node, traversing each node in the circuit tree structure in sequence according to a preset order, and calculating the node voltage of each node;

[0011] The operation of the programmable logic controller (PLC) control logic of the functional module is simulated according to the calculated voltages of the nodes.

[0012] Optionally, generating the circuit tree structure according to the identified components includes:

[0013] The circuit tree structure including the various components is generated with the bus power supply as a starting point, the power supply connection point as a node, and the element as a connector.

[0014] Optionally, taking the bus power supply as a starting node, traversing each node in the circuit tree structure in sequence according to a preset order, and calculating the node voltage of each node includes:

[0015] For the i-th node in the circuit tree structure, selecting a target associated node from each associated node of the i-th node according to the preset order, where the initial value of i is 1; the target associated node is a node that has not been selected in the past, and i is a positive integer;

[0016] Calculating a node voltage of the target associated node;

[0017] Let i=i+1, take the target associated node as the i-th node, and execute again the step of selecting a target associated node from each associated node of the i-th node in the circuit tree structure according to the preset order.

[0018] Optionally, selecting a target associated node from associated nodes of the i-th node in the preset order includes:

[0019] Starting from the associated nodes in the target direction of the i-th node, the target associated node is selected from the associated nodes according to the preset order, where the preset order includes a clockwise order or a counterclockwise order.

[0020] Optionally, if the target circuit includes at least two bus power supplies, taking the bus power supply as a starting node, traversing each node in the circuit tree structure in sequence according to a preset order, and calculating the node voltage of each node includes:

[0021] For each of the at least two bus power supplies, the steps of taking the bus power supply as a starting node, traversing each node in the circuit tree structure in sequence according to a preset order, and calculating the node voltage of each node are performed.

[0022] Optionally, obtaining a circuit description file of a target circuit includes:

[0023] An extensible markup language (XML) file of the target circuit is obtained, where the XML file is a file that exports and saves a PLC program of the target circuit written in a ladder diagram.

[0024] Optionally, simulating the operation of the programmable logic controller (PLC) control logic of the functional module according to the calculated node voltages includes:

[0025] The operation of the functional module is simulated according to the trigger mechanism of the functional module and the obtained node voltage of each node.

[0026] Optionally, simulating the operation of the functional module according to the trigger mechanism of the functional module and the acquired node voltages of each node includes:

[0027] Obtaining the electrical level of the power connection point connected to the functional module according to the connection relationship thereof;

[0028] If the power connection point is high, the function block is operated according to the principle of conduction; if the power connection point is low, the function block is operated in a non-conducting manner; or

[0029] If the function module is triggered by the rising edge, the function module will be run when the detected power connection point is the rising edge, and will not be run when the detected power connection point is the falling edge; if the function module is triggered by the falling edge, the function module will be run when the detected power connection point is the falling edge, and will not be run when the detected power connection point is the rising edge.

[0030] In a second aspect, a device for implementing PLC control logic through circuit simulation is provided, the device comprising a memory and a processor, the memory storing at least one program instruction, and the processor implementing the method described in the first aspect by loading and executing the at least one program instruction.

[0031] According to a third aspect, a computer storage medium is provided, wherein at least one program instruction is stored in the computer storage medium, and the at least one program instruction is loaded and executed by a processor to implement the method according to the first aspect.

[0032] The method obtains a circuit description file for a target circuit, which includes functional modules; generates a circuit tree structure for the target circuit based on the circuit description file; calculates the node voltages of each node in the target circuit based on the circuit tree structure; and simulates the operation of the PLC control logic of the functional modules based on the calculated node voltages. This method solves the problems of long circuit simulation times, low efficiency, and high software complexity in the prior art, eliminating the need for program compilation, saving time and improving efficiency. Furthermore, the present application eliminates the need for a compiler, reducing software complexity.

[0033] In addition, the present application generates a circuit tree structure based on the circuit description file, that is, the node voltage of each node is obtained through a dot matrix method, which simplifies the solution and improves the operating efficiency and real-time performance.

[0034] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention and implement it according to the contents of the specification, the following is a detailed description of the preferred embodiments of the present invention with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 A method flow chart of a method for implementing PLC control logic through circuit simulation provided by one embodiment of the present invention;

[0036] Figure 2 A possible schematic diagram of a target circuit provided by one embodiment of the present invention;

[0037] Figure 3 An embodiment of the present invention provides Figure 2 A possible schematic diagram of a circuit tree structure generated by the target circuit shown;

[0038] Figure 4 The calculated value provided by one embodiment of the present invention is Figure 2 Schematic diagram of node voltages at various nodes in the target circuit shown. DETAILED DESCRIPTION

[0039] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0040] In the description of the present invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings and are intended solely to facilitate and simplify the description of the present invention. They are not intended to indicate or imply that the devices or components referred to must have, be constructed, or operate in a specific orientation, and therefore should not be construed as limitations on the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0041] In the description of the present invention, it should be noted that, unless otherwise expressly specified or limited, the terms "mounted," "connected," and "connected" should be understood in a broad sense. For example, they may refer to fixed, detachable, or integral connections; mechanical or electrical connections; direct or indirect connections through an intermediate medium; and internal communication between two components. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on the specific circumstances.

[0042] In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0043] First, for ease of understanding, a brief description of the various terms involved in this application is given.

[0044] Busbar: The busbar is equivalent to the power supply of the circuit.

[0045] Component: This is equivalent to a switch, resistor, or other element in a circuit. In practice, components include normally open contacts, normally closed contacts, rising edge contacts, falling edge contacts, coils, and connecting wires.

[0046] Power connection point: Equivalent to a connector in a circuit, a node used to provide power to the next component or functional module.

[0047] Functional module: A functional module is a software module with certain functions that can realize various required software functions. It is equivalent to a functional device in a circuit, such as a television, refrigerator, etc.

[0048] Please refer to Figure 1 , which shows a method flow chart of a method for implementing PLC control logic through circuit simulation provided by an embodiment of the present application, such as Figure 1 As shown, the method includes:

[0049] Step 101: Obtain a circuit description file for the target circuit, which includes functional modules. Optionally, the circuit description file is a file that describes the connection between the various components of the target circuit and can be an XML file. In this case, this step involves the system obtaining an XML (Extensible Markup Language) file for the target circuit. This XML file is a file that exports and saves the PLC (Programmable Logic Controller) program for the target circuit written using a ladder diagram. In other words, after a circuit designer obtains the PLC program for the target circuit using a ladder diagram, they can save the program as an XML file. In this step, the system loads this XML file.

[0050] Alternatively, the system can load the XML file in a browser, or in an application. This application does not limit its specific application environment. By executing this method in a browser without installing a client, simulation can be performed anytime and anywhere, improving the programming experience.

[0051] In addition, the ladder diagram program described in this application is a software process consisting of busbars, components, power connection points, and functional modules, simulating the electrical schematic diagram of a relay. In actual implementation, the target circuit can also be written using other programming methods, and this application does not limit this. This application only requires obtaining the circuit description file of the target circuit.

[0052] For example, please refer to Figure 2 , which shows a possible circuit schematic diagram of the target circuit corresponding to the obtained circuit description file.

[0053] Step 102: generating a circuit tree structure of the target circuit according to the circuit description file;

[0054] Optionally, this step includes:

[0055] First, identifying various components of the target circuit according to the circuit description file, wherein the components include any one of a bus power supply, a power connection point, a component, and a functional module;

[0056] Second, the circuit tree structure is generated according to the identified components.

[0057] Optionally, the generating step includes: taking the bus power supply as a starting point, the power supply connection point as a node, and the element as a connector, to generate the circuit tree structure including the various components.

[0058] For example, for Figure 2 The target circuit shown in the figure can be generated by the system Figure 3 The circuit tree structure shown in the figure. The head node is the bus power supply, and the node is the other node in the circuit. The content in the brackets after each node represents the coordinates of the node in the tree structure. For example, (0,1) means the node is in the 0th row and 1st column of the grid, (2,1) means the node is in the 2nd row and 1st column of the tree structure, and so on.

[0059] Step 103, calculating the node voltage of each node in the target circuit according to the circuit tree structure;

[0060] Optionally, this step includes:

[0061] First, initializing the power supply voltage of the bus power supply in the circuit tree structure;

[0062] Optionally, the bus power supply is powered on by default, that is, the node voltage of the bus power supply is initialized to a high level, and the node voltages of other nodes are initialized to a low level.

[0063] Second, taking the bus power supply as a starting node, traverse each node in the circuit tree structure in sequence according to a preset order, and calculate the node voltage of each node.

[0064] Optionally, this step includes:

[0065] (1) For the i-th node in the circuit tree structure, a target associated node is selected from the associated nodes of the i-th node according to the preset order, where the starting value of i is 1; the target associated node is a node that has not been selected in the past, and i is a positive integer;

[0066] The preset order is a system default order or a user-defined order. Optionally, the preset order can be a clockwise order or a counterclockwise order.

[0067] Starting from the associated nodes in the target direction of the i-th node, the target associated node is selected from the associated nodes according to the preset order, wherein the preset order includes a clockwise order or a counterclockwise order. The target direction can be any direction, for example, north, south, left, or right of the current node. In actual implementation, only the target direction and the preset order need to be determined, and traversal can be performed according to the target direction and the preset order.

[0068] Taking the target direction as north and the preset order as clockwise as an example, for the i-th node, detect whether there is a north node of the i-th node. If so, when the north node has not been traversed, the north node is determined as the target associated node; and if there is no north node or the north node has been traversed, detect whether there is a right node of the i-th node. If so, when the right node has not been traversed, the right node is determined as the target associated node; and so on. If it does not exist, continue to detect the south node until the end. Optionally, if the target associated node cannot be determined according to the above traversal method, the process ends.

[0069] (2) Calculating the node voltage of the target associated node;

[0070] After the target associated node is determined, the node voltage of the target associated node may be calculated according to the node voltage of the i-th node.

[0071] (3) Let i=i+1, take the target associated node as the i-th node, and again perform the step of selecting a target associated node from each associated node of the i-th node in the circuit tree structure according to the preset order.

[0072] After the node voltage of the target associated node is calculated, i=i+1 is set, and the target associated node is taken as the i-th node, and the above traversal steps are continued.

[0073] It should be noted that if there are at least two bus power supplies, for each of the at least two bus power supplies, the steps of taking the bus power supply as the starting node, traversing each node in the circuit tree structure in sequence according to a preset order, and calculating the node voltage of each node are executed.

[0074] In one possible embodiment, please refer to Figure 4 , which shows a possible schematic diagram of the calculated voltages of each node. Figure 4 In the figure, the nodes filled with dots are at high level, and the nodes filled with vertical dashed lines are at low level.

[0075] Step 104 : Simulate the operation of the PLC control logic of the functional module according to the calculated voltages of the nodes.

[0076] Alternatively, the voltage level supplied to the functional module can be obtained based on the functional module's connection relationship. Alternatively, the functional module stores the coordinates of its connected power connection point, which can be used to obtain the voltage level at that power connection point. If the power connection point is high, the functional block operates as if it is conducting; otherwise, the functional block operates as if it is not conducting.

[0077] The above example uses the principle that a high level is conductive and a low level is non-conductive. In actual implementation, the operation of the functional module is simulated based on the trigger mechanism of the functional module and the acquired node voltages of each node. For example, if the functional module is triggered by a rising edge, the functional module will be executed when the detected power connection point is a rising edge, and will not be executed when the power connection point is a falling edge. Conversely, if the functional module is triggered by a falling edge, the functional module will be executed when the detected power connection point is a falling edge, and will not be executed when the power connection point is a rising edge.

[0078] In summary, the invention involves obtaining a circuit description file for a target circuit, which includes functional modules; generating a circuit tree structure for the target circuit based on the circuit description file; calculating the node voltages of each node in the target circuit based on the circuit tree structure; and simulating the operation of the PLC control logic of the functional modules based on the calculated node voltages. This solves the problems of long circuit simulation times, low efficiency, and high software complexity in the prior art, achieving the goal of eliminating the need for program compilation, saving time and improving efficiency. Furthermore, this application eliminates the need for a compiler, reducing software complexity.

[0079] In addition, the present application generates a circuit tree structure based on the circuit description file, that is, the node voltage of each node is obtained through a dot matrix method, which simplifies the solution and improves the operating efficiency and real-time performance.

[0080] The present application also provides a device for implementing PLC control logic through circuit simulation, the device including a memory and a processor, the memory storing at least one program instruction, and the processor implementing the above-mentioned method by loading and executing the at least one program instruction.

[0081] The present application also provides a computer storage medium, in which at least one program instruction is stored. The at least one program instruction is loaded and executed by a processor to implement the method described above.

[0082] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0083] The above-described embodiments merely illustrate several implementations of the present invention, and while their descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent. It should be noted that a person skilled in the art would be able to make numerous variations and improvements without departing from the spirit of the present invention, all of which fall within the scope of protection of the present invention. Therefore, the scope of protection of the patent for this invention shall be determined by the appended claims.

Claims

1. A method for realizing PLC control logic by circuit simulation, characterized in that: The method comprises: Obtaining a circuit description file of a target circuit, wherein the target circuit includes functional modules; identifying, according to the circuit description file, components of the target circuit, wherein the components include any one of a bus power supply, a power connection point, an element, and a functional module, and generating a circuit tree structure of the target circuit according to the identified components; Calculating a node voltage of each node in the target circuit according to the circuit tree structure, specifically comprising initializing a power supply voltage of a bus power supply in the circuit tree structure, taking the bus power supply as a starting node, traversing each node in the circuit tree structure in sequence according to a preset order, and calculating the node voltage of each node; The operation of the programmable logic controller (PLC) control logic of the functional module is simulated according to the calculated voltages of the nodes.

2. The method according to claim 1, characterized in that The circuit tree structure is generated based on the identified components, including: taking the bus power supply as the starting point, the power supply connection point as the node, and the element as the connector, to generate the circuit tree structure including the components.

3. The method according to claim 1, characterized in that The method of taking the bus power supply as a starting node, traversing each node in the circuit tree structure in sequence according to a preset order, and calculating the node voltage of each node includes: For the i-th node in the circuit tree structure, selecting a target associated node from each associated node of the i-th node according to the preset order, where the initial value of i is 1; the target associated node is a node that has not been selected in the past, and i is a positive integer; Calculating a node voltage of the target associated node; Let i=i+1, take the target associated node as the i-th node, and execute again the step of selecting a target associated node from each associated node of the i-th node in the circuit tree structure according to the preset order.

4. The method according to claim 3, characterized in that The selecting a target associated node from the associated nodes of the i-th node according to the preset order includes: Starting from the associated nodes in the target direction of the i-th node, the target associated node is selected from the associated nodes according to the preset order, where the preset order includes a clockwise order or a counterclockwise order.

5. The method according to claim 1, wherein If the target circuit includes at least two bus power supplies, the method of taking the bus power supply as a starting node, traversing each node in the circuit tree structure in a preset order, and calculating the node voltage of each node includes: For each of the at least two bus power supplies, the steps of taking the bus power supply as a starting node, traversing each node in the circuit tree structure in sequence according to a preset order, and calculating the node voltage of each node are performed.

6. The method according to any one of claims 1 to 5, characterized in that: The step of obtaining a circuit description file of a target circuit includes: An extensible markup language (XML) file of the target circuit is obtained, where the XML file is a file that exports and saves a PLC program of the target circuit written in a ladder diagram.

7. The method according to claim 1, characterized in that The operation of simulating the programmable logic controller (PLC) control logic of the functional module according to the calculated node voltages includes: The operation of the functional module is simulated according to the trigger mechanism of the functional module and the obtained node voltage of each node.

8. The method according to claim 7, characterized in that The simulating the operation of the functional module according to the trigger mechanism of the functional module and the acquired node voltages of each node includes: Obtaining the electrical level of the power connection point connected to the functional module according to the connection relationship thereof; If the power connection point is high, the function block is operated according to the principle of conduction; if the power connection point is low, the function block is operated in a non-conducting manner; or If the function module is triggered by the rising edge, the function module will be run when the detected power connection point is the rising edge, and will not be run when the detected power connection point is the falling edge; if the function module is triggered by the falling edge, the function module will be run when the detected power connection point is the falling edge, and will not be run when the detected power connection point is the rising edge.

9. A device for implementing PLC control logic through circuit simulation, characterized in that: The device includes a memory and a processor, wherein the memory stores at least one program instruction, and the processor implements the method according to any one of claims 1 to 8 by loading and executing the at least one program instruction.

10. A computer storage medium, characterized in that At least one program instruction is stored in the computer storage medium, and the at least one program instruction is loaded and executed by the processor to implement the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Graphic language cross compiling method and cross compiler

    CN109976760A