A PLC breakpoint debugging method
By implementing breakpoint debugging functions for text language and graphics languages in PLC development and programming software, supporting single-step, step-in, step-out and other operations, the problem of missing breakpoint debugging functions of existing PLC development and programming software is solved, and a more accurate and consistent debugging process is achieved.
Patent Information
- Application Number
- CN202210755616.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-30
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2042-06-30
AI Technical Summary
The existing PLC development and programming software lacks breakpoint debugging functions, which leads to difficulties for users to troubleshoot configuration program exceptions.
It provides a PLC breakpoint debugging method, which supports breakpoint debugging of text language and graphics language. Through remote communication between the client and the PLC device, debugging instructions and instruction information offset tables are directly generated, so as to realize the debugging functions of single-step, step-in, step-out, and run to the cursor without the need to download the debug information table to the device.
It realizes more comprehensive and accurate breakpoint debugging, saves equipment space, ensures the configuration consistency of debug mode and non-debug mode, and simplifies debugging control.
Smart Images

Figure CN115202285B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of PLC, and in particular to a method for implementing breakpoint debugging. Background Art
[0002] Programmable Logic Controller (PLC) executes user programs through periodic scanning. Breakpoint debugging can be used to breakpoint, monitor, and single-step the running user program to fully observe the running status of the user program or determine whether its logic is correct.
[0003] In the field of industrial control, the widespread application of PLC control technology has become indispensable. It occupies an important position in the automation control system of many industries. Its powerful functions, high flexibility and strong practicality make it one of the three major technical pillars of modern industrial automation. However, in the development process of PLC products, the development programming software lacks breakpoint debugging function, which is not conducive to users to debug abnormal configuration programs. Summary of the invention
[0004] The present invention provides a PLC breakpoint debugging method, which can support breakpoint debugging of text language and graphic language, support single step, step in, step out, and run to cursor. In the debugging mode, there is no need to download the debugging information table to the device, so that the breakpoint debugging is more comprehensive and more accurate, and the device space is saved. The configuration consistency of the debugging mode and the non-debugging mode is guaranteed, and the debugging control is simpler.
[0005] In order to achieve the above object, the technical solution provided by the present invention is as follows:
[0006] A PLC breakpoint debugging method comprises the following steps: a client communicates with a PLC device remotely; the client directly generates a debugging instruction and an instruction information offset table; the PLC device receives the debugging instruction through communication and executes the corresponding command; the PLC replies to the client through communication on the success or failure of the command execution; after the PLC program is interrupted, the client is notified of the instruction offset of the current program interruption position through communication, the client parses the instruction offset, and converts it into a text line or graphic element number where the program is located through the instruction information offset table for display.
[0007] The present invention communicates with the PLC device through the configuration programming software based on IEC61131-3 on the client (such as a host computer, a computer), opens the debugging mode and the non-debugging mode, and the configurations of the two modes are consistent. There is no need to download the debugging information table to the device. The device only needs to open the debugging server and start the debugging pile to ensure that the device storage space is not occupied, which is suitable for the debugging of small devices. There is no need to download the debugging information to the device, the debugging mode and the non-debugging mode are consistent in configuration, and after exiting the debugging mode, there is no need to repeatedly download the configuration without debugging information to the device, so as to ensure configuration consistency.
[0008] The configuration software communicates with the PLC device through a remote communication connection. The PLC device receives debugging instructions issued by the user operating the configuration programming software, including flipping breakpoints, clearing breakpoints, single stepping, stepping in, stepping out, full speed, etc. After receiving the command, the PLC executes the corresponding command to debug and control the configuration program in the PLC.
[0009] The PLC replies to the configuration software through communication whether the command is executed successfully or not. After the PLC program is interrupted, the configuration software is notified of the instruction offset of the current program interruption position through communication. The configuration software parses the instruction offset and converts it into the text line or graphic element number where the program is located through the instruction offset information table, and then displays it on the software interface.
[0010] The method of converting graphic language to text language is as follows: through the graphic configuration sequence number, connection relationship, associated parameters, etc., the corresponding text language is converted and generated, and the corresponding relationship between the graphic and the text is generated synchronously, and then the corresponding instruction offset information table is generated from the text language. The graphic language supports breakpoint debugging function.
[0011] In some embodiments, as a preference, after receiving the debugging instruction issued by the user operating the configuration software, the following operations are performed:
[0012] The configuration software receives the user's operations of adding and deleting breakpoints. The configuration software searches the instruction offset information table according to the position selected by the user to obtain the instruction offset corresponding to the selected position, and sends the communication to the PLC device to set and delete the breakpoint.
[0013] For the user's single-step, step-in, and step-out operations, since there is no debugging information table in the device, the device does not need to know which instruction the program should stop at next, and does not need to perform complex semantic judgments on statements such as branches, conditions, and loops. The specific single-step, step-in, and step-out are all controlled by the configuration software. The device only needs to execute each statement one by one in non-full-speed mode and return the instruction offset.
[0014] Receive the user's single-step and step-in operations in the configuration software, and the configuration software sends the instruction set single-step command to the PLC. After receiving the command, the PLC executes the next instruction and replies to the instruction offset. The configuration software receives and determines whether the text line corresponding to the current instruction offset has changed. If it has not changed, it will repeatedly send the instruction set single-step command until the text line changes, and then display it on the software interface.
[0015] Receive the user's step-out operation in the configuration software, and the configuration software sends the instruction set single-step command to the PLC. After receiving the command, the PLC instructs the next instruction and replies to the current instruction offset. The configuration software receives and determines whether the program organization unit corresponding to the current instruction line has changed. If it has not changed, the instruction set single-step command is sent repeatedly until the program organization unit corresponding to the text line changes or is interrupted by a breakpoint, and the software interface is displayed.
[0016] Receive the full-speed operation of the user in the configuration software, the configuration software sends a full-speed command to the PLC, the PLC runs at full speed after receiving it, if it is interrupted by a breakpoint, it replies with the interrupt position instruction offset, the configuration software parses the instruction offset, converts it into the text line or graphic element number where the program is located through the debugging information table, and then displays it on the software interface.
[0017] The present invention controls the PLC to add, delete, single-step, step in, step out, etc. breakpoints through remote communication connection and private message protocol. At the same time, the current PLC status can be obtained through communication for interface display.
[0018] In some embodiments, as a preferred method, the debugging operation of the user in the user interface and the interrupt reply of the PLC are received, and the debugging information table is searched. The specific operations are as follows:
[0019] Receive the breakpoint operation of the user in the configuration interface, obtain the breakpoint text line or graphic element number according to the debugging information table, find the corresponding instruction offset according to the mapping relationship, and send the debugging command.
[0020] Receive the interrupt position instruction offset replied by the PLC device, and obtain the text line or graphic element number of the interrupt position corresponding to the instruction offset according to the debugging information table to display the interface of the interrupt position.
[0021] Compared with the prior art, the present invention has the following advantages:
[0022] The PLC breakpoint debugging method of the present invention can support breakpoint debugging of text language and graphic language, support single step, step in, step out, and run to cursor. In the debugging mode, there is no need to download the debugging information table to the device additionally, so that the breakpoint debugging is more comprehensive and more accurate, and the device space is saved. The configuration consistency of the debugging mode and the non-debugging mode is guaranteed, and the debugging control is simpler. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a schematic diagram of the PLC breakpoint debugging method of the present invention;
[0024] Figure 2 A flow chart of a method for generating an instruction offset information table in a PLC breakpoint debugging method of the present invention;
[0025] Figure 3 The debugging information file format generated in the PLC breakpoint debugging method of the present invention;
[0026] Figure 4 It is a flow chart of graphic configuration preprocessing in the PLC breakpoint debugging method of the present invention;
[0027] Figure 5 It is a flow chart of converting graphic configuration to ST text in the PLC breakpoint debugging method of the present invention;
[0028] Figure 6 A flow chart of executing breakpoint insertion and deletion control instructions in the PLC breakpoint debugging method of the present invention;
[0029] Figure 7 The present invention is a flow chart of executing single-step control instructions in the PLC breakpoint debugging method. DETAILED DESCRIPTION
[0030] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific implementation described herein is only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0031] like Figure 1 As shown, the PLC breakpoint debugging method of the present invention, the debugger client is connected to the server (i.e., PLC device) through remote communication. The user inputs the debugging command, and the configuration software based on IEC61131-3 in the host computer directly generates a debugging information table, i.e., an instruction information offset table. The server receives the debugging command through communication, executes the corresponding command, and replies to the success or failure of the client command execution through communication. After the PLC program is interrupted, the client is notified of the instruction offset of the current program interruption position through communication, the client parses the instruction offset, and converts it into the text line or graphic element number where the program is located through the instruction information offset table, and displays the software interface.
[0032] like Figure 2The instruction offset information table generated by the configuration software includes the correspondence between the program language text line and the instruction offset. The compiler generates an abstract syntax book during the compilation process, records the text line number in the syntax tree, and then generates the corresponding debugging information file in a fixed format according to the instruction offset and line number of the syntax tree node when traversing the abstract syntax tree to generate the compilation link file. The file format is as follows: Figure 3 shown.
[0033] like Figure 4 , Figure 5 As shown, the present invention provides a method for converting a graphic language into a text language. The graphic language converted into a text language also supports the breakpoint debugging function. The graphic language can be an LD language or a FBD language. Figure 4 Before converting the graphic language to the text language, the configuration primitives need to be preprocessed. First, the configurations need to be sorted and converted in the agreed order to ensure the sequential execution of the program. Secondly, the connection between primitives is equivalent to the value transfer of variables. The parameter transfer between primitives can be represented by associating the same temporary variables with the input and output pins at both ends of the connection. Figure 5 , to convert the formal graphic configuration to ST text, first output the program start statement, then convert the variables defined in the variable area to ST variable definition, then perform ST variable definition on the attached temporary variables, and then convert the graphics elements to text in order. During this period, it is necessary to record whether the graphics elements have been converted to prevent an infinite loop. When traversing to the contact, the AND or AND relationship is judged according to the value on the left side of the contact, and the logical operation is assigned to the associated value on the right side of the contact, and the corresponding logical operation text and assignment text are output. When traversing to the coil, the associated value on the left side of the coil is assigned to the variable associated with the coil, and the corresponding assignment text is output. When traversing to the function or function block primitive, first determine whether there is an enable pin on the left side. If so, first output the enable judgment data, then use the variable associated with the input pin on the left side of the function or function block to assign the input pin of the function or function block, output the assignment statement, and then output the execution statement of the function or function block. Then assign the pin value of the output pin of the function block to the variable associated with the primitive output endpoint, output the assignment statement, and finally determine whether there is an enable pin on the right side. If so, output the IF end statement. Traverse all primitives until the last one, and when compiling to each primitive, synchronously output the corresponding primitive number as a comment, so that you can find the text line corresponding to the primitive by the primitive number, or find the corresponding primitive number by the text line. Finally, output the end statement of the program, and the graphic text conversion of the corresponding configuration is completed.
[0034] like Figure 6 , 7The present invention provides a debugging method supporting remote communication, which enables the configuration software to connect to the real PLC device for breakpoint debugging of the configuration without downloading the debugging information to the device, so that the configuration of the standard mode and the debugging mode remain consistent. The configuration software and the virtual machine establish a TCP connection for remote communication. According to the user operation, the debugging command is sent to the device according to the private message protocol. After receiving the device, the protocol is parsed, and the parsing result is inserted into the configuration debugging pile to execute the debugging command. The result is fed back to the configuration software after communication parsing. After parsing, the configuration software displays the interface.
[0035] like Figure 7 The configuration program is controlled in single step. The PLC is already in an interrupt state. The configuration software controls the PLC to execute to the next instruction offset through the communication protocol. The PLC sends the instruction offset of the current interrupt to the configuration software. The configuration software searches for the corresponding text line according to the instruction deviation. If the current program is text, it only needs to determine whether the text line has changed. If the current language is a graphic language, it is also necessary to determine whether the graphic element number corresponding to the text line has changed. If it has not changed, continue to send single-step commands to control the PLC to execute to the next instruction offset until the corresponding change occurs. After the change, the configuration software selects the corresponding text line or graphic element number according to the language type for hit display. The step-in control of the configuration program can be inferred in turn. The configuration software controls the PLC to execute to the next instruction offset through the communication protocol until the program organization unit or program text line changes.
[0036] The above description is only a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements without departing from the principle of the present invention, and these improvements should also be regarded as within the protection scope of the present invention.
Claims
1. A PLC breakpoint debugging method, characterized in that: The PLC breakpoint debugging method comprises the following steps: the client communicates with the PLC device remotely; the client directly generates a debugging instruction and an instruction information offset table; the PLC device receives the debugging instruction through communication and executes the corresponding command; the PLC replies to the client through communication whether the command is executed successfully or not; after the PLC program is interrupted, the client is notified of the instruction offset of the current program interruption position through communication, the client parses the instruction offset, and converts it into the text line or graphic element number where the program is located through the instruction information offset table for display; The operation of generating debugging instructions after receiving user operations on the client is as follows: Receive the user's operation of adding or deleting breakpoints. The client searches the instruction offset information table according to the position selected by the user to obtain the instruction offset corresponding to the selected position, and sends the communication to the PLC device to set or delete the breakpoint. For the user's single-step, step-in, and step-out operations, the specific single-step, step-in, and step-out are directly controlled by the client. The PLC device only needs to execute each statement one by one in non-full-speed mode and return the instruction offset; Receive the user's single-step and step-in operations. The client sends the instruction set single-step command to the PLC. After receiving the command, the PLC executes the next instruction and replies the instruction offset. The client receives and determines whether the text line corresponding to the current instruction offset has changed. If it has not changed, it will repeatedly send the instruction set single-step command until the text line changes and display it; After receiving the user's step-out operation, the client sends the instruction set single-step command to the PLC. After receiving the command, the PLC instructs the next instruction and replies with the current instruction offset. The client receives and determines whether the program organization unit corresponding to the current instruction line has changed. If not, the client sends the instruction set single-step command repeatedly until the program organization unit corresponding to the text line changes or is interrupted by a breakpoint, and then displays it; After receiving the user's full-speed operation, the client sends a full-speed command to the PLC. After receiving it, the PLC runs at full speed. If it is interrupted by a breakpoint, it replies with the interrupt position instruction offset. The client parses the instruction offset and converts it into the text line or graphic element number where the program is located through the debugging information table, and then displays it.
2. The PLC breakpoint debugging method according to claim 1, characterized in that: The content of the instruction information offset table includes the correspondence between program language text lines and instruction offsets, and the mapping relationship between graphics and texts.
3. The PLC breakpoint debugging method according to claim 2, characterized in that: The mapping relationship between the graphics and the text is obtained by the following method: the corresponding text language is converted and generated through the sequence number, connection relationship and associated parameters of the graphic configuration, and the corresponding relationship between the graphics and the text is generated synchronously.
4. The PLC breakpoint debugging method according to claim 1, characterized in that: The debugging instructions include flip breakpoint, clear breakpoint, single step, step in, step out, and full speed.
Citation Information
Patent Citations
Cross debugging system and method based on PLC programming language
CN110442520A
Breakpoint debugging implementation method and device, equipment and storage medium
CN114356765A