Structuring support device, structuring support method, and structuring support program

The structuring support device addresses the challenge of converting multiple similar programs into appropriate function blocks by determining variable types based on usage within and outside program blocks, enhancing the efficiency of ladder program structuring and reducing man-hours required.

WO2024247284A1PCT designated stage expired Publication Date: 2024-12-05MITSUBISHI ELECTRIC CORP
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/JP2023/020727
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-06-02
Publication Date
2024-12-05

AI Technical Summary

Technical Problem

Existing technologies face challenges in converting multiple similar programs into appropriate function blocks in ladder programs, as variables like devices and labels may not be correctly typed when multiple programs are combined, leading to inefficient structuring support.

Method used

A structuring support device with a program analysis unit that identifies similar program blocks, determines the type of variables based on their usage within and outside these blocks, and generates function blocks that convert multiple program blocks into a single function, ensuring appropriate variable typing.

Benefits of technology

This approach allows for accurate variable typing and conversion, reducing the time required for structuring ladder programs and improving the efficiency of program conversion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure JP2023020727_05122024_PF_FP_ABST
    Figure JP2023020727_05122024_PF_FP_ABST
Patent Text Reader

Abstract

A structuring support device (10) sets, as a target variable, each of one or more variables used in a plurality of similar program blocks included in a ladder program. The structuring support device (10) determines the type of each target variable according to whether or not the target variable satisfies the condition that the target variable is not used outside the plurality of program blocks in the ladder program and is commonly used in the plurality of program blocks. The structuring support device (10) generates function blocks by converting the plurality of program blocks into functions on the basis of the determined type of each target variable.
Need to check novelty before this filing date? Find Prior Art

Description

Structuring support device, structuring support method, and structuring support program

[0001] The present disclosure relates to a technique for supporting the structuring of ladder programs.

[0002] Structuring of ladder programs for programmable logic controllers is also being promoted. Program creation support tools for ladder programs are also required to have functions to support structuring of ladder programs. Structuring of ladder programs includes creating function blocks that break down functions into functions.

[0003] Patent Document 1 describes a technology in which, when a user specifies the range of a program that they want to use as a function block, the specified range is converted into a function block. When converting into a function block, it is necessary to convert variables such as devices and labels used in the selected range into appropriate types of variables and convert them into function blocks. In Patent Document 1, variables are converted into types such as input / output variables and internal variables depending on whether they are used outside the specified range.

[0004] JP 2008-33913 A

[0005] There is a code clone detection technology that detects similar programs. When similar programs extracted using code clone technology or the like are organized into function blocks, it is necessary to combine multiple programs into a single function block. However, with the technology described in Patent Document 1, when multiple programs are simultaneously organized into function blocks, it may not be possible to convert variables such as devices and labels into appropriate types of variables. The present disclosure aims to enable conversion into appropriate variables when combining multiple programs into a single function block.

[0006] The structuring support device according to the present disclosure comprises: a program analysis unit that identifies a plurality of similar program blocks included in a ladder program; and a function block generation unit that determines the type of one or more variables used in the plurality of program blocks identified by the program analysis unit as target variables depending on whether the target variables satisfy the conditions that they are not used outside the plurality of program blocks in the ladder program and are used in common in the plurality of program blocks, and generates function blocks that convert the plurality of program blocks into functions.

[0007] In the present disclosure, the type of a target variable is determined depending on whether the target variable is not used outside of multiple program blocks and is commonly used in multiple program blocks. This makes it possible to appropriately determine the type of a variable and convert it to an appropriate variable.

[0008] 1 is a configuration diagram of a structuring support device 10 according to a first embodiment. 2 is a flowchart of processing by the structuring support device 10 according to the first embodiment. 3 is a diagram showing an example of a ladder program 30 according to the first embodiment. 4 is an explanatory diagram of variable analysis processing according to the first embodiment. 5 is a flowchart of variable type determination processing according to the first embodiment. 6 is an explanatory diagram of variable type determination processing according to the first embodiment. 7 is an explanatory diagram of generation processing of a function block 32 according to the first embodiment. 8 is an explanatory diagram of program conversion processing according to the first embodiment. 9 is a configuration diagram of a structuring support device 10 according to a first modification. 10 is a configuration diagram of a structuring support device 10 according to a second embodiment. 11 is a flowchart of processing by the structuring support device 10 according to the second embodiment. 12 is an explanatory diagram of program comparison processing according to the second embodiment.

[0009] First Embodiment *** Description of Configuration *** The configuration of a structuring support device 10 according to the first embodiment will be described with reference to Figure 1. The structuring support device 10 is a computer that supports the structuring of a ladder program by analyzing the ladder program and dividing it into function blocks. The structuring support device 10 includes hardware such as a processor 11, a memory 12, a storage 13, and a communication interface 14. The processor 11 is connected to other hardware via signal lines and controls this other hardware.

[0010] The processor 11 is an IC that performs processing. IC stands for Integrated Circuit. Specific examples of the processor 11 include a CPU, a DSP, and a GPU. CPU stands for Central Processing Unit. DSP stands for Digital Signal Processor. GPU stands for Graphics Processing Unit.

[0011] The memory 12 is a storage device that temporarily stores data. Specific examples of the memory 12 include SRAM and DRAM. SRAM stands for Static Random Access Memory. DRAM stands for Dynamic Random Access Memory.

[0012] The storage 13 is a storage device that stores data. A specific example of the storage 13 is an HDD. HDD is an abbreviation for Hard Disk Drive. The storage 13 may also be a portable recording medium such as an SD (registered trademark) memory card, CompactFlash (registered trademark), NAND flash, a flexible disk, an optical disk, a compact disk, a Blu-ray (registered trademark) disk, or a DVD. SD is an abbreviation for Secure Digital. DVD is an abbreviation for Digital Versatile Disk.

[0013] The communication interface 14 is an interface for communicating with external devices. Specific examples of the communication interface 14 include Ethernet (registered trademark), USB, and HDMI (registered trademark) ports. USB stands for Universal Serial Bus. HDMI stands for High-Definition Multimedia Interface.

[0014] The structuring support device 10 is connected to a transmission path 90, to which a programmable logic controller is connected, via a communication interface 14. Specific examples of the transmission path 90 include a bus or a network such as a LAN. LAN is an abbreviation for Local Area Network.

[0015] The structuring support device 10 includes, as functional components, a program analysis unit 21, a variable analysis unit 22, a function block generation unit 23, and a program conversion unit 24. The functions of each functional component of the structuring support device 10 are realized by software. The storage 13 stores programs that realize the functions of each functional component of the structuring support device 10. These programs are loaded into the memory 12 by the processor 11 and executed by the processor 11. In this way, the functions of each functional component of the structuring support device 10 are realized.

[0016] 1 shows only one processor 11. However, there may be a plurality of processors 11, and the plurality of processors 11 may cooperate to execute programs that realize the respective functions.

[0017] ***Description of Operation*** The operation of structuring support device 10 according to embodiment 1 will be described with reference to Figures 2 to 8. The operating procedure of structuring support device 10 according to embodiment 1 corresponds to the structuring support method according to embodiment 1. Furthermore, the program that realizes the operation of structuring support device 10 according to embodiment 1 corresponds to the structuring support program according to embodiment 1.

[0018] The processing flow of the structuring support device 10 according to the first embodiment will be described with reference to FIG. 2 . (Step S11: Program Analysis Processing) The program analysis unit 21 analyzes the ladder program 30 to identify multiple similar program blocks 31 included in the ladder program 30. The program blocks 31 are partial programs that make up the ladder program 30. The ladder program 30 is configured using variables such as devices and labels. In FIG. 3 , the ladder program 30 is configured using five variables, Label1 to Label5. The program analysis unit 21 identifies multiple similar program blocks 31 from the ladder program 30 using a code clone detection technique or the like. Similar program blocks 31 refer to, for example, program blocks 31 that have the same structure but use different variables. Any method may be used as long as it can identify similar program blocks 31. In FIG. 3 , program block 31X and program block 31Y are identified as similar program blocks 31.

[0019] (Step S12: Variable Analysis Process) The variable analysis unit 22 analyzes the variables used in the multiple program blocks 31 identified in step S11. Specifically, the variable analysis unit 22 sets each of one or more variables used in the multiple program blocks 31 as a target variable. The variable analysis unit 22 identifies the usage location and usage situation for the target variable. There are three usage locations: input, output, and input / output. Input is a case where the target variable is used in an input instruction. Output is a case where the target variable is used in an output instruction. Input / output is a case where the target variable is used in an input instruction and an output instruction. There are three usage situations: (1) to (3). (1) is a case where the variable is used outside the multiple program blocks 31 in the ladder program 30. (2) is a case where the target variable is not used outside the multiple program blocks 31 in the ladder program 30 and is not used in common by the multiple program blocks 31. (3) is a case where the target variable is not used outside of multiple program blocks 31 in the ladder program 30 and is used in common by multiple program blocks 31.

[0020] As a result, each variable used in the ladder program 30 shown in Fig. 3 is analyzed as shown in Fig. 4. Labels 1 and 2 in Fig. 3 are used outside of multiple program blocks 31, so they are classified as (1). Labels 3 and 4 are not used outside of multiple program blocks 31. However, Label 3 is used only in program block 31X, and Label 4 is used only in program block 31Y, so they are classified as (2). Label 5 is not used outside of multiple program blocks 31, and is used in common by program blocks 31X and 31Y, so they are classified as (3).

[0021] (Step S13: Function Block Generation Process) The function block generation unit 23 determines the type of variables by referring to the analysis results obtained in step S12. Then, the function block generation unit 23 generates a function block 32 in which multiple program blocks are converted into functions based on the type of variables.

[0022] The process of determining the type of a variable will be described with reference to Figures 5 and 6. The function block generator 23 sets one or more variables used in multiple program blocks 31 as target variables. Then, the function block generator 23 executes the process shown in Figure 5 for the target variables.

[0023] (Step S121: External Use Determination Process) The function block generation unit 23 determines whether the target variable is used outside the multiple program blocks 31 in the ladder program 30. If the target variable is not used outside, the function block generation unit 23 proceeds to step S122. On the other hand, if the target variable is used outside, the function block generation unit 23 proceeds to step S123.

[0024] (Step S122: Common specification determination process) The function block generation unit 23 determines whether the target variable is commonly used in multiple program blocks 31. If the target variable is not commonly used, the function block generation unit 23 proceeds to step S123. On the other hand, if the target variable is commonly used, the function block generation unit 23 proceeds to step S127.

[0025] (Step S123: Command Determination Process) The function block generation unit 23 determines whether the target variable is used in an input command or an output command. If the target variable is used in an input command, the function block generation unit 23 proceeds to process step S124. If the target variable is used in an output command, the function block generation unit 23 proceeds to process step S125. If the target variable is used in both an input command and an output command, the function block generation unit 23 proceeds to process step S126.

[0026] (Step S124: First Determination Process) The function block generator 23 determines the type of the target variable to be an input variable.

[0027] (Step S125: Second Determination Process) The function block generator 23 determines the type of the target variable to be an output variable.

[0028] (Step S126: Third Determination Process) The function block generator 23 determines the type of the target variable to be an input / output variable.

[0029] (Step S127: Fourth Determination Process) The function block generator 23 determines the type of the target variable to be an internal variable. Therefore, Label1 becomes an input variable, Label2 becomes an output variable, Label3 and Label4 become input / output variables, and Label5 becomes an internal variable.

[0030] The process of generating a function block 32 will be described with reference to FIG. 7 . The function block generator 23 selects one program block 31 from among the multiple program blocks 31. The function block generator 23 assigns a variable name in the function block 32 to each variable in the selected program block 31, and assigns a determined type to each variable. Assume that program block 31X in FIG. 3 is selected. In this case, FBLabel1 is assigned as the name to Label1, and an input variable is assigned as the type. FBLabel2 is assigned as the name to Label2, and an output variable is assigned as the type. FBLabel3 is assigned as the name to Label3, and an input / output variable is assigned as the type. FBLabel4 is assigned as the name to Label5, and an internal variable is assigned as the type. This generates the function block 32. Assume that program block 31Y in FIG. 3 is selected. In this case, FBLabel1 is assigned as the name to Label1, and an input variable is assigned as the type. FBLabel2 is set as the name in Label2, and an output variable is set as the type. FBLabel3 is set as the name in Label4, and an input / output variable is set as the type. FBLabel4 is set as the name in Label5, and an internal variable is set as the type. This generates the same function block 32 as when program block 31X is selected.

[0031] (Step S14: Program Conversion Process) The program conversion unit 24 converts the ladder program 30 by replacing multiple program blocks 31 with the function blocks 32 generated in step S13. Any method for replacing the program blocks 31 with the function blocks 32 can be used as long as it ensures that the ladder program 30 is equivalent before and after the replacement. For example, for each program block 31 in the ladder program 30, the program conversion unit 24 replaces the remaining part with a function block 32 while leaving the external input instructions and the external output instructions. At this time, the program conversion unit 24 associates variables used in the remaining input instructions with corresponding variables in the function block 32.

[0032] In the case of the ladder program 30 shown in Fig. 3, program blocks 31X and 31Y are replaced with function blocks 32 as shown in Fig. 8. For program block 31X, only the input instructions of Label1 and 3, which are input instructions from outside, and the output instructions of Label2 and 3, which are output instructions to the outside, remain, and the remaining part is replaced with function blocks 32. The input instruction of Label1 is associated with FBLabel1, Label2 is associated with FBLabel2, and Label3 is associated with FBLabel3. For program block 31Y, only the input instructions of Label1 and 4, which are input instructions from outside, and the output instructions of Label2 and 4, which are output instructions to the outside, remain, and the remaining part is replaced with function blocks 32. An input command of Label1 is associated with FBLabel1, Label2 is associated with FBLabel2, and Label4 is associated with FBLabel3.

[0033] ***Effects of First Embodiment*** As described above, the structuring support device 10 according to the first embodiment determines the type of a target variable depending on whether the target variable satisfies the conditions that it is not used outside of multiple program blocks and is used in common across multiple program blocks. This makes it possible to appropriately determine the type of a variable and convert it into an appropriate variable. This makes it possible to reduce the amount of work required to structure a ladder program.

[0034] ***Other Configurations*** <Modification 1> In the first embodiment, each functional component is realized by software. However, in Modification 1, each functional component may be realized by hardware. The differences between Modification 1 and the first embodiment will be described below.

[0035] The configuration of the structuring support device 10 according to the first modification will be described with reference to Fig. 9. When each functional component is realized by hardware, the structuring support device 10 includes an electronic circuit 15 instead of the processor 11, memory 12, and storage 13. The electronic circuit 15 is a dedicated circuit for realizing the functions of each functional component, memory 12, and storage 13.

[0036] The electronic circuit 15 may be a single circuit, a composite circuit, a programmed processor, a parallel programmed processor, a logic IC, a GA, an ASIC, or an FPGA. GA stands for Gate Array. ASIC stands for Application Specific Integrated Circuit. FPGA stands for Field-Programmable Gate Array. Each functional component may be realized by a single electronic circuit 15, or each functional component may be distributed across multiple electronic circuits 15.

[0037] <Modification 2> As a modification 2, some of the functional components may be realized by hardware, and other functional components may be realized by software.

[0038] The processor 11, the memory 12, the storage 13, and the electronic circuit 15 are collectively referred to as a processing circuit. In other words, the functions of the respective functional components are realized by the processing circuit.

[0039] Second Embodiment The second embodiment differs from the first embodiment in that it does not generate a function block 32 that is the same as an existing function block 32. In the second embodiment, this difference will be explained, and the explanation of the same points will be omitted.

[0040] ***Description of Configuration*** The configuration of structuring support device 10 according to the second embodiment will be described with reference to Figure 10. Structuring support device 10 differs from structuring support device 10 shown in Figure 1 in that it includes a program comparison unit 25 as a functional component. The functions of program comparison unit 25 and storage unit 26 are realized by software or hardware, like the other functional components.

[0041] ***Explanation of Operation*** The operation of structuring support device 10 according to embodiment 2 will be described with reference to Figures 11 and 12. The operating procedure of structuring support device 10 according to embodiment 2 corresponds to the structuring support method according to embodiment 2. Furthermore, the program that realizes the operation of structuring support device 10 according to embodiment 2 corresponds to the structuring support program according to embodiment 2.

[0042] The flow of processing by the structuring support device 10 according to the second embodiment will be described with reference to Fig. 11. The processing from step S21 to step S22 is the same as the processing from step S11 to step S12 in Fig. 2.

[0043] (Step S23: Program Comparison Processing) The program comparison unit 25 compares the multiple program blocks 31 identified in step S21 with existing function blocks 32. The existing function blocks 32 include function blocks 32 previously generated by the function block generation unit 23 and function blocks 32 provided by device manufacturers, etc. The program comparison unit 25 determines whether there is an existing function block 32 with the same configuration as the multiple program blocks 31. The same configuration as the multiple program blocks 31 means that the existing function block 32 has the same structure as the multiple program blocks 31 and uses one or more variables of the same type as each of the variables used in the multiple program blocks 31. If there is no existing function block 32, the program comparison unit 25 proceeds to step S24. On the other hand, if there is an existing function block 32 with the same configuration, the program comparison unit 25 identifies the existing function block 32 and proceeds to step S25.

[0044] A specific example will be described with reference to FIG. 12. Here, it is assumed that a program block 31Z is identified as one of the multiple program blocks 31 in step S21. Also, it is assumed that an AND function exists as an existing function block 32. The program block 31Z outputs the logical product of two inputs. Therefore, the program block 31Z has the same structure as the AND function, and the types of each variable are the same. Therefore, in the example of FIG. 12, the program comparison unit 25 determines that an existing function block 32 with the same configuration exists, identifies the AND function, and then proceeds to step S25.

[0045] (Step S24: Function Block Generation Processing) The function block generation unit 23 generates the function block 32 in the same manner as in step S13 in Fig. 2. Then, the function block generation unit 23 writes the generated function block 32 into the storage 13 as an existing function block 32.

[0046] (Step S25: Program Conversion Process) The program conversion unit 24 converts the ladder program 30 by replacing the program block 31 with the existing function block 32 identified in step S23 or the function block 32 generated in step S24.

[0047] That is, if an existing function block 32 is identified in step S23, the function block generator 23 stops generating the function block 32 that converts a plurality of program blocks 31 into a common function.

[0048] ***Effects of the Second Embodiment*** As described above, the structuring support device 10 according to the second embodiment determines whether or not there is an existing function block 32 that has the same configuration as the program block 31 for which the function block 32 is to be generated. If there is an existing function block 32, the structuring support device 10 stops generating the function block 32. This prevents multiple equivalent function blocks 32 from being generated. As a result, the configuration of the converted ladder program 30 is prevented from becoming complicated, enabling efficient structuring to be achieved.

[0049] In addition, the word "unit" in the above description may be read as a "circuit," "step," "procedure," "process," or "processing circuit."

[0050] The embodiments and modifications of the present disclosure have been described above. Some of these embodiments and modifications may be combined and implemented. Furthermore, one or more of them may be implemented partially. Note that the present disclosure is not limited to the above embodiments and modifications, and various modifications are possible as needed.

[0051] 10 Structuring support device, 11 Processor, 12 Memory, 13 Storage, 14 Communication interface, 21 Program analysis unit, 22 Variable analysis unit, 23 Function block generation unit, 24 Program conversion unit, 25 Program comparison unit, 30 Ladder program, 31 Program block, 32 Function block.

Claims

1. A structuring support device comprising: a program analysis unit which identifies a plurality of similar program blocks included in a ladder program; and a function block generation unit which, for each of one or more variables used in the plurality of program blocks identified by the program analysis unit, determines the type of the target variable depending on whether or not the target variable satisfies the conditions that the target variable is not used outside the plurality of program blocks in the ladder program and is commonly used in the plurality of program blocks, and generates function blocks that turn the plurality of program blocks into functions.

2. The structuring support device according to claim 1, wherein the function block generation unit, if the condition is satisfied, sets the type of the target variable to an internal variable, and if the condition is not satisfied, determines the type of the target variable depending on whether the target variable is used in an input command or an output command.

3. The structuring support device of claim 2, wherein the function block generation unit, when the condition is not satisfied, sets the type of the target variable to an input variable if the target variable is used in an input instruction and not used in an output instruction, sets the type of the target variable to an output variable if the target variable is used in an output instruction and not used in an input instruction, and sets the type of the target variable to an input / output variable if the target variable is used in both an input instruction and an output instruction.

4. The structuring support device according to any one of claims 1 to 3, further comprising: a program conversion unit that converts the ladder program by replacing the plurality of program blocks with the function blocks generated by the function block generation unit.

5. The structuring support device according to any one of claims 1 to 4, further comprising a program comparison unit that identifies an existing function block that has the same structure as the plurality of program blocks and uses variables of the same type as each of one or more variables used in the plurality of program blocks, and the function block generation unit stops generating a function block that converts the plurality of program blocks into a common function when an existing function block is identified by the program comparison unit.

6. The structuring support device according to any one of claims 1 to 5, wherein the plurality of program blocks are program blocks having the same structure but using different variables.

7. A structuring support method in which a computer identifies a plurality of similar program blocks included in a ladder program, and determines the type of one or more variables used in the plurality of program blocks as target variables depending on whether the target variables are not used outside the plurality of program blocks in the ladder program and are commonly used in the plurality of program blocks, and generates function blocks by turning the plurality of program blocks into functions.

8. A structuring support program that causes a computer to function as a structuring support device that performs a program analysis process that identifies multiple similar program blocks included in a ladder program, and a function block generation process that determines the type of one or more variables used in the multiple program blocks identified by the program analysis process as target variables depending on whether or not the target variables are not used outside the multiple program blocks in the ladder program and are commonly used in the multiple program blocks, and generates function blocks that turn the multiple program blocks into functions.

Citation Information

Patent Citations

  • Program development support apparatus for PLC

    JP2008033913A

  • PLC system, development support device for the same, and program

    JP2012118715A

  • Programmable logic controller and main unit

    JP2020013526A

  • Program creation assistance device, program creation assistance method, and program creation assistance program

    WO2020178983A1

  • Program development device, and program for implementing program development device

    WO2021065033A1