Function block calling methods, devices, equipment and media of industrial control configuration software

By using the target structure to store and convert it into C language in industrial control configuration software, the problems of too many nodes and breakpoint debugging when converting IEC logic to syntax tree are solved, and the functions are stored in a concise manner and debugged across platforms.

CN116009994BActive Publication Date: 2026-06-30HANGZHOU HOLLYSYS AUTOMATION

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HANGZHOU HOLLYSYS AUTOMATION
Filing Date
2022-12-27
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

In existing technologies, when converting IEC logic into a syntax tree, there are problems such as too many nodes making it difficult to view and the inability to implement breakpoint debugging.

Method used

The address of local variables of the target function block in the industrial control configuration software is stored in the target structure based on preset storage rules, and then converted into C language to generate a .c file. The controller executable file is generated by calling C functions.

Benefits of technology

It achieves easy viewing and concise storage of function blocks, supports breakpoint debugging, and is cross-platform and easy to maintain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116009994B_ABST
    Figure CN116009994B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, and storage medium for calling function blocks in industrial control configuration software, relating to the field of industrial control. The method includes: storing the addresses of local variables of a target function block in the industrial control configuration software using a target structure based on preset storage rules, thereby completing the storage of the target function block; obtaining the structure variable corresponding to the target function block and writing values ​​to the structure variable based on configuration logic; converting the target function block into C language to obtain a corresponding .c file, and calling C functions in the .c file so that the .c file generates a controller executable file through a compilation module, and using the controller executable file to implement the industrial controller's call to the target function block, thereby completing the corresponding industrial control process. Therefore, this application solves the problems of function block storage and function block calling during the conversion of IEC logic into C language.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial control, and in particular to a method, apparatus, device, and storage medium for calling function blocks in industrial control configuration software. Background Technology

[0002] With the deepening application of industrial control systems, when facing larger-scale and more complex control systems, people have gradually realized that the original host computer programming development method is time-consuming, labor-intensive, and unprofitable for projects. At the same time, the widespread application of management information systems and computer-integrated manufacturing systems requires more detailed and in-depth data for production, operation, and decision-making in industrial enterprises to optimize various aspects of production and operation. Therefore, in recent years, the application of configuration software has gradually become more widespread in China. The process from configuring logic to running it in the controller is a core issue in a control system. In existing technologies, after IEC configuration is completed, the IEC logic needs to be downloaded to the controller. Some software converts the IEC logic into a syntax tree, and then converts the syntax tree into binary code before downloading it to the controller. Converting IEC logic to a syntax tree has two main drawbacks: first, converting a simple configuration logic into a syntax tree generates many nodes, making it difficult to view; second, converting to a syntax tree does not enable breakpoint debugging. Summary of the Invention

[0003] In view of this, the purpose of this invention is to provide a method, apparatus, device, and storage medium for calling function blocks in industrial control configuration software, which can solve the problems of storing and calling function blocks when converting IEC logic into C language. The specific solution is as follows:

[0004] In a first aspect, this application discloses a method for calling function blocks in industrial control configuration software, including:

[0005] Based on preset storage rules, the addresses of local variables of the target function block in the industrial control configuration software are stored using the target structure to complete the storage of the target function block.

[0006] Obtain the structure variable corresponding to the target function block, and write the value of the structure variable based on the configuration logic;

[0007] The target function block is converted into C language to obtain the corresponding .c file. The C functions in the .c file are then called so that the .c file is compiled into a controller executable file by the compilation module. Based on the controller executable file, the industrial controller calls the target function block to complete the corresponding industrial control process.

[0008] Optionally, the step of storing the addresses of local variables of the target function block in the industrial control configuration software using the target structure based on preset storage rules to complete the storage of the target function block includes:

[0009] Establish a one-to-one correspondence between the structure variables of the target structure and the local variables of the target function block, and store the local variables of the target function block based on the one-to-one correspondence and the address of the target structure.

[0010] Optionally, writing values ​​to the structure variables based on configuration logic further includes:

[0011] If the input and output variables of the target function block are not assigned values ​​in the configuration logic, then the structure variables will not be written to and will be set to default values.

[0012] Optionally, converting the target function block into C language to obtain the corresponding .c file includes:

[0013] The target function block is converted into C language to obtain the corresponding target header file (.c file) associated with the target function block.

[0014] Optionally, the target header files associated with the target function block include: the header file corresponding to the target function block and the header files corresponding to the functions called by the logic of the target function block.

[0015] Optionally, converting the target function block into C language to obtain the corresponding .c file includes:

[0016] The target function block is converted into C language to obtain the corresponding .c file. The C function in the .c file is a function with an empty return value and input parameters of the structure variable corresponding to the target function block and the forced address offset.

[0017] Optionally, the forced address offset includes: forcing a relative offset between the address of the tag storage and the variable address.

[0018] Secondly, this application discloses a function block calling device for industrial control configuration software, comprising:

[0019] The function block storage module is used to store the addresses of local variables of the target function block in the industrial control configuration software based on the target structure according to the preset storage rules, so as to complete the storage of the target function block;

[0020] The variable write-value module is used to obtain the structure variable corresponding to the target function block and write the value of the structure variable based on the configuration logic;

[0021] The function call module is used to convert the target function block into C language to obtain the corresponding .c file, and to call the C functions in the .c file so that the .c file can be compiled into a controller executable file by the compilation module. Based on the controller executable file, the industrial controller can call the target function block to complete the corresponding industrial control process.

[0022] Thirdly, this application discloses an electronic device, including:

[0023] Memory, used to store computer programs;

[0024] A processor is used to execute the computer program to implement the aforementioned function block calling method of the industrial control configuration software.

[0025] Fourthly, this application discloses a computer-readable storage medium for storing a computer program, which, when executed by a processor, implements the aforementioned function block calling method of industrial control configuration software.

[0026] As can be seen from the above, when calling function blocks in industrial control configuration software, this application first uses a target structure to store the addresses of local variables of the target function block in the industrial control configuration software based on preset storage rules, thereby completing the storage of the target function block; it then obtains the structure variable corresponding to the target function block and writes values ​​to the structure variable based on the configuration logic; finally, it converts the target function block into C language to obtain a corresponding .c file, and calls the C functions in the .c file so that the .c file generates a controller executable file through the compilation module, and the industrial controller calls the target function block based on the controller executable file to complete the corresponding industrial control process. It is evident that, compared with converting to C syntax, converting to C is easier to view, more concise, and can be debugged in Visual Studio, offering advantages such as cross-platform compatibility and ease of maintenance. This application primarily addresses the problems of function block storage and function block calling when converting IEC logic to C language. Attached Figure Description

[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0028] Figure 1 A flowchart of a function block calling method for industrial control configuration software provided in this application;

[0029] Figure 2 A schematic diagram of the C-to-C conversion process for function block calls provided in this application;

[0030] Figure 3 A flowchart illustrating a specific function block calling method for industrial control configuration software provided in this application;

[0031] Figure 4 A schematic diagram illustrating the correspondence rules between structure members and local variables of functional blocks provided in this application;

[0032] Figure 5 A schematic diagram of a function block calling device for industrial control configuration software provided in this application;

[0033] Figure 6 This application provides a structural diagram of an electronic device. Detailed Implementation

[0034] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0035] In existing technologies, after IEC configuration is completed, the IEC logic needs to be downloaded to the controller. Some software converts the IEC logic into a syntax tree, and then converts the syntax tree into binary code before downloading it to the controller. Converting IEC logic to a syntax tree has two main drawbacks: first, converting a simple configuration logic into a syntax tree generates many nodes, making it difficult to view; second, converting to a syntax tree does not enable breakpoint debugging. To solve this problem, this application provides a function block calling method for industrial control configuration software, which solves the problems of function block storage and calling when converting IEC logic into more easily viewable and concise C language.

[0036] See Figure 1 As shown in the figure, an embodiment of the present invention discloses a method for calling function blocks in industrial control configuration software, including:

[0037] Step S11: Based on preset storage rules, use the target structure to store the addresses of local variables of the target function block in the industrial control configuration software, so as to complete the storage of the target function block.

[0038] In this embodiment, the local variables of the function block include input variables, output variables, input-output variables, and internal variables. Since the addresses of these local variables are not contiguous, it is impossible to access all pins of the function block through a single address. Therefore, it is necessary to use a target structure based on preset storage rules to store the addresses of the local variables of the target function block in the industrial control configuration software, thereby completing the storage of the target function block.

[0039] Step S12: Obtain the structure variable corresponding to the target function block, and write the value of the structure variable based on the configuration logic.

[0040] In this embodiment, a function block not only needs to store the values ​​of each pin, but also needs to execute certain logic to obtain the corresponding results. When configuring the logic for a function block call in the control software, such as... Figure 2 As shown, firstly, the structure variable corresponding to the function block is obtained, and then values ​​are written to each member of the structure variable according to the configuration logic. The step of writing values ​​to the structure variable based on the configuration logic further includes: if the input and output variables of the target function block are not assigned values ​​in the configuration logic, then no values ​​are written to the structure variable, and default values ​​are adopted.

[0041] Step S13: Convert the target function block into C language to obtain the corresponding .c file, and call the C functions in the .c file so that the .c file generates a controller executable file through the compilation module, and realize the industrial controller to call the target function block based on the controller executable file to complete the corresponding industrial control process.

[0042] In this embodiment, the target function block is converted into C language to obtain the corresponding .c file of the target header file associated with the target function block. The target header file associated with the target function block includes: the header file corresponding to the target function block and the header files corresponding to the functions called by the logic of the target function block. Then, by calling the C functions in the .c file, the .c file is compiled into a controller executable file by the compilation module. Based on the controller executable file, the industrial controller calls the target function block to complete the corresponding industrial control process.

[0043] As can be seen from the above, when calling function blocks in industrial control configuration software, this application first uses a target structure to store the addresses of local variables of the target function block in the industrial control configuration software based on preset storage rules, thereby completing the storage of the target function block; it then obtains the structure variable corresponding to the target function block and writes values ​​to the structure variable based on the configuration logic; finally, it converts the target function block into C language to obtain a corresponding .c file, and calls the C functions in the .c file so that the .c file generates a controller executable file through the compilation module, and the industrial controller calls the target function block based on the controller executable file to complete the corresponding industrial control process. It is evident that, compared with converting to C syntax, converting to C is easier to view, more concise, and can be debugged in Visual Studio, offering advantages such as cross-platform compatibility and ease of maintenance. This application primarily addresses the problems of function block storage and function block calling when converting IEC logic to C language.

[0044] See Figure 3 As shown in the figure, this invention discloses a specific method for calling function blocks in industrial control configuration software, including:

[0045] Step S21: Establish a one-to-one correspondence between the structure variables of the target structure and the local variables of the target function block, and store the local variables of the target function block based on the one-to-one correspondence and the address of the target structure.

[0046] In this embodiment, a structure is used to store the addresses of local variables of the function block. Each member of the structure corresponds one-to-one with a local variable of the function block, and all members are pointers. The correspondence rules are as follows: Figure 4 As shown. In a specific embodiment, assuming that its inputs, outputs, input-output pairs, and local variables are all of type BOOL, and their names are in, out, inout, and temp respectively, then its storage format is as follows (to prevent the variable names from leading with numbers during configuration, __AT__ is uniformly added before the names):

[0047] struct__AT__FB001

[0048] {

[0049] bool*H_IN;

[0050] bool*H_OUT;

[0051] bool*H_INOUT;

[0052] bool*H_TEMP;

[0053] }

[0054] This structure is defined in the .h file corresponding to the FB001 function block.

[0055] Step S22: Obtain the structure variable corresponding to the target function block, and write the value of the structure variable based on the configuration logic.

[0056] Step S23: Convert the target function block into C language to obtain the corresponding .c file. The C function in the .c file is a function with an empty return value and input parameters being the structure variable corresponding to the target function block and the forced address offset.

[0057] In this embodiment, the logic of the function block, after being converted to C, corresponds to a .c file. Taking FB001 as an example again, this .c file contains the following: the header files that need to be referenced, including the header files corresponding to the function block itself and the header files corresponding to the functions called in the function block logic, and a function named H_FB001, with the variable __AT__FB001 as input parameter and a forced address offset. The forced address offset includes: the relative offset between the address of the forced marker storage and the address of the variable. It should be noted that the content of this function is the internal logic of the function block, and the return value is empty. Furthermore, the H_FB001 function body internally implements the updating of output and input / output variables.

[0058] Step S24: By calling the C functions in the .c file, the .c file is compiled into a controller executable file by the compilation module, and the industrial controller calls the target function block based on the controller executable file to complete the corresponding industrial control process.

[0059] The specific processes of steps S22 and S24 can be found in the relevant content disclosed in the foregoing embodiments, and will not be repeated here.

[0060] As can be seen from the above, when calling function blocks in industrial control configuration software, this application first establishes a one-to-one correspondence between the structure variables of the target structure and the local variables of the target function block, and stores the addresses of the local variables of the target function block based on the one-to-one correspondence and the target structure; obtains the structure variables corresponding to the target function block, and writes values ​​to the structure variables based on the configuration logic; converts the target function block into C language to obtain the corresponding .c file, and the C functions in the .c file are functions with empty return values ​​and input parameters of the structure variables corresponding to the target function block and forced address offsets. Finally, by calling the C functions in the .c file, the .c file generates a controller executable file through the compilation module, and the industrial controller calls the target function block based on the controller executable file to complete the corresponding industrial control process. It is evident that, compared with converting to C syntax, converting to C is easier to view, more concise, and can be debugged in Visual Studio, offering advantages such as cross-platform compatibility and ease of maintenance. This application focuses on solving the problems of function block storage and function block calling when converting IEC logic into C language.

[0061] See Figure 5 As shown, this embodiment of the invention discloses a function block calling device for industrial control configuration software, comprising:

[0062] Function block storage module 11 is used to store the addresses of local variables of target function blocks in industrial control configuration software using target structures based on preset storage rules, so as to complete the storage of the target function blocks;

[0063] The variable writing module 12 is used to obtain the structure variable corresponding to the target function block and write the structure variable based on the configuration logic.

[0064] The function call module 13 is used to convert the target function block into C language to obtain the corresponding .c file, and to call the C functions in the .c file so that the .c file can generate a controller executable file through the compilation module, and to realize the industrial controller's call to the target function block based on the controller executable file to complete the corresponding industrial control process.

[0065] As can be seen from the above, when calling function blocks in industrial control configuration software, this application first uses a target structure to store the addresses of local variables of the target function block in the industrial control configuration software based on preset storage rules, thereby completing the storage of the target function block; it then obtains the structure variable corresponding to the target function block and writes values ​​to the structure variable based on the configuration logic; finally, it converts the target function block into C language to obtain a corresponding .c file, and calls the C functions in the .c file so that the .c file generates a controller executable file through the compilation module, and the industrial controller calls the target function block based on the controller executable file to complete the corresponding industrial control process. It is evident that, compared with converting to C syntax, converting to C is easier to view, more concise, and can be debugged in Visual Studio, offering advantages such as cross-platform compatibility and ease of maintenance. This application primarily addresses the problems of function block storage and function block calling when converting IEC logic to C language.

[0066] In some specific embodiments, the function block storage module 11 may include:

[0067] The correspondence establishment unit is used to establish a one-to-one correspondence between the structure variables of the target structure and the local variables of the target function block, and to store the local variables of the target function block based on the one-to-one correspondence and using the address of the local variables of the target function block in the target structure.

[0068] In some specific embodiments, the variable writing module 12 may further include:

[0069] The default value unit is used to ensure that if the input and output variables of the target function block are not assigned values ​​in the configuration logic, the structure variable is not written to and the default value is adopted.

[0070] In some specific embodiments, the function call module 13 may include:

[0071] The function block conversion unit is used to convert the target function block into C language to obtain the corresponding target header file .c file associated with the target function block.

[0072] In some specific embodiments, the target header file associated with the target functional block includes: the header file corresponding to the target functional block and the header file corresponding to the functions called by the logic of the target functional block.

[0073] In some specific embodiments, the function call module 13 may include:

[0074] The .c file determination unit is used to convert the target function block into C language to obtain the corresponding .c file. The C function in the .c file is a function with an empty return value and input parameters being the structure variable corresponding to the target function block and the forced address offset.

[0075] In some specific embodiments, the forced address offset includes: forcing a relative offset between the address of the tag storage and the address of the variable.

[0076] Furthermore, embodiments of this application also disclose an electronic device, Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.

[0077] Figure 6 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the function block calling method of the industrial control configuration software disclosed in any of the foregoing embodiments. Alternatively, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0078] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0079] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0080] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the function block calling method of the industrial control configuration software executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.

[0081] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned function block calling method for industrial control configuration software. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0082] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0083] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0084] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0085] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0086] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for calling function blocks in industrial control configuration software, characterized in that, include: Based on preset storage rules, the addresses of local variables of the target function block in the industrial control configuration software are stored using the target structure to complete the storage of the target function block. Obtain the structure variable corresponding to the target function block, and write the value of the structure variable based on the configuration logic; The target function block is converted into C language to obtain the corresponding .c file. The C functions in the .c file are then called so that the .c file is compiled into a controller executable file by the compilation module. Based on the controller executable file, the industrial controller calls the target function block to complete the corresponding industrial control process. The method of storing the addresses of local variables of a target function block in industrial control configuration software using a target structure based on preset storage rules to complete the storage of the target function block includes: Establish a one-to-one correspondence between the structure variables of the target structure and the local variables of the target function block, and store the local variables of the target function block based on the one-to-one correspondence and the address of the local variables of the target function block using the target structure; wherein, the data type of the structure variables and each local variable is pointer type; The step of converting the target function block into C language to obtain the corresponding .c file includes: The target function block is converted into C language to obtain the corresponding .c file. The C function in the .c file is a function with an empty return value and input parameters of the structure variable corresponding to the target function block and the forced address offset. The forced address offset includes: forcing the relative offset between the address of the stored tag and the address of the variable.

2. The function block invocation method according to claim 1, characterized in that, The method of writing values ​​to the structure variables based on configuration logic also includes: If the input and output variables of the target function block are not assigned values ​​in the configuration logic, then the structure variables will not be written to and will be set to default values.

3. The function block invocation method according to claim 1, characterized in that, The step of converting the target function block into C language to obtain the corresponding .c file includes: The target function block is converted into C language to obtain the corresponding target header file (.c file) associated with the target function block.

4. The function block invocation method according to claim 3, characterized in that, The target header files associated with the target function block include: the header file corresponding to the target function block and the header files corresponding to the functions called by the logic of the target function block.

5. A function block calling device for industrial control configuration software, characterized in that, include: The function block storage module is used to store the addresses of local variables of the target function block in the industrial control configuration software based on the target structure according to the preset storage rules, so as to complete the storage of the target function block; The variable write-value module is used to obtain the structure variable corresponding to the target function block and write the value of the structure variable based on the configuration logic; The function call module is used to convert the target function block into C language to obtain the corresponding .c file, and to call the C functions in the .c file so that the .c file can be compiled into a controller executable file by the compilation module, and the industrial controller can call the target function block based on the controller executable file to complete the corresponding industrial control process; The function block storage module is used to establish a one-to-one correspondence between the structure variables of the target structure and the local variables of the target function block, and to store the local variables of the target function block based on the one-to-one correspondence and using the address of the local variables of the target function block in the target structure; wherein, the data types of the structure variables and the local variables are all pointer types. The function call module is used to convert the target function block into C language to obtain the corresponding .c file. The C function in the .c file is a function with an empty return value and input parameters of the structure variable corresponding to the target function block and a forced address offset. The forced address offset includes: forcing the relative offset between the address of the stored tag and the address of the variable.

6. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the function block calling method of the industrial control configuration software as described in any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that, Used to store computer programs, which, when executed by a processor, implement the function block calling method of industrial control configuration software as described in any one of claims 1 to 4.