METHOD OF OPTIMALLY COMPILING PLC COMMAND

20170115972 ยท 2017-04-27

    Inventors

    Cpc classification

    International classification

    Abstract

    Disclosed embodiments include a system and a method of compiling a PLC (Programmable Logic Controller) command. In some embodiments, the method includes: determining one compile processing scheme chosen from a plurality of compile processing schemes for a command included in a program to be executed in a PLC; and executing a command compile or compiler optimized for a rate or a size based on the chosen compile processing scheme.

    Claims

    1. A method of compiling a PLC (Programmable Logic Controller) command, the method comprising: determining a compiler processing scheme chosen from a plurality of compiler processing schemes for a command included in a program to be executed in a PLC; and executing a command compiler optimized for a rate or a size based on the determined compile processing scheme.

    2. The method according to claim 1, wherein executing the command compiler includes: determining whether the determined compile processing scheme is a simple command processing based on a criterion when the determined compile processing scheme is determined to be for the size; when the determined compile processing scheme is determined to be the simple compiler processing scheme, executing the command compiler in an assembly language by a direct compile processing scheme; and when the determined compile processing scheme is determined to not be the simple compiler processing scheme: executing the command compiler in an indirect compiler processing scheme by identifying an address of a command processing function stored in a binary file with reference to a command map table optimized for the rate; invoking the command processing function; copying the command processing function needed to execute the command into a compile area to identify the address of the command processing function upon driving the PLC; and invoking the stored function to execute the command.

    3. The method according to claim 1, wherein executing the command compiler includes: when the determined compiler processing scheme is determined to be for the size: executing the command compiler in an indirect compiler processing scheme by identifying an address of a command processing function stored in a binary file with reference to a command map table optimized for the size; invoking the command processing function; copying the command processing function needed to execute the command into a compile area to identify the address of the command processing function upon driving the PLC; and invoking the stored function to execute the command.

    4. The method according to claim 1, wherein executing the command compiler includes: when the determined compiler processing scheme is determined to be a default scheme, determining whether the determined compiler processing scheme is a simple command processing based on a criterion; when the determined compiler processing scheme is determined to be the simple compile processing scheme, executing the command compiler by a direct compiler processing scheme; and when the determined compile processing scheme is determined to not be the simple compile processing scheme, executing the command compiler in an indirect compiler processing scheme by identifying an address of a command processing function stored in a binary file with reference to a command map table set by default; invoking the command processing function; copying the command processing function needed to execute the command into a compile area to identify the address of the command processing function upon driving the PLC; and invoking the stored function to execute the command.

    5. The method according to claim 1, wherein determining the compile processing scheme includes: providing a first option box corresponding to the rate and a second option box corresponding to the size; and determining that a rate option is chosen if the first option box has been checked, the size option is chosen if the second option box has been checked, and the default is chosen if no option box has been checked.

    6. The method according to claim 1, further comprising: setting to automatically choose the compiler processing scheme of a plurality of compiler processing schemes for the command based on a program size or a remaining data storage capacity in the PLC.

    7. The method according to claim 6, wherein setting to automatically choose the compiler processing scheme includes: setting to choose the compiler processing scheme for the rate under a normal condition or for the size when the program size is over any reference size.

    8. The method according to claim 6, wherein setting to automatically choose the compiler processing scheme includes: setting to choose the compiler processing scheme for the rate under a normal condition or for the size when the remaining data storage capacity in the PLC is below any reference capacity.

    Description

    BRIEF DESCRIPTION OF DRAWINGS

    [0025] FIG. 1 is a block diagram illustrating user's codes in a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    [0026] FIG. 2 is a block diagram illustrating developer's codes in a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    [0027] FIG. 3 is a block diagram illustrating a command processing in a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    [0028] FIG. 4 is a flowchart illustrating a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    [0029] FIG. 5 is a view illustrating a process of setting the compile processing scheme to optimally compile a PLC command according to some embodiments of the present disclosure.

    [0030] FIG. 6 is a block diagram illustrating a process of generating an object file in a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    [0031] FIG. 7 is a view illustrating a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    [0032] FIG. 8 is a view illustrating a direct compiling in a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    [0033] FIG. 9 is a flowchart illustrating an indirect compiling in a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    [0034] FIG. 10 is a flowchart illustrating a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    DETAILED DESCRIPTION

    [0035] The present disclosure may be variously modified and include various embodiments. Therefore, some specific embodiments will be exemplified in the drawings by way of illustrations and be described in the detailed description below. However, this is not intended to limit the present disclosure to the specific embodiments and it is to be understood that they cover all modifications, equivalents, or alterations falling into the spirit and the scope of the present disclosure.

    [0036] Hereinafter, embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings.

    [0037] FIG. 1 is a block diagram illustrating user's codes in a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    [0038] Referring to FIG. 1, a user writes a program 1 by using a Programming and Debugging Tool (PADT).

    [0039] FIG. 2 is a block diagram illustrating developer's codes in a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    [0040] Referring to FIG. 2, a developer creates command processing function codes 2 by using a source editing tool. The command processing function codes 2 may be, for example, void move (void). The command processing function codes 2 created by the developer are compiled into object codes 4 of a binary format by a MPU dedicated complier 3. The MPU dedicated compiler 3 may be a C language or a C++ compiler.

    [0041] The compiled object codes 4 of a binary format store thereon command processing functions. These object codes 4 are used to extract a start address and a size on a basis of command, so that a command map table is created.

    [0042] FIG. 3 is a block diagram illustrating a command processing in a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    [0043] Referring to FIG. 3, a process executed when the user has written a MOVE command in the PADT is shown. A PADT compiler 5 may essentially convert the program written by the user into a format which enables a PLC to operate. In order to execute the command, processing functions should be invoked based on the command.

    [0044] When the user has written a MOVE command 6 through the PADT, the MOVE command processing function may be invoked during processing the program 7 (8).

    [0045] If the MOVE command is invoked, an address of a MOVE command processing function stored in the binary file 10 is identified with reference to the command map table 9 (11) and then the MOVE command processing function code stored in a binary file 10 is invoked (12). Subsequently, the MOVE command processing function code is inserted into a compile area (13). When the compile processing completes as described above, a PLC drive file 14 is generated.

    [0046] FIG. 4 is a flowchart illustrating a method of optimally compiling a PLC command according to some embodiments of the present disclosure. FIG. 5 is a view illustrating a process of setting the compile processing scheme to optimally compile a PLC command according to some embodiments of the present disclosure.

    [0047] Referring to FIG. 4, program codes to be executed in the PLC are created by using a ladder program of the PADT (S100).

    [0048] Thereafter, one of a plurality of compile processing schemes for a command comprised in a program to be executed in the PLC is set (S200).

    [0049] For example, some embodiments of the present disclosure may cause the user to check or release a rate option and a size option so that a scheme for optimizing the compile processing can be set. At this time, if no option is chosen, it may be set that a compile or compiler utilizing elementary object codes is executed. Meanwhile, if the size option is chosen, it may be set that a compiler optimized for the size is executed.

    [0050] Referring to FIG. 5, a choose box 10 of choosing the rate option or the size option is shown. The choose box 10 may include a first choose box 11 corresponding to the rate option and a second choose box 12 corresponding to the size option.

    [0051] If the first box 11 has been checked, it is determined that the rate option is chosen. On the contrary, if the second choose box 12 has been checked, it is determined that the size option is chosen. However, if there are no any checks on the first choose box 11 and the second choose box 12, it is determined that a default option is chosen.

    [0052] A command compile is executed according to the chosen one of the plurality of compile processing schemes for the command included in the program to be executed in the PLC and as a result the PLC drive file is generated (S300).

    [0053] To do so, it is determined which compile processing scheme has been chosen from the plurality of compile processing schemes for the command included in the program to be executed in the PLC (S200).

    [0054] Referring to FIG. 6, when the chosen compile processing scheme is determined to be for a rate, the MPU dedicated compiler generates object codes in a format of binary file optimized for the rate.

    [0055] When the chosen compile processing scheme is determined to be for the size, the MPU dedicated compiler generates object codes in a format of binary file optimized for the size.

    [0056] When the chosen compile processing scheme is determined to be default, the MPU dedicated compiler generates object codes in a format of binary set by default.

    [0057] Thereafter, upon processing the command, the PADT compiler may convert the program written by the user into a format which enables a PLC to operate.

    [0058] That is, when the chosen compile processing scheme is for the rate, the PADT compiler uses the object codes optimized for the rate to execute the command compile or compiler optimized for the rate, thereby generating the PLC drive file. Meanwhile, when the chosen compile processing scheme is for the size, the PADT compiler uses the object codes optimized for the size to execute the command compile or compiler optimized for the size, thereby generating the PLC drive file.

    [0059] Further, when the chosen compile processing scheme is default, the PADT compiler uses the object codes set by default to execute the command compile, thereby generating the PLC drive file.

    [0060] The PLC drive file generated as described above is downloaded to the PLC (S400).

    [0061] FIG. 7 is a view illustrating a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    [0062] Referring to FIG. 7, it is determined which compile processing scheme has been chosen from the plurality of compile processing schemes for the command included in the program to be executed in the PLC (S301).

    [0063] When the chosen compile processing scheme is determined to be for the rate in S301, it is determined whether the chosen compile processing scheme is a simple command processing based on any established criterion (S302). The criterion as to whether it is the simple command processing is whether the command can be directly compiled. If the command can be directly compiled, it conforms to the simple command.

    [0064] As such, when the rate option is chosen, the PADT compiler examines the in-use command to determine whether the in-use command is one that can be compiled by a direct compile processing scheme.

    [0065] For example, if codes of one command are very long and complicate, the direct compile cannot be executed because it may be written into C codes in a CPU. Therefore, when it is determined that the command can be directly compiled, the PADT compiler directly executes the compile in an assembly language optimized for the rate. However, when it is determined that the command cannot be directly compiled, the PADT compiler follows a command execution routine, which is written into C codes, in relation to the rate option.

    [0066] Herein, the direct compile is any compile processing scheme by which the PADT compiler executes and stores the command as shown in FIG. 8. When the user writes any command, the PADT compiler upon compiling allows all codes for processing the command to be stored on a PLC compile area. Then, if there is any command used in the program processing, the command can be executed without the need of invoking any separate function because execution codes for the command have been stored on the compile area.

    [0067] Meanwhile, for the indirect compile, when the user writes any command by the ladder program as shown in FIG. 9, the PADT compiler examines the command while processing the compile. The PADT compiler identifies an address of the command processing function stored in the binary file with reference to the command map table stored on the PADT and then invokes the command processing function. Then, the command processing function needed to execute the command is copied to an ending portion into the compile area of the PLC. Accordingly, upon driving the PLC, the command processing can be made by identifying the address of the command processing function and invoking the stored function.

    [0068] When in S302 the chosen compile processing scheme is determined to be a simple command processing, the command compile is executed in an assembly language by the direct compile processing scheme (S303).

    [0069] Meanwhile, when in S302 the chosen compile processing scheme is determined to not be a simple command processing, the PADT compiler identifies an address of the command processing function stored in the binary file with reference to the command map table optimized for the rate (S304). Subsequently, the command processing function is invoked based on the address of the command processing function (S305), the command processing function needed to execute the command is copied into the compile area so that the command compile is executed by the indirect compile processing scheme (S306). Accordingly, upon driving the PLC, the command can be executed by identifying the address of the command processing function and invoking the stored function.

    [0070] Meanwhile, when in S301 the chosen compile processing scheme is determined to be for the size, the PADT compiler identifies an address of the command processing function stored in the binary file with reference to the command map table optimized for the size (S307). Subsequently, the command processing function is invoked based on the address of the command processing function (S308), the function needed to execute the command is copied into the compile area so that the command compile is executed by the indirect compile processing scheme (S309). Accordingly, upon driving the PLC, the command can be executed by identifying the address of the command processing function the PLC and invoking the stored function.

    [0071] As such, if the chosen compile processing scheme is for the size, the PADT compiler executes the indirect compile on the in-use command. The indirect compile processing scheme is useful to reduce the overall program size because it would copy the execution routine only once in relation to the identical command. Further, it may compile the command execution routine created in C codes in relation to the size option upon processing the indirect compile, thereby reducing the program size.

    [0072] Meanwhile, when the chosen compile processing scheme is determined to be default in S301, it is determined whether the chosen compile processing scheme is a simple command processing based on any established criterion (S310).

    [0073] When in S310 the chosen compile processing scheme is determined to be a simple command processing, the command compile is executed by the direct compile processing scheme (S311).

    [0074] However, when in S310 the chosen compile processing scheme is determined to not be a simple command processing, an address of the command processing function stored in the binary file with reference to the command map table set by default is identified (S312). Subsequently, the command processing function is invoked based on the address of the command processing function (S313), the function needed to execute the command is copied into the compile area so that the command compile is executed by the indirect compile processing scheme (S314). Accordingly, upon driving the PLC, the command can be executed by identifying the address of the command processing function and invoking the stored function.

    [0075] As such, the user may choose the compile processing scheme for the command suitably to system environment. If the rate option is chosen, the PLC program is compiled to optimize the processing rate and thus the control is enabled in an increased rate of 32% relative to the prior art. Also, if the size option is chosen, the program may be used with its size increasing up to 30% relative to the existing program size. Therefore, the PLC employing some embodiments of the present disclosure becomes flexible in its processing rate and program size where it can cover, so that it can be applied to various systems.

    [0076] According to some embodiments of the present disclosure, a method of optimally compiling a PLC program causes a user to choose any compile processing scheme so that the PLC program can be flexibly applied to various systems.

    [0077] FIG. 10 is a flowchart illustrating a method of optimally compiling a PLC command according to some embodiments of the present disclosure.

    [0078] Referring to FIG. 10, program codes to be executed in the PLC are written by using a ladder program of the PADT (S510).

    [0079] The program is set to automatically choose one of a plurality of compile processing schemes for a command included in a program to be executed in the PLC, based on a program size or a remaining data storage capacity in the PLC (S520).

    [0080] For example, in order to automatically choose the one compile processing scheme, the program may be set so that the compile processing scheme for the rate is chosen under a normal condition while the compile processing scheme for the size is chosen when the program size is over any reference size.

    [0081] For another example, in order to automatically choose the one compile processing scheme, the program may be set so that the compile processing scheme for the rate is chosen under a normal condition while the compile processing scheme for the size is chosen when the remaining data storage capacity in the PLC is below any reference capacity.

    [0082] A command compile is executed according to one automatically chosen from the plurality of compile processing schemes for the command included in the program to be executed in the PLC and as a result the PLC drive file is generated (S530).

    [0083] To do so, it is determined which compile processing scheme has been chosen from the plurality of compile processing schemes for the command included in the program to be executed in the PLC.

    [0084] When the chosen compile processing scheme is determined to be for the rate, the command compile or compiler optimized for the rate is executed. When the chosen compile processing scheme is determined to be for the size, the command compile or compiler optimized for the size is executed.

    [0085] When the chosen compile processing scheme is determined to be default, the command compile set by default is executed to generate object codes, and as a result the PLC drive file is generated The generated PLC drive file is downloaded to the PLC (S540).

    [0086] While embodiments according to the present disclosure have been described above, they are non-exhaustive, and those skilled in the art will understand that various modifications and changes derived therefrom can be done within an equivalent range falling into the scope of the present disclosure. Therefore, the true technical scope of the present disclosure should be defined by the appended claims. Various components illustrated in the figures may be implemented as hardware and/or software and/or firmware on a processor, ASIC/FPGA, dedicated hardware, and/or logic circuitry. Also, the features and attributes of the specific embodiments disclosed above may be combined in different ways to form additional embodiments, all of which fall within the scope of the present disclosure. Although the present disclosure provides certain preferred embodiments and applications, other embodiments that are apparent to those of ordinary skill in the art, including embodiments which do not provide all of the features and advantages set forth herein, are also within the scope of this disclosure. Accordingly, the scope of the present disclosure is intended to be defined only by reference to the appended claims.