Programmable logic controller, downtime diagnosis method and device thereof and readable storage medium

By collecting the on-site information of downtime exceptions and user program location area information in the programmable logic controller, and converting and generating a function call stack, the problem that the existing technology cannot diagnose downtime exceptions caused by user programs is solved, and efficient and economical downtime diagnosis and analysis is achieved.

CN119806882APending Publication Date: 2025-04-11SHENZHEN INOVANCE TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411970180.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The prior art cannot effectively diagnose programmable logic controller downtime caused by user programs, and there are certain limitations.

Method used

After the programmable logic controller triggers a downtime exception, it collects the downtime exception site information and the location area information corresponding to the user program, converts the instruction address in the downtime exception site information into the function name, and determines the instruction address based on the location area information of the user program, and generates the downtime exception site function call stack to analyze the cause of the downtime.

Benefits of technology

It realizes diagnostic analysis of downtime abnormalities caused by user programs, can collect diagnostic information without shutting down of the user equipment, save storage space, avoid economic losses caused by equipment shutdown, and expands the application scope of downtime diagnosis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119806882A_ABST
    Figure CN119806882A_ABST
Patent Text Reader

Abstract

The invention discloses a programmable logic controller, a downtime diagnosis method and device of the programmable logic controller and a readable storage medium, and relates to the technical field of programmable logic controllers. Acquiring abnormal downtime site information and position area information corresponding to the user program; converting an instruction address corresponding to the downtime abnormal site information into a corresponding function name, determining an instruction address corresponding to the user program based on the position area information, and converting the instruction address corresponding to the user program into the corresponding function name; and adding each function name into the initial function call stack to obtain a downtime abnormal field function call stack. According to the method and the device, the technical problem that a current downtime diagnosis scheme for the programmable logic controller cannot process downtime abnormity caused by a user program and has limitation is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of programmable logic controllers, and in particular to a method and device for diagnosing downtime of a programmable logic controller, a programmable logic controller, and a computer-readable storage medium. Background Art

[0002] With the development of industry, in order to adapt to the ever-changing needs of users, the software and systems of programmable logic controllers have become more and more complex, and are also prone to problems such as downtime exceptions. At present, when a programmable logic controller encounters a downtime exception, there are two commonly used solutions for collecting downtime data. One is executed by the operating system software. After the downtime exception is triggered, the operating system software will generate a coredump (core dump) file based on the downtime exception site information for fault diagnosis and analysis. The other solution is to call the registered downtime exception handling callback through the operating system software to handle the downtime exception, and collect some abnormal site information during the processing. However, the above downtime exception analysis solutions can only analyze the downtime exception caused by the software program of the programmable logic controller itself, and cannot handle the downtime exception caused by the user program, which has certain limitations. Summary of the invention

[0003] The main purpose of the present application is to provide a method and device for downtime diagnosis of a programmable logic controller, a programmable logic controller and a computer-readable storage medium, aiming to solve the technical problem that the current downtime diagnosis scheme for programmable logic controllers cannot handle downtime exceptions caused by user programs and has limitations.

[0004] To achieve the above object, the present application provides a method for diagnosing a downtime of a programmable logic controller, the method comprising: After the programmable logic controller triggers a downtime exception, collect the downtime exception site information and the location area information corresponding to the user program; Converting the instruction address corresponding to the abnormal downtime site information into a corresponding function name; and determining the instruction address corresponding to the user program based on the location area information, and converting the instruction address corresponding to the user program into a corresponding function name; Each of the function names is added to an initial function call stack to obtain a crash exception site function call stack, wherein the crash exception site function call stack is used to determine the crash cause of the programmable logic controller.

[0005] In one embodiment, the crash exception site information includes at least crash exception register information, crash exception thread stack information, and location area information where the software program and dependent libraries are loaded into the memory.

[0006] In one embodiment, the step of converting the instruction address corresponding to the abnormal downtime site information into the corresponding function name includes: Based on the time sequence of each piece of data in the abnormal downtime site information, each piece of data in the abnormal downtime site information is analyzed in turn to obtain the instruction address corresponding to each piece of data in the abnormal downtime site information; Based on the mapping relationship between instruction addresses and function names, the instruction addresses corresponding to the various pieces of data in the abnormal scene information are converted into corresponding function names in sequence.

[0007] In one embodiment, the step of converting the instruction address corresponding to the user program into the corresponding function name includes: Based on the mapping relationship between the instruction address corresponding to the user program and the function name, the instruction address corresponding to the user program is converted into the corresponding function name in sequence.

[0008] In one embodiment, the step of adding each of the function names to a preset initial function call stack to obtain a crash exception scene function call stack includes: Based on the time sequence corresponding to each of the function names, each of the function names is added to the initial function call stack in sequence to obtain the crash exception site function call stack.

[0009] In one embodiment, after the programmable logic controller triggers a downtime exception, before the step of collecting downtime exception site information and location area information corresponding to the user program, the method further includes: A downtime exception handling callback is registered in the operating system corresponding to the programmable logic controller, wherein the downtime exception handling callback is used to control the programmable logic controller to collect downtime exception site information and location area information corresponding to the user program after the programmable logic controller triggers a downtime exception.

[0010] In one embodiment, after the step of adding each of the function names to a preset initial function call stack to obtain a crash exception scene function call stack, the method further includes: Visually display the function call stack at the crash exception site; Or, storing the abnormal crash scene function call stack in a preset database; Or, the crash exception on-site function call stack is written into a local file, an external server file or a cloud server file.

[0011] In addition, the present application also provides a downtime diagnosis device for a programmable logic controller, the downtime diagnosis device for a programmable logic controller comprising: An information collection module is used to collect the abnormal downtime site information and the location area information corresponding to the user program after the programmable logic controller triggers the abnormal downtime; An address conversion module is used to convert the instruction address corresponding to the abnormal downtime site information into a corresponding function name; and determine the instruction address corresponding to the user program based on the location area information, and convert the instruction address corresponding to the user program into a corresponding function name; The call stack generation module is used to add each of the function names to the initial function call stack to obtain a crash exception site function call stack, wherein the crash exception site function call stack is used to determine the crash cause of the programmable logic controller.

[0012] The present application also provides a programmable logic controller, which is a physical device, and includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the steps of the programmable logic controller downtime diagnosis method as described above.

[0013] The present application also provides a readable storage medium, which is a computer-readable storage medium, and a program for implementing a downtime diagnosis method for a programmable logic controller is stored on the computer-readable storage medium. The program for implementing the downtime diagnosis method for a programmable logic controller is executed by a processor to implement the steps of the downtime diagnosis method for the programmable logic controller as described above.

[0014] The present application also provides a computer program product, including a computer program, which implements the steps of the programmable logic controller downtime diagnosis method as described above when the computer program is executed by a processor.

[0015] The present application provides a method for diagnosing a downtime of a programmable logic controller. First, after the programmable logic controller triggers a downtime exception, the downtime exception site information and the location area information corresponding to the user program are collected, and then the instruction address corresponding to the downtime exception site information is converted into a corresponding function name; and the instruction address corresponding to the user program is determined based on the location area information, and the instruction address corresponding to the user program is converted into a corresponding function name, and finally each of the function names is added to a preset initial function call stack to obtain a downtime exception site function call stack, wherein the downtime exception site function call stack is used to determine the downtime cause of the programmable logic controller. The technical solution of the present application can collect downtime exception site information for diagnosing, analyzing and locating downtime exception problems and determine the corresponding downtime exception site function call stack without shutting down the user device, thereby effectively avoiding the economic losses caused to the user by the equipment shutdown. In addition, the downtime exception site information occupies a small storage space, saving the storage space of the programmable logic controller device, and can record more historical data to diagnose historical downtime exception problems. Moreover, the technical solution of the present application can diagnose and analyze the downtime exceptions caused by user programs, and convert the instruction addresses in the downtime exception site information into corresponding function names based on the location area information where the user program is loaded into the memory, and generate a downtime exception site function call stack for analyzing and determining the cause of the downtime of the programmable logic controller. It can be applied to more scenarios and overcomes the limitations of traditional downtime diagnosis solutions. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0018] Figure 1 This is a flow chart of Embodiment 1 of a method for diagnosing downtime of a programmable logic controller according to an embodiment of the present application; Figure 2 A schematic diagram of a feasible process of collecting abnormal downtime site information and / or location area information of user programs loaded into memory in an embodiment of the present application; Figure 3 A schematic diagram of a feasible process of analyzing and converting the collected information to obtain a function call stack at the scene of a downtime exception in an embodiment of the present application; Figure 4This is a schematic diagram of the overall flow of a feasible method for diagnosing downtime of a programmable logic controller in an embodiment of the present application; Figure 5 This is a structural diagram of a downtime diagnosis device for a programmable logic controller in an embodiment of the present application; Figure 6 This is a schematic diagram of the device structure of the hardware operating environment involved in the programmable logic controller in the embodiment of the present application.

[0019] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0020] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and understandable, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work belong to the scope of protection of this application.

[0021] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0022] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0023] At present, whether it is the PLC software or the user program running on the PLC, if a downtime exception problem is triggered, the commonly used processing methods include the following two. One is that the operating system software performs the default processing. After the downtime exception is triggered, the operating system software will generate a coredump file based on the downtime exception site information, and then force the PLC software process to exit. Although this method can capture detailed information on the downtime exception site for analysis and location of the downtime exception site problem, it also has two disadvantages. One is that the exit of the PLC software will cause the user's equipment to shut down, causing economic losses to the user; the other is that the coredump file is often large, generally ranging from a few megabytes to tens of megabytes or even hundreds of megabytes. For small PLC devices, the storage space is often small, and storing these coredump files has a certain pressure. Only a small number of coredump files can be stored, which is not conducive to locating historical downtime exception problems. The second is to pre-register the downtime exception processing callback with the operating system software in the PLC software. After triggering the downtime exception, the operating system software will call the registered downtime exception handling callback to handle the downtime exception, and collect some abnormal scene information during the processing, and then save it to the disk. For most downtime exceptions, after the downtime exception scene is handled in the downtime exception handling callback, the programmable logic controller software process will not exit and can continue to run. In this way, the collected downtime exception scene information is often too little or insufficient, or not systematic, compared with the core dump file, and is often unable to be used for diagnosis and analysis to locate the downtime exception scene problem. Even if enough information is collected, the collected data is mostly binary digital data, and the analysis process is not only prone to errors, but also requires more time and energy. In addition, it also has high requirements for the quality and skills of the analyst. Moreover, the above downtime exception analysis schemes can only analyze the downtime exception caused by the software program of the programmable logic controller itself, and cannot handle the downtime exception caused by the user program, which has certain limitations.

[0024] In order to overcome the technical defects in the above-mentioned prior art, the present application embodiment provides a method for diagnosing downtime of a programmable logic controller, referring to Figure 1 , Figure 1 The flowchart of an embodiment of a method for diagnosing downtime of a programmable logic controller is shown in the figure. In the first embodiment, the method for diagnosing downtime of a programmable logic controller includes: Step S10, after the programmable logic controller triggers a shutdown exception, collect the shutdown exception site information and the location area information corresponding to the user program; Among them, the programmable logic controller (PLC) is a digital operation electronic system designed specifically for use in industrial environments. The programmable logic controller uses a programmable memory to store instructions for performing operations such as logical operations, sequential control, timing, counting and arithmetic operations, and controls various types of mechanical equipment or production processes through digital or analog input and output. The downtime abnormality of the programmable logic controller refers to the state in which the PLC suddenly stops working during operation and cannot continue to perform its intended functions or respond to input signals. This usually causes the automation equipment and systems connected to it to stop running or work abnormally, which may affect the operation of the entire production line. After the programmable logic controller is detected to trigger a downtime abnormality, the downtime abnormality site information of the programmable logic controller in the current situation is immediately collected. Among them, the downtime abnormality site information is usually marked according to the time point when the downtime abnormality is triggered and saved in full, so that in the subsequent automated diagnosis and analysis positioning stage, the complete collection information of the corresponding downtime abnormality site can be obtained according to the downtime abnormality trigger point mark.

[0025] In addition, the embodiment of the present application does not limit the method for saving the abnormal downtime site information collected at this stage. Any method that can save the collected information is considered to have saved the collected information, including but not limited to saving it in the local storage device of the device, external storage device, or even uploading it to the server or cloud.

[0026] In an embodiment of the present application, it is necessary to collect the location area information of the user program of the programmable logic controller loaded into the memory. When the crash exception is triggered by the user program, there is an exception during the operation of the user program, and it is necessary to analyze the instruction address corresponding to the location area information loaded into the memory, so as to determine the crash exception site function call stack together with the instruction address in the crash exception site information.

[0027] In a feasible embodiment, before step S10, it can be determined whether it is necessary to collect the location area information of the user program loaded into the memory of the programmable logic controller, which depends on whether the current downtime abnormality is caused by the user program, or whether the cause of the current downtime abnormality includes the user program abnormality. If so, it is necessary to collect the location area information of the user program loaded into the memory of the programmable logic controller and perform data analysis, otherwise, it is only necessary to analyze the instruction address in the downtime abnormality site information.

[0028] Specifically, in the process of determining whether the downtime exception of the programmable logic controller is triggered by the user program, the running identifier of the user program can be applied. The user program has been pre-set, and the corresponding running identifier will be displayed when the downtime exception is triggered. Therefore, when the user program displays the identifier corresponding to the triggering downtime exception, it can be determined that the downtime exception of the programmable logic controller is triggered by the user program, and the location area information of the corresponding user program loaded into the memory is collected. Then, from the parsed collected data, the instruction addresses therein are converted into corresponding function names in chronological order. When the user program does not display the identifier corresponding to the triggering downtime exception, it can be determined that the downtime exception of the programmable logic controller is not triggered by the user program, and it is only necessary to parse the data corresponding to the downtime exception on-site information.

[0029] Step S20, converting the instruction address corresponding to the abnormal downtime site information into the corresponding function name; and determining the instruction address corresponding to the user program based on the location area information, and converting the instruction address corresponding to the user program into the corresponding function name; In the embodiment of the present application, it is necessary to parse the data corresponding to the abnormal downtime site information, filter the instruction address therein, and convert the corresponding function name to provide a data basis for the subsequent abnormal downtime diagnosis and analysis. Among them, the instruction address refers to the memory address of the instruction pointed to by the program counter (PC) at a specific time. During the execution of the program, the PC will point to and execute each instruction one by one according to the instruction sequence. The instruction address is an important sign of the program execution flow, which records the location of the current program execution. When an exception occurs, the instruction address plays an important role in locating the problem, analyzing the cause, and repairing the fault. The function name is an identifier used to identify a specific function or operation in the program. Each function has its own unique name so that it can be called and executed in the program. The function name is an important guarantee for the readability and maintainability of the program. Through the function name, the staff can clearly understand the function and purpose of each function, so that it is more convenient to write, debug and maintain the code, which is conducive to analyzing the cause of the abnormal downtime.

[0030] During the compilation process of the programmable logic controller, the compiler will associate the function name in the source code with the corresponding instruction sequence and generate a symbol table or debugging information. The above information records the mapping relationship between the function name and the instruction address. When the programmable logic controller crashes, the crash to crash exception is monitored and the exception site information is collected, including the instruction address where the exception occurred, the exception type, and the related register status. Subsequently, by searching the symbol table or debugging information, the instruction address can be mapped to the corresponding function name, thereby quickly locating the function and code location where the exception occurred.

[0031] It should also be noted that the location area information loaded into the memory describes the range information of the instruction address loaded into the memory for each module of the program, and can be used to indicate the instruction address corresponding to the user program to be queried from the memory. Among them, the downtime exception site information is the information that will exist and need to be collected for any downtime exception, and the location area information of the user program loaded into the memory of the programmable logic controller is collected when the user program triggers a downtime exception. It should also be noted that the location area information of the user program loaded into the memory refers to the range information corresponding to the instruction address loaded into the memory by the user program.

[0032] In this way, the technical solution of the embodiment of the present application can be applied to the scenario of downtime exception caused by the program of the programmable logic controller itself, and can also be applied to the scenario of downtime exception caused by user program exception. It has a wider application scope and provides an efficient solution for handling downtime exception problems in more scenarios.

[0033] For example, a feasible process for collecting abnormal downtime site information and / or location area information of user programs loaded into memory is as follows: Figure 2 The method of collecting the on-site information of the downtime exception includes: recording the downtime exception type information, recording the downtime exception register information, recording the downtime exception thread stack information, recording the location area information of the programmable logic controller software program loaded into the memory, and recording the location area information of the programmable logic controller software program dependency library loaded into the memory; determining whether the downtime exception is triggered by the user program, if so, recording the location area information of the user program loaded into the memory, if not, terminating the collection.

[0034] In another feasible embodiment, the location area information of the programmable logic controller software program loaded into the memory and the location area information of all dependent libraries of the programmable logic controller software program loaded into the memory are fixed information after the programmable logic controller software program is initialized. Therefore, it is not mandatory to collect this information after the downtime exception is triggered. It can also be collected and saved after the programmable logic controller software program is initialized, and there is no need to repeat the collection when the downtime exception is triggered, thereby further improving the timeliness of data collection.

[0035] Exemplarily, when a programmable logic controller crashes abnormally, the crash abnormality thread crash abnormality site register data information and crash abnormality thread stack information are collected. These data mainly include the function call stack information of the thread, such as local variables, return addresses, instruction addresses, etc. However, these data are binary data that can be recognized by the machine, and a series of calculations and processing are required for these data according to certain rules to obtain a text form that can be read and understood by humans. For these digital data, if you do not use tools, but take a manual approach to compare and calculate one by one, although you can also find the function call stack of the crash abnormality site, this will not only generate a large workload, but also be prone to errors, appear inefficient, and have high skill requirements for analysts. Therefore, in order to improve the efficiency of solving the crash abnormality problem, a method of automatically analyzing and collecting information is provided, and the collected data are input into a pre-established automated analysis tool, and the binary instruction address is converted into the corresponding function name, so as to obtain the corresponding crash abnormality site function call stack later. Specifically, it includes collecting a large amount of binary data (tens of KB), inputting it into the automated analysis tool, and trying to convert it one by one, the data processing volume is large and very cumbersome. This step is completed by automated analysis tools, which greatly reduces manual workload and improves processing efficiency compared to manual comparison.

[0036] Step S30, adding each function name to a preset initial function call stack to obtain a crash exception site function call stack, wherein the crash exception site function call stack is used to determine the crash cause of the programmable logic controller.

[0037] After the function names are obtained, they are added to the preset empty initial function call stack in sequence according to the time sequence determined by these function names. After the function names are added, the crash exception scene function call stack can be obtained. It can be understood that the initial function call stack is an empty stack before the function names are added. Each time a function name is obtained, it is added to the stack. After all function names are added, the crash exception scene function call stack used to characterize the order of each function call can be obtained.

[0038] In addition, step S30 can also be completed by a pre-established automated analysis tool. The collected relevant information is imported into the automated analysis tool, and the automated diagnostic analysis tool calculates and processes the binary digital data, and the function call stack of the abnormal downtime scene can be obtained within a few minutes. This method not only avoids the probability of analysis errors introduced by the staff due to their own quality differences, but also greatly reduces the time consumption caused by data analysis, effectively improving the efficiency of data analysis.

[0039] It should be noted that the implementation of the automated analysis tool is not limited to scripts, independent programs, servers, etc. Any method that can run on a computer device and analyze the collected information to give a function call stack at the scene of the crash exception can be used as an automated analysis tool. Moreover, there is no limitation on the method of importing the collected relevant information into the automated analysis tool. Any method that allows the automated analysis tool to load the collected information is considered to have imported the collected information into the automated diagnostic analysis tool.

[0040] The technical solution of the embodiment of the present application can not only diagnose and analyze the downtime anomalies triggered by the software program of the programmable logic controller itself, but also diagnose and analyze the downtime anomalies caused by the user program, and convert the instruction address in the downtime anomaly site information into the corresponding function name based on the location area information where the user program is loaded into the memory, and generate a downtime anomaly site function call stack for analyzing and determining the cause of the downtime of the programmable logic controller. It can be applied to more scenarios and overcomes the limitations of traditional downtime diagnosis solutions.

[0041] Further, in a feasible embodiment, the crash abnormality site information includes at least crash abnormality register information, crash abnormality thread stack information, and location area information where the software program and dependent library are loaded into the memory; Optionally, the crash exception site information may also include crash exception type information, which refers to the error type that occurs when the software program is running and causes the software to crash, such as segmentation fault, illegal instruction, division by zero, system call exception, etc. In addition, the crash exception register information refers to the crash exception site register information of the abnormal thread, the crash exception thread stack information refers to the crash exception site thread stack information of the abnormal thread, and the location area information of the software program and dependent library loaded into the memory refers to the location area information of the programmable logic controller software and its dependent library loaded into the memory.

[0042] Among them, register information refers to the status and data of registers, which are key components used to store and transmit data in PLC or computer systems, when a fault occurs. After a PLC crashes, the on-site register information may include: program counter, which indicates the address of the currently executed instruction; program status word: contains information about the current program execution status, such as interrupt flags, condition codes, etc.; values ​​of other registers: such as data registers, address registers, etc., which are used to store and transmit data.

[0043] Thread stack information refers to the state and data of the stack used by each thread during execution in a multi-threaded environment. The stack is an area in the computer used to store information such as local variables, function calls, and return addresses. When a thread crashes, thread stack information is also crucial for troubleshooting. By checking the state and data of the thread stack, you can understand the call relationship, local variable values, and other information of the thread during execution, thereby locating the cause of the fault. For example, in a thread crash exception, the thread stack information may include: the top pointer, which is used to indicate the top position of the current stack; the stack frame, each function call will create a new stack frame to store the local variables, parameters, and return address of the function; the values ​​of local variables and parameters, during the execution of the function, the values ​​of local variables and parameters will be stored in the stack.

[0044] In addition, the collected crash exception site information is not limited to crash exception type information, abnormal thread crash exception site register information, abnormal thread crash exception site thread stack information, location area information of programmable logic controller software and its dependent libraries loaded into memory, location area information of user programs loaded into memory, etc. Other types of information can be collected according to actual conditions, and the collected information types can be appropriately deleted while ensuring that the crash exception site function call stack can be deduced through the collected information.

[0045] In the embodiment of the present application, various types of abnormal on-site information are collected, which provides a reliable data basis for the subsequent fault diagnosis process of the programmable logic controller, and facilitates a comprehensive and in-depth analysis of the actual fault cause that causes the downtime and the function where the abnormality occurs.

[0046] Further, in a feasible embodiment, the step of converting the instruction address corresponding to the abnormal downtime site information into the corresponding function name may include: Step S21, based on the time sequence of each piece of data in the abnormal downtime scene information, successively parse each piece of data in the abnormal downtime scene information to obtain the instruction address corresponding to each piece of data in the abnormal downtime scene information; Step S22: based on the mapping relationship between instruction addresses and function names, convert the instruction addresses corresponding to the data in the abnormal scene information into corresponding function names in sequence.

[0047] In the technical solution of the embodiment of the present application, a pre-created automated analysis tool can be used to analyze the data corresponding to the collected abnormal downtime site information and the location area information. Specifically, the collected abnormal downtime site information is combined with the data in the location area information and imported into the automated analysis tool, and the automated analysis tool is used to parse the data in chronological order.

[0048] Exemplarily, in the case of the existence of unparsed data, it is determined whether the unparsed data is the instruction address of the location area loaded into the memory by the user program. If so, the instruction address (in binary form) is calculated and converted into the corresponding function name based on the preset mapping relationship between the instruction address and the function name; if not, it is determined whether the unparsed data is the instruction address of the programmable logic controller software program or its dependent library loaded into the memory location area. If so, the instruction address (in binary form) is calculated and converted into the corresponding function name; otherwise, the data is skipped and the next unparsed data is parsed until all the data is parsed.

[0049] In the embodiment of the present application, the instruction address in the exception site information is converted into a corresponding function name for the subsequent generation of a corresponding downtime exception site function call stack, which reflects the data involved in the function call process of the programmable logic controller during operation, and facilitates analysis from the function perspective of which function causes the downtime exception of the programmable logic controller, thereby accurately diagnosing the cause of the downtime exception.

[0050] In a feasible embodiment, the step of converting the instruction address corresponding to the user program into the corresponding function name may include: Step S23: based on the mapping relationship between the instruction address corresponding to the user program and the function name, the instruction address corresponding to the user program is converted into the corresponding function name in sequence.

[0051] After the instruction address corresponding to the user program is queried in the memory based on the location area information, the instruction address corresponding to the user program can be calculated in turn according to the preset mapping relationship between the instruction address corresponding to the user program and the function name to obtain the function name corresponding to the instruction address.

[0052] In the embodiment of the present application, the instruction address corresponding to the user program is converted into the corresponding function name for the subsequent generation of the corresponding downtime exception scene function call stack, which reflects the data involved in the function call process of the user program of the programmable logic controller during operation, and facilitates the analysis from the function perspective of which function causes the downtime exception caused by the user program, thereby accurately diagnosing the fault cause of the downtime exception.

[0053] Compared with the prior art, the embodiments of the present application can cover the scenarios of abnormal downtime caused by user programs, have a wider application range, and overcome the defects of the limitations of the downtime diagnosis scheme of the traditional programmed logic controller.

[0054] Furthermore, the step of adding each of the function names to a preset initial function call stack to obtain a function call stack at the crash exception site may include: Step S31, based on the time sequence corresponding to each function name, each function name is added to the initial function call stack in sequence to obtain a crash exception scene function call stack.

[0055] It should be noted that the process of adding the function name to the preset empty initial function call stack described in step S31 can be executed synchronously with the step of converting the instruction address into the function name in step S20. For example, each time a function name is obtained by conversion, the function name is added to the initial function call stack until all the instruction addresses in the collected information are converted into function names and the function names in the initial function call stack are also added, thereby obtaining the function call stack at the scene of the crash exception.

[0056] For example, in combination with the content of the above-mentioned embodiment, a feasible process of analyzing and converting the collected information to obtain the function call stack of the crash exception scene is as follows: Figure 3 As shown, firstly, the collected information (including the crash exception site information and / or the location area information of the programmable logic controller's user program loaded into the memory) is imported into the automated analysis tool to determine whether there is unparsed data. If not, the crash exception site function call stack is output; if so, whether the unparsed data is the instruction address of the user program loaded into the memory location area is determined; if so, the instruction address is converted into a function name; if not, whether the unparsed data is the instruction address of the programmable logic controller software program or its dependent library loaded according to the memory location area; if so, the instruction address is converted into a function name; if not, return to execute the step of determining whether there is unparsed data; after converting the instruction address into a function name, the function name is added to the crash exception site function call stack until the crash exception site function call stack is output.

[0057] It should be noted that there is no order requirement for determining whether the unparsed data is a user program instruction address, a programmable logic controller software program and its dependent library instruction address or other steps, as long as it can determine whether the unparsed data is an instruction address. In addition, in the embodiments of the present application, there is no limitation on the method of importing the collected information into the automated diagnostic analysis tool. Any method that enables the automated diagnostic analysis tool to load the collected information is considered to have imported the collected information into the automated diagnostic analysis tool.

[0058] At present, whether it is the programmable logic controller software or the user program running on the programmable logic controller software, after the downtime exception occurs, the cause of the downtime exception is diagnosed and analyzed, and the ultimate goal is to restore the function call stack when the downtime exception is triggered. Therefore, after obtaining the function call stack of the downtime exception site in the embodiment of the present application, the staff can diagnose and analyze the cause of the programmable logic controller downtime exception. For example, from the obtained downtime exception site function call stack, the function calls corresponding to the function names that cause the exception can be identified, and the implementation of these functions can be checked, especially those related to the exception description; possible programming errors, resource conflicts, data overflows and other problems can also be found; and the problem can also be reproduced in a safe test environment. Specifically, it can be achieved by simulating the conditions that trigger the exception, using debugging tools to execute the code step by step, and observing the program behavior, especially those related to the functions mentioned in the function call stack; once the root cause of the problem is found, the error in the code is fixed, and then the repair is verified in the test environment to ensure that no new problems are introduced; in order to avoid the occurrence of the downtime exception phenomenon of the programmable logic controller, some preventive measures can be implemented, such as adding error handling logic, optimizing resource management, etc., to reduce the possibility of similar problems in the future.

[0059] In the embodiment of the present application, the data in the abnormal downtime site information are parsed in chronological order, and the process of data parsing and conversion is continuously executed in a loop when there is unparsed data, ensuring that each unparsed data can be parsed and processed, further improving the accuracy and precision of downtime diagnosis and avoiding data omissions.

[0060] In a feasible embodiment, after the programmable logic controller triggers a downtime exception, before the step of collecting downtime exception site information and location area information corresponding to the user program, the method may further include: Step A10, registering a crash exception handling callback in the operating system corresponding to the programmable logic controller, wherein the crash exception handling callback is used to control the programmable logic controller to collect crash exception site information and location area information corresponding to the user program after the programmable logic controller triggers a crash exception.

[0061] The downtime exception handling callback refers to the automatic calling of a preset callback function or handler to deal with the exception when a downtime exception is detected during the operation of the PLC. For example, during the PLC programming process, a special exception handling function or module can be pre-written as the implementation of the processing callback. This function or module is used to implement the entire downtime diagnosis process of the programmable logic controller as described above. The corresponding parameters can also be configured. During the configuration process of the PLC, relevant parameters and options can be set to enable or disable the processing callback function and specify the address and name of the callback function or module.

[0062] During the initialization phase of the programmable logic controller software, it is necessary to register a crash exception handling callback with the operating system software so that both the programmable logic controller software and the user program running on the programmable logic controller software can enter the crash exception handling callback registered there when a crash exception is triggered.

[0063] The downtime exception handling callback is registered in the operating system of the programmable logic controller. After the programmable logic controller triggers the downtime exception, the programmable logic controller is controlled to execute steps S10 to S30 to complete the collection process of the on-site function call stack when the downtime exception occurs. The downtime exception handling callback registration provides a logical control basis for the programmable logic controller to automatically perform downtime diagnosis, realizes the automated processing of downtime diagnosis, and reduces manual workload.

[0064] In a feasible embodiment, after the step of adding each of the function names to a preset initial function call stack to obtain a function call stack at the crash exception site, the method further includes: Step S40, visually displaying the function call stack at the crash exception site; Or, step S50, storing the function call stack of the abnormal crash scene into a preset database; Or, in step S60, the function call stack at the crash exception site is written into a local file, an external server file or a cloud server file.

[0065] It is understandable that after obtaining the crash exception site function call stack, it is necessary to output the crash exception site function call stack. The method of outputting the crash exception site function call stack is not limited in the embodiment of the present application. It can be directly input into the display for display, saved to a database (local server database, external server database, or cloud server database), or written to a file (local file, external server file, or cloud server file). The user obtains the crash exception site function call stack by reading the database or file content. In the technical scheme of the embodiment of the present application, any method of providing the crash exception site function call stack to the user can be considered as outputting the crash exception site function call stack. Among them, the crash exception site function call stack is provided to the user in various different ways, which can adapt to the needs of different industrial control scenarios and improve the applicability of the scenarios.

[0066] For ease of understanding, in combination with the contents of the aforementioned embodiments of the present invention, a feasible overall process of a programmable logic controller downtime diagnosis method is introduced. For example, referring to Figure 4First, register the crash exception handling callback with the operating system software, and then collect the crash exception site information after the crash exception is triggered to determine whether the user program triggers the crash exception. If so, collect the location area information where the user program is loaded into the memory. If not, import the collected information into the automated analysis tool, and finally output the crash exception site function call stack.

[0067] In addition, the present application also provides a programmable logic controller downtime diagnosis device, referring to Figure 5 , wherein the downtime diagnosis device of the programmable logic controller includes: The information collection module 10 is used to collect the abnormal downtime site information and the location area information corresponding to the user program after the programmable logic controller triggers the abnormal downtime; An address conversion module 20 is used to convert the instruction address corresponding to the abnormal downtime site information into a corresponding function name; and determine the instruction address corresponding to the user program based on the location area information, and convert the instruction address corresponding to the user program into a corresponding function name; The call stack generation module 30 is used to add each of the function names to the initial function call stack to obtain a crash exception site function call stack, wherein the crash exception site function call stack is used to determine the crash cause of the programmable logic controller.

[0068] In one embodiment, the crash exception site information includes at least crash exception register information, crash exception thread stack information, location area information where software programs and dependent libraries are loaded into memory, and location area information where user programs are loaded into memory.

[0069] In one embodiment, the address conversion module 20 is further configured to: Based on the time sequence of each piece of data in the abnormal downtime site information, each piece of data in the abnormal downtime site information is analyzed in turn to obtain the instruction address corresponding to each piece of data in the abnormal downtime site information; Based on the mapping relationship between instruction addresses and function names, the instruction addresses corresponding to the various pieces of data in the abnormal scene information are converted into corresponding function names in sequence.

[0070] In one embodiment, the address conversion module 20 is further configured to: Based on the mapping relationship between the instruction address corresponding to the user program and the function name, the instruction address corresponding to the user program is converted into the corresponding function name in sequence.

[0071] In one embodiment, the call stack generation module 40 is further used to: Based on the time sequence corresponding to each of the function names, each of the function names is sequentially added to a preset initial function call stack to obtain the crash exception scene function call stack; In one embodiment, the downtime diagnosis device of the programmable logic controller further includes a callback registration module, and the callback registration module is used to: A downtime exception handling callback is registered in the operating system corresponding to the programmable logic controller, wherein the downtime exception handling callback is used to control the programmable logic controller to collect downtime exception site information and location area information corresponding to the user program after the programmable logic controller triggers a downtime exception.

[0072] In one embodiment, the downtime diagnosis device of the programmable logic controller further includes a call stack output module, and the call stack output module is used to: Visually display the function call stack at the crash exception site; Or, storing the abnormal crash scene function call stack in a preset database; Or, the crash exception on-site function call stack is written into a local file, an external server file or a cloud server file.

[0073] The downtime diagnosis device for a programmable logic controller provided by the present application adopts the downtime diagnosis method for a programmable logic controller in the above-mentioned embodiment, which can solve the technical problem that the current downtime diagnosis scheme for a programmable logic controller cannot handle downtime exceptions caused by user programs and has limitations. Compared with the prior art, the beneficial effects of the downtime diagnosis device for a programmable logic controller provided by the embodiment of the present application are the same as the beneficial effects of the downtime diagnosis method for a programmable logic controller provided by the above-mentioned embodiment, and the other technical features in the downtime diagnosis device for a programmable logic controller are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0074] An embodiment of the present application also provides a programmable logic controller, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the downtime diagnosis method of the programmable logic controller in the above-mentioned embodiment one.

[0075] Reference below Figure 6, which shows a schematic diagram of the structure of a programmable logic controller suitable for implementing the embodiment of the present disclosure. The programmable logic controller in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The programmable logic controller shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0076] like Figure 6 As shown, the programmable logic controller may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the programmable logic controller are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the programmable logic controller to communicate with other devices wirelessly or by wire to exchange data. Although the programmable logic controller with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0077] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0078] The programmable logic controller provided by the present application adopts the downtime diagnosis method of the programmable logic controller in the above embodiment, which can solve the technical problem that the current downtime diagnosis scheme for programmable logic controller cannot handle downtime exceptions caused by user programs and has limitations. Compared with the prior art, the beneficial effects of the programmable logic controller provided by the embodiment of the present application are the same as the beneficial effects of the downtime diagnosis method of the programmable logic controller provided by the above embodiment, and other technical features in the programmable logic controller are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0079] It should be understood that the various parts of the present disclosure can be implemented with hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0080] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0081] An embodiment of the present application also provides a computer-readable storage medium having computer-readable program instructions stored thereon, and the computer-readable program instructions are used to execute the downtime diagnosis method of the programmable logic controller in the above-mentioned embodiment 1.

[0082] The computer-readable storage medium provided in the embodiment of the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.

[0083] The computer-readable storage medium may be included in a programmable logic controller; or may exist independently without being assembled into a programmable logic controller.

[0084] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by a programmable logic controller, the programmable logic controller executes: after the programmable logic controller triggers a downtime exception, it collects downtime exception site information and location area information corresponding to the user program; converts the instruction address corresponding to the downtime exception site information into a corresponding function name; and, based on the location area information, determines the instruction address corresponding to the user program, and converts the instruction address corresponding to the user program into a corresponding function name; adds each of the function names to an initial function call stack to obtain a downtime exception site function call stack, wherein the downtime exception site function call stack is used to determine the cause of the downtime of the programmable logic controller.

[0085] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0086] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0087] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of the module does not limit the unit itself in some cases.

[0088] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions for executing the above-mentioned method for diagnosing downtime of a programmable logic controller, and can solve the technical problem that the current programmable logic controller downtime diagnosis scheme cannot handle downtime anomalies caused by user programs and has limitations. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the embodiment of the present application are the same as the beneficial effects of the method for diagnosing downtime of a programmable logic controller provided in the above-mentioned embodiment 1, and will not be repeated here.

[0089] An embodiment of the present application further provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the programmable logic controller downtime diagnosis method as described above.

[0090] The computer program product provided by the present application can solve the technical problem that the current downtime diagnosis solution for programmable logic controllers cannot handle downtime exceptions caused by user programs and has limitations. Compared with the prior art, the beneficial effects of the computer program product provided by the embodiment of the present application are the same as the beneficial effects of the downtime diagnosis method for programmable logic controllers provided by the above-mentioned embodiment 1, and will not be elaborated here.

[0091] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.

Claims

1. A method for diagnosing downtime of a programmable logic controller, characterized in that: The downtime diagnosis method of the programmable logic controller comprises: After the programmable logic controller triggers a downtime exception, collect the downtime exception site information and the location area information corresponding to the user program; Converting the instruction address corresponding to the abnormal downtime site information into a corresponding function name; and determining the instruction address corresponding to the user program based on the location area information, and converting the instruction address corresponding to the user program into a corresponding function name; Each of the function names is added to an initial function call stack to obtain a crash exception site function call stack, wherein the crash exception site function call stack is used to determine the crash cause of the programmable logic controller.

2. The method for diagnosing a downtime of a programmable logic controller according to claim 1, wherein: The crash exception site information at least includes crash exception register information, crash exception thread stack information, and location area information where the software program and dependent libraries are loaded into the memory.

3. The method for diagnosing a downtime of a programmable logic controller according to claim 2, wherein: The step of converting the instruction address corresponding to the abnormal downtime site information into the corresponding function name comprises: Based on the time sequence of each piece of data in the abnormal downtime site information, each piece of data in the abnormal downtime site information is analyzed in turn to obtain the instruction address corresponding to each piece of data in the abnormal downtime site information; Based on the mapping relationship between instruction addresses and function names, the instruction addresses corresponding to the various pieces of data in the abnormal scene information are converted into corresponding function names in sequence.

4. The method for diagnosing a downtime of a programmable logic controller according to claim 2, wherein: The step of converting the instruction address corresponding to the user program into the corresponding function name comprises: Based on the mapping relationship between the instruction address corresponding to the user program and the function name, the instruction address corresponding to the user program is converted into the corresponding function name in sequence.

5. The method for diagnosing a downtime of a programmable logic controller according to claim 2, wherein: The step of adding each of the function names to the initial function call stack to obtain the function call stack at the crash exception site includes: Based on the time sequence corresponding to each of the function names, each of the function names is added to the initial function call stack in sequence to obtain the crash exception site function call stack.

6. The method for diagnosing a downtime of a programmable logic controller according to claim 1, wherein: After the programmable logic controller triggers a downtime exception, before the step of collecting downtime exception site information and location area information corresponding to the user program, the method further includes: A downtime exception handling callback is registered in the operating system corresponding to the programmable logic controller, wherein the downtime exception handling callback is used to control the programmable logic controller to collect downtime exception site information and location area information corresponding to the user program after the programmable logic controller triggers a downtime exception.

7. The method for diagnosing a downtime of a programmable logic controller according to any one of claims 1 to 6, characterized in that: After the step of adding each of the function names to a preset initial function call stack to obtain a crash exception on-site function call stack, the method further includes: Visually display the function call stack at the crash exception site; Or, storing the abnormal crash scene function call stack in a preset database; Or, the crash exception on-site function call stack is written into a local file, an external server file or a cloud server file.

8. A programmable logic controller downtime diagnosis device, characterized in that: The downtime diagnosis device of the programmable logic controller comprises: An information collection module is used to collect the abnormal downtime site information and the location area information corresponding to the user program after the programmable logic controller triggers the abnormal downtime; An address conversion module is used to convert the instruction address corresponding to the abnormal downtime site information into a corresponding function name; and determine the instruction address corresponding to the user program based on the location area information, and convert the instruction address corresponding to the user program into a corresponding function name; The call stack generation module is used to add each of the function names to the initial function call stack to obtain a crash exception site function call stack, wherein the crash exception site function call stack is used to determine the crash cause of the programmable logic controller.

9. A programmable logic controller, characterized in that: The programmable logic controller comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the steps of the downtime diagnosis method of the programmable logic controller as described in any one of claims 1 to 7.

10. A readable storage medium, characterized in that: The readable storage medium is a computer-readable storage medium, on which is stored a program for implementing a downtime diagnosis method for a programmable logic controller. The program for implementing a downtime diagnosis method for a programmable logic controller is executed by a processor to implement the steps of the downtime diagnosis method for a programmable logic controller as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Downtime processing method and electronic equipment

    CN120743685A