Program creation assistance device and computer program

The program creation support device facilitates the use of LLMs to generate ladder programs by converting natural language prompts into ladder diagrams, addressing the scarcity of ladder language experts and improving PLC programming efficiency.

WO2025142359A1PCT designated stage expired Publication Date: 2025-07-03KEYENCE CORP

Patent Information

Application Number
PCT/JP2024/042872
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-12-25
Filing Date
2024-12-04
Publication Date
2025-07-03

AI Technical Summary

Technical Problem

There is a lack of programmers familiar with the ladder language used in programmable logic controllers (PLCs), making it difficult for users to create control programs, and large language models (LLMs) cannot effectively generate ladder programs due to the scarcity of publicly available ladder program data on the Internet.

Method used

A program creation support device that utilizes an LLM interface to convert natural language prompts into ladder diagrams by adding specific information to restrict the text code, enabling users to create ladder programs more efficiently.

Benefits of technology

Users can leverage LLMs to assist in creating ladder programs, reducing the workload and enhancing the usability of programmable logic controllers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure JP2024042872_03072025_PF_FP_ABST
    Figure JP2024042872_03072025_PF_FP_ABST
Patent Text Reader

Abstract

[Problem] To enable a user who creates a control program used in a programmable logic controller to enjoy the benefit of an LLM. [Solution] First information pertaining to an input / output apparatus connected to a PLC, second information pertaining to at least one of a command or a program module for controlling the input / output apparatus, and third information indicating control content implemented in combination with the command or the program module are received in a natural language. On the basis of same, a natural language prompt for generating a text code corresponding to a ladder diagram is generated. The prompt is transmitted to the LLM and an answer sentence is received from the LLM. A text code included in the answer sentence is converted into a ladder diagram. In addition, the prompt includes fourth information that constrains the text code included in the answer sentence to be suitable for the conversion into the ladder diagram.
Need to check novelty before this filing date? Find Prior Art

Description

Program creation support device and computer program.

[0001] The present invention relates to a program creation support device and a computer program.

[0002] A programmable logic controller (PLC) calculates control signals based on a control program (ladder program) created by the user using a ladder diagram (ladder language) and signals input from sensors, etc., and outputs control signals to connected actuators, motors, etc. Ladder language is a programming language intended for use in PLCs and is not used in general-purpose computers. As a result, there is an issue of there being few programmers skilled in ladder language. If programming using ladder language could be assisted, the burden on users attempting to create ladder programs would be reduced.

[0003] Patent Document 1 describes a device that automatically generates control code to control the operation of each process when a user creates a control program for an HMI (human-machine interface), which is a display device for a PLC, by placing the components of each process in the desired position on a GUI (graphical user interface).

[0004] U.S. Patent No. 7,324,856

[0005] Meanwhile, large-scale language models known as LLMs (Large Language Models) are becoming increasingly popular. LLMs are models that output more plausible answers to natural language inputs through machine learning of massive amounts of text data. Data used for machine learning is collected from the Internet, etc. Therefore, LLMs are good at generating program code written in general-purpose programming languages ​​(e.g., Python, Java, C++, JavaScript, and C#) that are easily collected via the Internet through machine learning of source code written in such languages.

[0006] If ladder programs used in PLCs could also be generated using an LLM, the workload on users would be reduced. However, because few ladder programs are publicly available on the Internet, LLMs have not been able to fully learn ladder programs. In particular, there were no LLMs that could take natural language input and output ladder programs. As a result, users who wanted to create ladder programs could not take advantage of the benefits of an LLM.

[0007] Therefore, an object of the present invention is to enable users who create control programs, such as ladder programs, used in programmable logic controllers to enjoy the benefits of LLM.

[0008] The present invention provides, for example, a program creation support device that supports the creation of a control program to be used in a programmable logic controller, comprising: an information receiving unit that receives, in natural language, first information regarding input / output devices connected to the programmable logic controller, second information regarding at least one of instructions or program modules for controlling the input / output devices, and third information indicating control content to be realized in combination with the instructions or program modules; a prompt generation unit that generates a natural language prompt for generating text code corresponding to a ladder diagram based on the first information, the second information, and the third information received by the information receiving unit; an LLM interface that sends the prompt generated by the prompt generation unit to a large scale language model (LLM) and receives an answer sentence corresponding to the prompt from the large scale language model; and a conversion unit that converts the text code included in the answer sentence received via the LLM interface into a ladder diagram, wherein the prompt generation unit adds fourth information to the prompt that constrains the text code included in the answer sentence so that it is suitable for conversion into the ladder diagram by the conversion unit.

[0009] According to the present invention, it is possible to enable users who create control programs, such as ladder programs, used in programmable logic controllers to enjoy the benefits of LLM.

[0010] Diagram explaining a PLC system Diagram explaining a setting support device (program creation support device) Diagram explaining a basic unit Diagram explaining functions implemented in the setting software Sequence diagram showing the steps to create and transfer a user program Flowchart showing the steps to create a ladder program Flowchart showing the steps to create a ladder program Flowchart showing the steps to correct an error Sequence diagram showing the steps to create and transfer a user program Diagram explaining a generated ladder diagram Diagram explaining a generated function block Diagram explaining a generated ladder diagram

[0011] Hereinafter, the embodiments will be described in detail with reference to the accompanying drawings. Note that the following embodiments do not limit the scope of the invention as claimed, and not all combinations of features described in the embodiments are necessarily essential to the invention. Two or more of the features described in the embodiments may be arbitrarily combined. Furthermore, the same reference numerals are used for the same or similar components, and redundant explanations will be omitted.

[0012] <PLC System> Figure 1 shows an example configuration of a programmable logic controller system (hereinafter referred to as PLC system 1) according to an embodiment of the present invention. As shown in Figure 1, this PLC system 1 includes a PC, which is a setting support device for editing user programs such as ladder programs, a basic unit 3, which is a PLC (Programmable Logic Controller) for comprehensively controlling various control devices installed in a factory or the like, and multiple motor drivers 4a-4c. The multiple motor drivers 4a-4c drive motors 10a, 10b, and 10c, respectively. The motor drivers 4a-4c may also be referred to as motor amplifiers or motion units. The motors 10a, 10b, and 10c drive loads, which are the objects of control.

[0013] The user program created by PC2, which is a setting support device, may be created using a graphical programming language such as ladder language, a flow chart format motion program, or structured text (ST) language, or may be created using a high-level programming language such as C language.

[0014] In the PLC system 1, one or more expansion units (e.g., an I / O unit, an analog input unit, an analog output unit, a communication unit, motor drivers 4a to 4c, etc.) are connected to the basic unit 3. The basic unit 3 is sometimes called a CPU unit.

[0015] The basic unit 3 has a display unit 5 and an operation unit 6. The display unit 5 can display the operating status of the motor drivers 4a to 4c. The display unit 5 may switch the display content depending on the operation of the operation unit 6. The display unit 5 typically displays the current values ​​(device values) of devices in the PLC system 1 and error information (presence or absence of alarms or warnings) that has occurred within the PLC system 1. A device is a memory area provided for storing device values ​​(device data) and is sometimes called a data memory or device memory. Device values ​​are information indicating the input status from input devices, the output status to output devices, and the status of internal relays (auxiliary relays), timers, counters, data memories, etc. set in a user program. Device values ​​are classified into bit and word types. A bit device stores a 1-bit device value. A word device stores a 1-word device value.

[0016] The motor drivers 4a to 4c are provided to expand the functions of the PLC system 1. The motors 10a to 10c are controlled by the motor drivers 4a to 4c, respectively. The motor drivers 4a to 4c supply power to the motors 10a to 10c and control the amount of rotation and the like in accordance with commands from the basic unit 3. The motors 10a to 10c are, for example, servo motors or stepping motors.

[0017] The PC 2 is a computer that provides a development environment for the PLC system 1. The PC 2 is, for example, a portable notebook or tablet personal computer and includes a display unit 7 and an operation unit 8. A ladder program, which is an example of a user program for controlling the PLC system 1, is created using the PC 2. The created ladder program is converted into mnemonic code within the PC 2. The PC 2 is connected to the basic unit 3 of the PLC system 1 via a communication cable 9a such as a universal serial bus (USB) and sends the ladder program converted into mnemonic code to the basic unit 3. The basic unit 3 converts the ladder program into machine code and stores it in a memory provided in the basic unit 3. Note that, although the mnemonic code is transmitted to the basic unit 3 in this example, the present invention is not limited to this. For example, the PC 2 may convert the mnemonic code into intermediate code and transmit the intermediate code to the basic unit 3.

[0018] 1, the operation unit 8 of the PC 2 may include a pointing device such as a mouse connected to the PC 2. The PC 2 may also be configured to be detachably connected to the basic unit 3 via a communication cable 9a other than USB. The PC 2 may also be connected wirelessly to the basic unit 3 without using the communication cable 9a. In this case, the communication cable 9a may be understood to represent a wireless link.

[0019] The basic unit 3 and motor driver 4a are connected by a communication cable 9b and can communicate with each other via the communication cable 9b. The motor drivers 4a and 4b are connected by a communication cable 9c and can communicate with each other via the communication cable 9c. The motor driver 4b can communicate with the basic unit 3 via the communication cables 9b and 9c. The motor drivers 4b and 4c are connected by a communication cable 9d and can communicate with each other via the communication cable 9d. Furthermore, the motor driver 4c can communicate with the basic unit 3 via the communication cables 9b, 9c, and 9d.

[0020] In the following, when common matters are described for the motor drivers 4a to 4c, they will be referred to as the motor driver 4. Similarly, when common matters are described for the motors 10a to 10c, they will be referred to as the motor 10.

[0021] The LLM server 100 is, for example, a server computer or service connected to the Internet. The PC 2 accesses the LLM server 100 via the Internet, sends prompts, and receives responses (answer sentences) to the prompts. The LLM server 100 has machine-learned numerous source codes written in general-purpose programming languages ​​such as Python, Java, C++, JavaScript, and C#. For example, when the PC 2 sends a prompt to the LLM server 100 specifying content to be implemented by a desired program written in C, the LLM server 100 receives a response sentence, which is a desired program written in C that implements the content specified by the prompt. The LLM server 100 may also be implemented inside the PC 2.

[0022] <Setting Support Device> Figure 2 is a block diagram illustrating the electrical configuration of a PC 2 that operates as a setting support device. As shown in Figure 2, the PC 2 includes a CPU 11, a display unit 7, an operation unit 8, a storage device 12, and a communication unit 13. The display unit 7, operation unit 8, storage device 12, and communication unit 13 are each electrically connected to the CPU 11. The storage device 12 includes RAM, ROM, HDD, and SSD, and may also include a removable memory card. CPU is an abbreviation for central processing unit. ROM is an abbreviation for read-only memory. RAM is an abbreviation for random access memory. HDD is an abbreviation for hard disk drive. SSD is an abbreviation for solid state drive.

[0023] A user of the PC 2 causes the CPU 11 to execute the setting software 21 stored in the storage device 12, edits the user program 22 via the operation unit 8, and transmits the user program 22 to the basic unit 3. The setting software 21 also has a module that sends prompts to the LLM server 100 and receives responses from the LLM server 100 to assist in creating the user program 22. Details of this will be described later. The PC 2 may also be called an engineering tool. The user program 22 is a ladder program, a motion program, or the like.

[0024] The PLC system configuration information 23 includes information indicating the connection positions of the multiple motor drivers 4 relative to the basic unit 3, information indicating the functions (e.g., communication function and positioning function) provided in the basic unit 3, information indicating the functions of the motor drivers 4, and device allocation information. The user program 22 and the PLC system configuration information 23 are part of the project data. Here, editing the project data includes creating and changing (re-editing) the project data. The user reads out the project data stored in the storage device 12 as needed and changes the project data using the setting software 21.

[0025] Symbol definitions 24 are definitions of various symbols (e.g., variables, devices) used in the PLC system 1. Templates 25 are existing text information used in creating prompts to be sent to the LLM server 100.

[0026] The communication unit 13 communicates with the basic unit 3 via the communication cable 9a. The CPU 11 transfers project data (such as the user program 22 and configuration information 23) to the basic unit 3 via the communication unit 13. The communication unit 13 includes a communication circuit capable of performing communication compliant with the USB standard, a communication circuit for performing wired LAN communication, and a communication circuit for performing wireless LAN communication.

[0027] The communication unit 13 communicates with the LLM server 100 via a communication cable and the Internet. The communication protocol between the PC 2 and the basic unit 3 may be a general-purpose protocol or a unique protocol.

[0028] <Basic Unit> Fig. 3 shows the hardware configuration of the basic unit 3. The CPU 31 writes information to the memory 32 and reads information from the memory 32. The memory 32 includes RAM, ROM, HDD, and SSD, and may also include a removable memory card. The project storage unit 35 is a ROM area that stores project data created and transferred by the PC 2. The project data includes the user program 22 and configuration information 23. Furthermore, the CPU 31 accepts information input from the operation unit 6. The CPU 31 displays various information on the display unit 5.

[0029] The CPU 31 is connected to the PC 2 via a communication unit 33a, and is also connected to the motor driver 4 via a communication unit 33b to perform communication. The communication unit 33a is, for example, a communication circuit compatible with USB. The communication unit 33b is a communication circuit capable of executing communication compatible with industrial Ethernet protocols (e.g., EtherCAT, EtherNet / IP, PROFINET, MECHATROLINK-III).

[0030] The program execution unit 36 ​​is a calculation processing circuit that executes the user program 22. The program execution unit 36 ​​may be implemented in a CPU different from the CPU 31. The motion control unit 34 controls the motor driver 4 in cooperation with the program execution unit 36.

[0031] <Editing a User Program> Figure 4 shows some of the various functions realized by the CPU 11 executing the setting software 21. The information receiving unit 41 displays a user interface of the setting software 21 to the user on the display unit 7. Furthermore, the information receiving unit 41 receives various information and instructions input by the user through the operation unit 8. For example, such information is input in a natural language that humans can understand. The input information may include, for example, first information about an input / output device (e.g., the motor driver 4) connected to the basic unit 3, second information about at least one of an instruction or a program module for controlling the input / output device, and third information indicating the control content realized in combination with the instruction or the program module.

[0032] The first information may include role information indicating the role of each of the multiple input devices connected to the basic unit 3. The role information included in the first information may be reflected in variable names or comments in the ladder diagram.

[0033] The second information may include definition information that defines the input and output of a program module that constitutes a part of the user program 22. In this case, the language conversion unit 44 may convert the text code included in the response statement received from the LLM server 100 into a ladder diagram that includes calling the program module.

[0034] The prompt generation unit 42 generates a natural language prompt to have the LLM server 100 generate a text code corresponding to the ladder diagram based on the first information, second information, and third information received by the information receiving unit 41.

[0035] The LLM interface 43 controls the communication unit 13 to transmit the prompt generated by the prompt generation unit 42 to the LLM server 100. The LLM interface 43 also controls the communication unit 13 to receive a response sentence corresponding to the prompt from the LLM server 100.

[0036] The language conversion unit 44 converts the text code contained in the response sentence received via the LLM interface 43 into a ladder diagram or a motion flow.

[0037] The prompt generation unit 42 generates a prompt that allows the user to obtain the ladder diagram or motion flow desired. In order for the LLM server 100 to generate an appropriate response sentence, the prompt may require fourth information that constrains the response sentence. For example, when a text code included in the response sentence is input to the language conversion unit 44, the language conversion unit 44 must be able to convert the text code into the ladder diagram desired by the user. Therefore, the fourth information constrains the response sentence, allowing the LLM server 100 to generate an appropriate response sentence. In this way, the prompt generation unit 42 may generate fourth information that constrains the text code included in the response sentence so that it is suitable for conversion into a ladder diagram by the language conversion unit 44, and add the fourth information to the prompt.

[0038] The fourth information may be a template of text code in a general-purpose programming language included in the template 25. The fourth information may be a candidate instruction set consisting of a plurality of instructions. The fourth information may include constraint information that constrains the text code to call a program module from a ladder diagram. The program module included in the user program 22 may be a program module that executes access to a specified file. In this case, the constraint information may include path information required to access the specified file. The program module may be a program module that executes access to a specified database. In this case, the constraint information includes information required to access the specified database. The program module may be a program module that executes access to a specified FTP server. In this case, the constraint information includes address information required to access the specified FTP server.

[0039] The PLC system 1 may include a motion unit such as a motor driver 4. In this case, the fourth information may include a point parameter indicating the movement coordinate of the controlled object in the motion unit.

[0040] The fourth information may also include information specifying a logical operation to be performed in the ladder diagram, information specifying a timer referenced in the ladder diagram, information specifying a counter referenced in the ladder diagram, or information specifying a special relay referenced from the ladder diagram.

[0041] The fourth information may be described by a metalanguage used to define the context-free grammar.

[0042] The library conversion unit 47 may convert each of multiple program components (e.g., function blocks, functions, etc.) usable in a ladder program based on a ladder diagram into library functions written in a general-purpose programming language. In this case, the fourth information may include multiple library functions converted by the library conversion unit 47. The program components may include not only existing components prepared in advance in the development environment (i.e., prepared by the PLC manufacturer) but also components prepared by the user. Components prepared in the development environment include, for example, instructions (e.g., FMOV commands), built-in function blocks (e.g., timer function blocks), built-in functions, and device maps (information indicating device allocation). Components prepared by the user include, for example, user function blocks, user functions, communication settings (Ethernet / IP communication, PROFINET communication, FTP communication), and motion settings (axis configuration, point parameters, G-code, and periodic control information). Generally, these components for ladder programs are not learned by the LLM server 100. Therefore, the library conversion unit 47 may convert these component groups into a library in a general-purpose programming language.

[0043] The fourth information may include constraint information that restricts the text code to be written using only bit operations and arithmetic operations. Bit operations in the general-purpose language can be converted into contacts in the ladder program. Arithmetic operations in the general-purpose language can be converted into operation instructions in the ladder program. Library functions in the general-purpose language can be converted into component groups in the ladder program.

[0044] The fourth information may include constraint information indicating that the specification of the ladder program using the ladder diagram is constrained by a language expression format. For example, the language expression format may be Extended Backus-Naur Form (EBNF).

[0045] The first text code included in the first answer sentence received from the LLM server 100 by the LLM interface 43 may contain insufficient information. In this case, the language conversion unit 44 fails to convert the ladder diagram of the first text code. Therefore, the message output unit 45 may output a message to the display unit 7 prompting the user to enter the missing information. The prompt generation unit 42 may generate a prompt including the additional information entered by the user. The LLM interface 43 may transmit the prompt generated by the prompt generation unit 42 to the LLM server 100 and receive a second answer sentence corresponding to the prompt from the LLM server 100.

[0046] The language conversion unit 44 converts the second text code contained in the second response sentence received via the LLM interface 43 into a ladder diagram. A ladder language is not a language written only in text, but is a language written in graphs. Therefore, it is difficult to directly convert text code written in a general-purpose language into a ladder diagram. On the other hand, the ladder diagram is converted into a mnemonic and transferred to the basic unit 3, where it is converted into machine code. The mnemonic is written in text. Therefore, the language conversion unit 44 converts the text code written in the general-purpose language into a mnemonic and then converts the mnemonic into a ladder diagram. In this way, using a mnemonic makes it easy to convert text code written in a general-purpose language into a ladder diagram.

[0047] The error detection unit 46 detects program errors in ladder diagrams or text code. The prompt generation unit 42 may create a prompt to request a correction suggestion from the LLM server 100 to resolve the program error. The LLM interface 43 may send the prompt to the LLM server 100 and receive a correction suggestion corresponding to the prompt from the LLM server 100. The user may correct the user program 22 in accordance with the correction suggestion. Alternatively, the correction suggestion may be a response statement including text code corrected to prevent the error from occurring. In this case, the language conversion unit 44 converts the text code included in the response statement received via the LLM interface 43 into a ladder diagram.

[0048] However, it is sometimes difficult to uniquely determine a graph representation (ladder diagram) that can be converted from a mnemonic. Therefore, the fourth information may include constraints imposed by the Extended Backus-Naur Form (EBNF) on the ladder program specifications based on the ladder diagram. This will ensure that a graph representation (ladder diagram) that can be converted from a mnemonic is uniquely determined. In this way, these constraints are a grammar definition format that ensures that the LLM server 100 generates a mnemonic that can be converted into a ladder diagram.

[0049] <Sequence> FIG. 5 shows a series of steps from creating the user program 22 to transferring it.

[0050] In S1, the PC 2, which is a setting support device, creates a prompt based on information input by the user (e.g., processing details realized by the user program 22, symbol definitions 24 for input devices and output devices, configuration information 23 for the PLC system 1, library functions converted into a general-purpose language, etc.), and sends the prompt to the LLM server 100. The LLM server 100 receives the prompt from the PC 2.

[0051] In S2, the LLM server 100 creates a program in a general-purpose language (e.g., text code such as mnemonics) in response to the prompt and sends a response statement including the program to the PC 2. The PC 2 receives the response statement from the LLM server 100.

[0052] The sending and receiving of the prompt in S3 and the sending and receiving of the answer in S4 are optional because the sending and receiving of the prompt and answer may take more than two round trips. The more complex the user program 22, the more frequently the prompt and answer will be sent and received. For example, the CPU 11 may divide the processing content of the user program 22 into multiple parts, send and receive prompts and answer sentences for each part, and then combine the parts to complete the user program 22. There may be cases where the text code included in the answer sentence cannot be converted into a ladder diagram. In such cases, the CPU 11 may create and send a prompt to fill in the missing information and receive the answer sentence. At this time, the CPU 11 may create and send a prompt to request the LLM server 100 to create a message (inquiry) to prompt the user to fill in the information. The PC 2 may display the message included in the corresponding answer sentence on the display unit 7 to prompt the user to enter additional information. Alternatively, the CPU 11 may detect an error in the user program 22, create a prompt including an error message and a text code, and request the LLM server 100 to correct the text code to resolve the error, and receive a suggested correction from the LLM server 100. The error may be detected by a debugger function (an example of the error detection unit 46) included in the configuration software 21. The error detection unit 46 may run a simulation on the user program 22 to search for bugs not detected by the debugger. In this manner, steps S1 to S4 may be repeated several times as necessary. The CPU 11 may also allow the user to manually edit the user program 22 by operating the operation unit 8 between steps S1 and S4 or after step S4.

[0053] In S5, the PC 2 transfers the completed user program 22 to the PLC (the basic unit 3 and the motor driver 4). The program execution unit 36 ​​of the basic unit 3 executes the user program 22.

[0054] <Flowchart> (1) Basic Processing Fig. 6 shows a method for creating a user program 22 that is executed by the CPU 11 in accordance with the setting software 21. As an example of the user program 22, a ladder program is used.

[0055] In S601, the CPU 11 (information receiving unit 41) receives the processing content of the ladder program. The user inputs the processing content of the ladder program by operating the operation unit 8. At this time, the display unit 7 may display a user interface including a dialog box prompting the user to input the processing content.

[0056] In S602, the CPU 11 (information receiving unit 41) acquires configuration information of the input / output devices connected to the PLC. The setting software 21 creates configuration information 23 based on user input, which indicates the model codes of the basic units 3 that will constitute the PLC system 1, the model codes and connection positions of the input / output devices (e.g., I / O unit, analog input unit, analog output unit, communication unit, motor drivers 4a to 4c) connected to the basic units 3, etc. Therefore, the CPU 11 may read the configuration information 23 from the storage device 12.

[0057] In S603, the CPU 11 (information receiving unit 41) receives designations of instructions in the ladder language (e.g., FMOV instructions) and program component groups (e.g., function blocks pasted on the ladder diagram) to be used in the ladder program. The user inputs these designations by operating the operation unit 8. At this time, the display unit 7 may display a user interface including a dialog box prompting the user to input the designations.

[0058] In S604, the CPU 11 (library conversion unit 47) converts the specified command and component group into a general-purpose language. As will be described later, the library conversion unit 47 may access an external database (DB) to acquire a command in a general-purpose language that corresponds to a command in a ladder language. The library conversion unit 47 may access an external database (DB) to acquire a component group (e.g., library functions) in a general-purpose language that corresponds to a component group (e.g., function blocks) in a ladder language.

[0059] In S605, the CPU 11 (information receiving unit 41) receives input of constraint conditions (the above-described fourth information). The user inputs the constraint conditions by operating the operation unit 8. At this time, the display unit 7 may display a user interface including a dialog box prompting the user to input the constraint conditions.

[0060] In S606, the CPU 11 (prompt generation unit 42) creates a prompt to request the LLM server 100 to create a program in a general-purpose language that will be the basis for the ladder program. This prompt includes the processing content of the ladder program, configuration information 23, converted commands and component groups, and constraints. Note that if the processing content of the ladder program is simple, it may not be necessary to include constraints.

[0061] In S607 , the CPU 11 (LLM interface 43 ) transmits the prompt generated by the prompt generating unit 42 to the LLM server 100 .

[0062] In S608, the CPU 11 (LLM interface 43) receives a reply sentence that is a response to the prompt from the LLM server 100.

[0063] In S609, the CPU 11 (language conversion unit 44) extracts a text code from the answer sentence and converts the text code into a ladder diagram. The CPU 11 may display the ladder diagram on the display unit 7 and edit the ladder diagram by accepting editing instructions from the user, such as minor corrections to the ladder diagram.

[0064] (2) Detailed Processing Figure 7 shows a method for creating a user program 22 that the CPU 11 executes in accordance with the setting software 21. Among the steps shown in Figure 7, steps that have already been described in Figure 6 are given the same reference numerals, and their description will be omitted. Here, the process for creating a ladder program is divided into two stages. The first stage is a stage for creating a program in a general-purpose language. The second stage is a stage for creating a mnemonic from the program in the general-purpose language. As described above, it is difficult to directly convert a program in a general-purpose language (text code) into a ladder diagram. Therefore, the program in the general-purpose language (text code) is converted into a mnemonic, and the mnemonic is converted into a ladder diagram.

[0065] When a prompt requesting a program in a general-purpose language is sent to the LLM server 100 in S607, the CPU 11 proceeds from S607 to S701.

[0066] In S701, the CPU 11 (LLM interface 43) receives a response sentence including a program (text code) in a general-purpose language from the LLM server 100.

[0067] In S702, the CPU 11 (information receiving unit 41) optionally receives input of constraints. For example, the constraints may include a condition that the ladder program specification based on the ladder diagram should be in Extended Backus-Naur Form (EBNF). As described above, this constraint will be valid if the mnemonic cannot be uniquely converted to a ladder diagram.

[0068] In S703, the CPU 11 (prompt generating unit 42) generates a prompt that includes a program in a general-purpose language and constraints (options) and requests the generation of a mnemonic.

[0069] In S704, the CPU 11 (LLM interface 43) transmits the prompt generated by the prompt generating unit 42 to the LLM server 100.

[0070] In S705, the CPU 11 (LLM interface 43) receives a response to the prompt from the LLM server 100. The response includes a mnemonic.

[0071] In S706, the CPU 11 (language conversion unit 44) extracts a mnemonic from the response sentence and converts the mnemonic into a ladder diagram.

[0072] (3) Error Resolution Method Fig. 8 shows an error resolution method for the user program 22 executed by the CPU 11 in accordance with the configuration software 21. The error resolution method may be performed on a program written in a general-purpose language or on a mnemonic. As an example, it is assumed that detection is performed on a generated program written in a general-purpose language.

[0073] In S801, the CPU 11 (error detection unit 46) checks for errors in the general-purpose language program created by the LLM server 100. Here, errors that may prevent the general-purpose language program from being compiled, such as syntax errors, may be checked.

[0074] In S802, the CPU 11 (error detection unit 46) determines whether or not there is an error in the general-purpose language program based on the results of the error check. If there is no error in the general-purpose language program, the CPU 11 terminates the error resolution method shown in Figure 8. If there is an error in the general-purpose language program, the CPU 11 proceeds from S802 to S803.

[0075] In S803, the CPU 11 (error detection unit 46) determines whether there is missing information to be provided to the LLM server 100. For example, the error detection unit 46 may determine whether there is missing information based on a message from the LLM server 100 included in the response text or the results of an error check. If there is missing information, the CPU 11 proceeds from S803 to S804. If there is no missing information, that is, if the error is due to another cause, the CPU 11 proceeds from S803 to S810.

[0076] In S804, the CPU 11 (message output unit 45) outputs a message to the display unit 7 requesting the user to add additional information. This message may include an explanatory text explaining what additional information is needed. This explanatory text may include, for example, information indicating the nature of the error. The message output unit 45 may send a prompt to the LLM server 100 requesting the user to create such an inquiry message and receive the inquiry message as a reply.

[0077] In S805 , the CPU 11 (information receiving unit 41 ) receives supplement information input by the user via the operation unit 8 .

[0078] In S806, the CPU 11 (prompt generating unit 42) generates a prompt for requesting correction of the error in the general-purpose language program based on the supplementary information.

[0079] In S807, the CPU 11 (LLM interface 43) transmits the created prompt to the LLM server 100.

[0080] In S808, the CPU 11 (LLM interface 43) receives the response sentence (including the modified general-purpose language program) from the LLM server 100.

[0081] In S809, the CPU 11 (language conversion unit 44) converts the text code extracted from the response sentence, that is, the corrected program in the general-purpose language, into a ladder diagram.

[0082] As described above, if there is no missing information, the CPU 11 proceeds to S810. In S810, the CPU 11 (prompt generation unit 42) creates a prompt to request the LLM server 100 to suggest modifications to the general-purpose language program, and then proceeds to S807.

[0083] <Other Sequences> Figure 9 shows a modified example of the sequence shown in Figure 5. In Figure 9, the same reference numerals are used to denote steps already described in relation to Figure 5. In this example, steps S11 to S14 are added before step S1. DB 150 is a computer that provides database services. DB 150 may be connected to PC 2 via the Internet, for example. CPU 11 can communicate with DB 150 via communication unit 13. Because DB 150 needs to comprehensively store information about PLC system 1, it may be operated by the vendor that manufactures PLC system 1.

[0084] In S11, the PC 2 sends a prompt to the LLM server 100 requesting that the LLM server 100 perform an element analysis of the process content of a general-purpose language program or mnemonic input by the user through the operation unit 8. The LLM server 100 receives this prompt and performs element analysis based on the prompt. This breaks down a sentence written in natural language into multiple elements. For example, assume that the process content is "I want to rotate axis 1 180 degrees clockwise." In this case, the result of the element analysis is "axis 1, clockwise, rotate 180 degrees."

[0085] In S12, the LLM server 100 creates a response sentence including the result of the element analysis and transmits the response sentence to the PC 2. The PC 2 receives the response sentence from the LLM server 100.

[0086] In S13, PC2 extracts multiple elements from the response sentence, creates a DB query requesting related information for the multiple elements, and sends the DB query to DB150. The DB query includes, for example, "axis 1, clockwise, rotate 180 degrees," which is the result of the element analysis. When DB150 receives the DB query from PC2, it searches the database to obtain related information. For example, if the DB query includes "axis 1, clockwise, rotate 180 degrees," a search for related information is performed for each element. As a result, "point parameter 1: rotate 180 degrees clockwise, axis setting information for axis 1, etc." is obtained as related information.

[0087] In S14, PC2 receives the answer sentence including the related information from DB150. Then, PC2 creates a prompt including the related information and transmits the prompt to LLM server 100. In this way, by using DB150, the amount of information that the user must input is reduced. In other words, the burden on the user will be reduced.

[0088] If the setting software 21 has a function for analyzing elements of text written in a natural language, steps S11 and S12 are unnecessary.

[0089] <Specific Examples> Below, examples of ladder programs, prompts, and response sentences are described.

[0090] (Case i) Example of creating a ladder program to control a motion unit (1) Prompts Prompts include, for example, the following text: "You will be given the following four pieces of information.

[0091] First information about the input / output devices connected to the programmable logic controller; Second information about at least one of the commands or program modules used in the control program; Third information indicating the contents of the control program; Fourth information to match the text code included in the answer to the ladder diagram. Please answer step by step, considering the third information and following the first, second, and fourth information." (1-1) First Information The first information may include unit configuration information for expansion units such as the basic unit 3 and motor driver 4. As an example, the configuration information for a motion unit is shown. ● Leading relay number: R34000 ● Leading DM number: DM10300 ● Axis 1 positioning control start relay: R34200 ● Axis 1 positioning control start completion relay: R40800 ● Axis 1 positioning completion relay: R40802 ● Axis 1 positioning completion clear relay: R34202 ● Axis 1 positioning start point number: #2100 ● Axis 1 positioning control start completion code: #4050 The following information may be given as axis information for this unit. ●Product series: SV2 ●Axis number: 1 ●Axis comment: None ●Station address: 42 ●Extended address: 0 ●Point parameters: No. 1 90° clockwise No. 2 90° counterclockwise No. 3 180° clockwise No. 4 180° counterclockwise (1-2) Second information An example of the second information is as follows: ●Scan should be expressed with while(true). ●Do not define local variables within the scan (inside the while statement). In that case, do not use any functions other than the API below. Do not use printf either.●Getting the current time: extern void GetTime(time_t& time); ●Size comparison: extern bool GT(int a, int b); ●Equals comparison: extern bool EQ(int a, int b); ●Status determination: extern bool LD(int value); ●Status determination (inverse logic): extern bool LDB(int value); ●Reflecting the previous determination: extern bool OUT(int value); ●Counting up: extern void INC(int& value); ●Assigning a value: extern void MOV(int from, int& to); ●AND condition determination: extern bool AND(bool a, bool b); ●OR condition determination: extern bool OR(bool a, bool b); ●Always executing: extern bool alwaysOn; (1-3) Third information An example of third information is, "I want to rotate axis 1 180 degrees clockwise."

[0092] (1-4) Fourth information The fourth information includes the following: ● Additional information: Axis 1 starts operation at point No. 5. ● Motion unit setting information First relay number: R30000 First DM number: DM10000 Axis 1 positioning control start relay: R30200 Axis 1 positioning control start completion relay: R36800 Axis 1 positioning completion relay: R36802 Axis 1 positioning completion clear relay: R30202 Axis 1 positioning start point number: #2100 Axis 1 positioning control start completion code: #4050 ● Axis 1 starts operation at point No. Program to start operation at 5 (C language) CONDITIONAL_EXECUTION(LD(MR000),OUT(R30000)); CONDITIONAL_EXECUTION(LD(MR000),OUT(R30505)); / * Set 5 as the positioning start point number for axis 1 and turn on the positioning control start relay * / CONDITIONAL_EXECUTION(LD(Always),MOV(5,@DM100)); CONDITIONAL_EXECUTION(LDP(MR001),UWRIT(1,2100,@DM100,1)); CONDITIONAL_EXECUTION(AND(OR(LDP(MR002),LD(R30200)),AND(LD(R36600),AND(LDB(R3680 0),LDB(R36903)))),OUT(DR30200)); / * Read the positioning control start completion code to EM0 * / CONDITIONAL_EXECUTION(LD(R36800),UREAD(1,4050,EM0,1)); CONDITIONAL_EXECUTION(AND(LD(R36800),NEQ(EM0,0)),SET(@MR000)); / * When the positioning completion relay turns ON, turn ON the positioning completion clear relay * / CONDITIONAL_EXECUTION(LD(R36802),OUT(R30202)); Furthermore, the fourth information may include the following constraints: "In particular, make use of AND / OR to avoid nesting if statements. Furthermore, use the following macro instead of the if statement within the program.#define CONDITIONAL_EXECUTION((CONDITION), (EXECUTION)) if (CONDITION) EXECUTION ; To ensure that this macro is used once per statement, write the part that is always executed as CONDITIONAL_EXECUTION(EQ(1, alwaysOn), ...);. Make sure that CONDITIONAL_EXECUTION is not used in the argument (CONDITION / EXECUTION) of CONDITIONAL_EXECUTION. Do not define a local variable within the scan (inside the while statement), but write it directly in the argument of CONDITIONAL_EXECUTION. Extract only the part that contains CONDITIONAL_EXECUTION from the generated program and output the text. Furthermore, convert this text as follows to generate and output text that does not contain AND / OR / CONDITIONAL_EXECUTION. AND(X,Y) => XY OR(X,Y) => [X,Y] CONDITIONAL_EXECUTION(X,Y) => XY Add a semicolon at the end of each statement. Make sure the output satisfies the following EBNF. # L5KPaerser ## Tokenizer First, break down the string using the following rules. | Delimiter | Identifier | | --- | --- | | ( | lp | | ) | rp | | [ | lb | | ] | rb | | , | cm | | ; | sc | | From "to the next" | dq (including spaces) | | From 'to the next' | sq (including spaces) | | While other characters occur consecutively | tk (separated by spaces) | | Space | *Skip | - Error detection & message If there is no closing DQ or SQ, it will output "End of string not found."## EBNF | FROM | TO | Error detected | Error message | | --- | --- | --- | --- | | INPUTTEXT | RUNG+ | | | | | RUNG | RUNGELEMENT sc | Missing sc | Terminating ";" not found.| | RUNGELEMENT | sc | | | | | SERIALBLOCK | | | | SERIALBLOCK | SERIALELEMENT+ | | | | SERIALELEMENT | NODE | | | | | PARALLELBLOCK | | | | PARALLELBLOCK | lb SERIALBLOCK (cm SERIALBLOCK?)+ rb | Not enough BLOCK or rb is missing | "]" not found. | | NODE | OPERATION lp OPERAND? (cm OPERAND?)* rp | No lp or rp is missing | "(" not found.or ")" not found. | | OPERATION | tk | No tk | Command not found. | | OPERAND | dq | | | | | sq | | | | | EXPRESSION | | | | MODIFIER | tk | | | | EXPRESSION | Token other than "cm" and "rp not corresponding to lp" + | | |" (2) Response When the above prompt is sent to the LLM server 100, the following response (mnemonic) is obtained.LD(MR000)OUT(R34000); LD(MR000)OUT(R34200); LD(alwaysOn)MOV(3,@DM100); LDP(MR001)UWRIT(1,2100,@DM100,1); [LD(MR002),LD(R34200)]LDB(R40600)LDB(R40800)LD(R40903)OUT(DR34200); LD(R40800)UREAD(1,4050,EM0,1); LD(R40800)NEQ(EM0,0)SET(@MR000); LD(R40802)OUT(R34202); (3) Ladder Diagram Figure 10 shows the ladder diagram converted from the above answer statement. It can be seen that the mnemonic contained in the answer statement matches the ladder diagram. According to FIG. 1, when MR000 is turned on, operation is permitted. Also, when MR000 is turned on, the servo for axis 1 in the motor driver 4 is turned on. CR2002 is a relay device that is always on. 3 is assigned to DM100 by the MOV instruction. At the rising edge of MR001, 2100 is set as the positioning start point number for axis 1 by the UWRIT instruction. When MR002 is turned on, or when positioning of axis 1 has started, and the motor driver 4 is operable, and positioning control for axis 1 has not started and is not currently in axis control, positioning control for axis 1 is started. When the start of positioning control is complete, a completion code is written to EM0 by the UREAD instruction. After that, the positioning control start is completed, and the positioning of axis 1 is completed.

[0093] (Case ii) In the case of function blocks In the above-described embodiment, not only ladder diagrams but also function blocks described in ladder diagrams can be created with the help of the LLM server 100. Below, as an example, a method for creating a function block that extracts a character string given separated by commas, converts the character string into numerical values, and stores them in an array is shown.

[0094] (1) Prompt: "You will be given the following four pieces of information: First information about the input / output devices connected to the programmable logic controller; Second information about at least one of the commands or program modules used in the control program; Third information indicating the contents of the control program; Fourth information to match the text code included in the answer to the ladder diagram; Corresponding to the third information, please answer step by step according to the first, second and fourth information." (1-1) First information: None (1-2) Second information ● Information I: Express the scan with while(true).

[0095] Do not define local variables within a scan (while statement). ●Information II In that case, do not use any functions other than the following API. Do not use printf either. Get current time: extern void GetTime(time_t& time); Compare size: extern bool GT(int a, int b); Compare equality: extern bool EQ(int a, int b); Determine status: extern bool LD(int value); Determine status (negative logic): extern bool LDB(int value); Reflect previous determination: extern bool OUT(int value); Count up: extern void INC(int& value); Assign value: extern void MOV(int from, int& to); AND condition determination: extern bool AND(bool a, bool b); OR condition determination: extern bool OR(bool a, bool b); Always execute: extern bool alwaysOn; Find the position of string F from the start character in string S and store in D: extern voi d SFIND(char *S, char *F, short *D, short start); / ** * @brief Extracts the specified number of characters from the left end (beginning) of a string. * S: Specifies the original string to extract, or where to store it * D: Specifies where to store the extracted string * n: Specifies the number of characters (bytes) to extract (0 to 1999) * / extern void SLEFT(char *S, char *D, short n); / ** * @brief Converts a decimal ASCII string to a numeric value. * ascii: Specifies where to store the decimal ASCII string to be converted to BIN data * num: Specifies where to store the converted BIN data * / extern void RDASC(char *ascii, int *num); (1-3) Third information "Extracts a string given separated by commas, separated by commas, and converts the string to a numeric value."Convert it and store it in an array. " (1-4) Fourth information "In particular, make use of AND / OR to avoid nesting if statements. Furthermore, use the following macro instead of the if statements within the program. #define CONDITIONAL_EXECUTION((CONDITION), (EXECUTION)) if (CONDITION) EXECUTION ; In order to use this macro once per statement, write the part that is always executed as CONDITIONAL_EXECUTION(EQ(1, alwaysOn), ...);. Make sure that CONDITIONAL_EXECUTION is not used in the argument (CONDITION / EXECUTION) of CONDITIONAL_EXECUTION. Do not define a local variable within the scan (inside the while statement), but write it directly in the argument of CONDITIONAL_EXECUTION. Extract only the part that contains CONDITIONAL_EXECUTION from the generated program and output the text. Furthermore, convert this text as follows to generate and output text that does not contain AND / OR / CONDITIONAL_EXECUTION. AND(X,Y) => XY OR(X,Y) => [X,Y] CONDITIONAL_EXECUTION(X,Y) => XY Add a semicolon to the end of each statement. Make sure the output satisfies the following EBNF. # L5KPaerser ## Tokenizer First, break down the string using the following rules. | Delimiter | Identifier | | --- | --- | | ( | lp | | ) | rp | | [ | lb | | ] | rb | | , | cm | | ; | sc | | From "to the next" | dq (including spaces) | | From 'to the next' | sq (including spaces) | | While other characters are consecutive | tk (separated by spaces) | | Space | *Skip | - Error detection & message If there is no closing DQ or SQ, the message "End of string not found" will be output.## EBNF | FROM | TO | Error detected | Error message | | --- | --- | --- | --- | | INPUTTEXT | RUNG+ | | | | | RUNG | RUNGELEMENT sc | Missing sc | Missing terminating ";". | | RUNGELEMENT | sc | | | | | SERIALBLOCK | | | | SERIALBLOCK | SERIALELEMENT+ | || | SERIALELEMENT | NODE | | | | | PARALLELBLOCK | | | | PARALLELBLOCK | lb SERIALBLOCK (cm SERIALBLOCK?)+ rb | Not enough BLOCK or rb missing | "]" not found. | | NODE | OPERATION lp OPERAND? (cm OPERAND?)* rp | No lp or no rp | "(" not found. or ")" not found. | | OPERATION | tk | No tk | Instruction not found. | | OPERAND | dq | | | | | sq | || | | EXPRESSION | | | | MODIFIER | tk | | | | EXPRESSION | Tokens other than "cm" and "rp" that does not correspond to "lp" + | | |" (2) Answer LD(alwaysOn)SFIND(inputString, ",", &commaPosition, index); LD(alwaysOn)SLEFT(inputString, tempString, commmaPosition); LD(alwaysOn)RDASC(tempString, &number); LD(alwaysOn)MOV(number, array[index]); LD(alwaysOn)INC(index); (3) Ladder diagram Figure 11 shows the generated function blocks. SFIND is an instruction that executes a string search. SLEFT is an instruction that executes extraction of characters from the left side of a string. RDASC is an instruction that converts between decimal and ASCII characters. This allows a given string separated by commas to be extracted at the comma separator, converted to numeric values, and stored in an array. In this way, the function block can convert the characters from the beginning of the given string up to the comma into numeric values. The user can modify the generated function block as needed to complete the function block so that it achieves the user's desired functionality.

[0096] (Case iii) Case of generating ladder diagram and program module separately The following describes generating the ladder diagram and program module separately when reading a program module (e.g., function block) from a ladder diagram.

[0097] (1) Prompt (1-1) First information "You will be given the following four pieces of information: * First information about the input / output devices connected to the programmable logic controller * Second information about at least one of the commands or program modules used in the control program * Third information indicating the contents of the control program * Fourth information to match the text code included in the answer to the ladder diagram Correspond to the third information and answer step by step according to the first, second and fourth information." (1-2) Second information Information I Express a scan with while(true). Do not define local variables within the scan (inside the while statement).

[0098] Information II: In this case, do not use any functions other than the following APIs. Do not use printf either.

[0099] Get current time: extern void GetTime(time_t& time); Compare size: extern bool GT(int a, int b); Compare equality: extern bool EQ(int a, int b); Determine status: extern bool LD(int value); Determine status (negative logic): extern bool LDB(int value); Reflect previous determination: extern bool OUT(int value); Count up: extern void INC(int& value); Assign value: extern void MOV(int from, int& to); AND condition determination: extern bool AND(bool a, bool b); OR condition determination: extern bool OR(bool a, bool b); Always execute: extern bool alwaysOn; Find the position of string F from the start character in string S and store in D: extern v oid SFIND(char *S, char *F, short *D, short start); / ** * @brief Extracts the specified number of characters from the left end (beginning) of a string. * S: Specifies the original string to extract, or where to store it * D: Specifies where to store the extracted string * n: Specifies the number of characters (bytes) to extract (0 to 1999) * / extern void SLEFT(char *S, char *D, short n); / ** * @brief Converts a decimal ASCII string to a numeric value. * ascii: Specifies where to store the decimal ASCII string to be converted to BIN data * num: Specifies where to store the converted BIN data * / extern void RDASC(char *ascii, int *num); (1-3) Third information "Only when R00 is ON and R100 is OFF, extract the given string separated by commas, convert the string to numeric values, and store them in an array." (1-4) Fourth information "Constraints and procedures will be given, so carry out the procedures keeping the constraints in mind.●Constraint 1: Use AND / OR to avoid nesting if statements. ●Constraint 2: Use the following macro instead of the if statement within the program: #define CONDITIONAL_EXECUTION((CONDITION), (EXECUTION)) if (CONDITION) EXECUTION To ensure that this macro is used once per statement, write the part that is always executed as CONDITIONAL_EXECUTION(EQ(1, alwaysOn), ...); ●Constraint 3: Do not use CONDITIONAL_EXECUTION as an argument (CONDITION / EXECUTION) to CONDITIONAL_EXECUTION. Also, only one process should be performed with EXECUTION. ●Constraint 4: Do not define local variables within the scan (inside the while statement), but write them directly as an argument to CONDITIONAL_EXECUTION. ●Constraint 5: Satisfy the following EBNF written in markdown format. # L5KPaerser ## Tokenizer First, decompose the string using the following rules. | Delimiter | Identifier | | --- | --- | | ( | lp | | ) | rp | | [ | lb | | ] | rb | | , | cm | | ; | sc | | From "to next" | dq (including spaces) | | From 'to next' | sq (including spaces) | | Between consecutive others | tk (separated by spaces) | | Space | *Skip | - Error detection & message If there is no closing DQ or SQ, it will output "End of string not found."## EBNF | FROM | TO | Error detected | Error message | | --- | --- | --- | --- | | INPUTTEXT | RUNG+ | | | | | RUNG | RUNGELEMENT sc | Missing sc | Terminating ";" not found.| | RUNGELEMENT | sc | | | | | SERIALBLOCK | | | | SERIALBLOCK | SERIALELEMENT+ | | | | SERIALELEMENT | NODE | | | | | PARALLELBLOCK | | | | PARALLELBLOCK | lb SERIALBLOCK (cm SERIALBLOCK?)+ rb | Not enough BLOCK or rb is missing | "]" not found. | | NODE | OPERATION lp OPERAND? (cm OPERAND?)* rp | No lp or rp is missing | "(" not found.or ")" not found. | | OPERATION | tk | No tk | Instruction not found. | | OPERAND | dq | | | | | sq | | | | | EXPRESSION | | | | MODIFIER | tk | | | | EXPRESSION | Token other than "cm" and "rp not corresponding to lp" +| | | Follow steps 1-3 below. ●Step 1: Understand the contents of information 3, follow constraints 1-4, convert the contents into a C language program, and output it.●Step 2: In the program created in Step 1, if there are any parts where the meaning of the processing is broken, add comments in the following format before and after the processing to make it clear that the section is broken. Format for comments before processing: / * [start]function-meaning : processing meaning * / Format for comments after processing: / * [end]function-meaning : processing meaning * / Step 2: From the generated program, extract only the lines containing CONDITIONAL_EXECUTION or function-meaning and output the text. Step 3: Convert the text output in Step 2 as follows to generate and output text that does not contain AND / OR / CONDITIONAL_EXECUTION. At this time, the text to be output must satisfy Constraint 5. AND(X,Y) => XY OR(X,Y) => [X,Y] CONDITIONAL_EXECUTION(X,Y) => XY Add a semicolon to the end of each statement. (2) Answer text Among the answers, the answer text for the function block is as described above. Here, the function block is given the name convertCommaSeparatedStringRoNumberArray. The answer text corresponding to the ladder diagram is the mnemonic for calling the function block convertCommaSeparatedStringRoNumberArray. The specific mnemonic is omitted.

[0100] (3) Ladder Diagram Figure 12 shows an example of a generated ladder diagram. The generated function blocks are as shown in Figure 11. As shown in Figure 12, the function block convertCommaSeparatedStringRoNumberArray is called only when R00 is ON and R100 is OFF. As a result, the function block convertCommaSeparatedStringRoNumberArray extracts the comma-separated strings given to it, converts the extracted strings to numbers, and stores them in an array.

[0101] (Case iv) Effectiveness of Specifying EBNF As mentioned above, specifying EBNF makes it possible to obtain a response statement that includes a text code that can be converted into a ladder diagram more reliably. Here, to verify the usefulness of specifying EBNF, a case will be introduced in which a text code that can be converted into a ladder diagram cannot be obtained if EBNF is not specified. ●Case A: When instructed to "Simply create a ladder." ●Case B: When instructed to "Create it in natural language and then convert it to a ladder." (1) About Case A (1-1) Prompt "Output a program that meets the following requirements. The program must be convertible into a ladder diagram in the PLC editor. Extract the given string separated by commas, convert the string to numbers, and store them in an array." (1-2) Answer "PLC ladder diagrams cannot usually be directly converted into text-based programming languages. However, the functionality you requested can be implemented in a general programming language. Below is an example implementation in Python. def convert_string_to_numbers(input_string): # Split with commas string_list = input_string.split(',') # Convert string to numbers number_list = [int(s) for s in string_list] return number_list # Test input_string = "1,2,3,4,5" print(convert_string_to_numbers(input_string)) This program takes a comma-separated string as input, splits it on commas, converts each string to a number, and stores them in an array. However, performing such operations in a PLC ladder diagram is difficult, so it is usually recommended to use a high-level language built into the PLC programming environment (such as Structured Text or Function Block Diagram). These languages ​​support more complex operations such as string manipulation and array manipulation.」 (1-3) Discussion of the results In Case A, the LLM server 100 creates a response containing Python code because it cannot output a ladder diagram. From this result, it is necessary to create a parser from Python to a ladder diagram in order to create a ladder diagram, which would be difficult for an average user. (2) Regarding Case B (2-1) Prompt "You must output a program that satisfies the following requirements through two steps. Submit a program that can be converted into a ladder diagram in a PLC editor. Requirement: Extract the given string separated by commas, separate them by commas, convert the string to numbers, and store them in an array. Step 1: Create a program in C++ format that satisfies the requirements. Step 2: Based on the program created in Step 1 and the requirements, submit code that can be converted into a ladder diagram in a PLC editor." (2-2) Response "Step 1: Program in C++ language Below is a C++ program that takes a comma-separated string, converts it to numbers, and stores it in an array.#include <iostream> #include <sstream> #include <vector> #include <string> std::vector<int> splitAndConvert(const std::string& str) { std::vector<int> result; std::stringstream ss(str); std::string token; while (std::getline(ss, token, ',')) { result.push_back(std::stoi(token));} return result;} int main() { std::string input = "1,2,3,4,5"; std::vector<int> numbers = splitAndConvert(input); for (int num : numbers) { std::cout << num << std::endl;} return 0;} Step 2: PLC ladder diagram PLC ladder diagrams are typically used to represent physical inputs and outputs. Therefore, it is difficult to directly express string or array operations. However, it is possible to express the flow of a general program. Below is an example of a ladder diagram that expresses the general flow of the above C++ program. However, the specific implementation will depend on the PLC model and programming environment used. (Start) [----]( )----[ / ]----(Split and Convert) [----]( )----[ / ]----(Store in Array) [----]( )----[ / ]----(Output) (End) [----]( )----[ / ] This ladder diagram expresses the flow from "Start" to "End.""Split and Convert" represents the operation of splitting a string and converting it to a number, "Store in Array" represents the operation of storing the result in an array, and "Output" represents the operation of outputting the result." (2-3) Discussion of the Results In Case B, compared to Case i, the answer obtained appears to be correct at first glance. However, in reality, this is not a correct ladder diagram. If we consider the [ / ] written in the answer as a contact point, (End) [----]( )----[ / ] is inconsistent as a ladder diagram. Conversely, even if we consider this as a coil, it becomes a double coil, which is not appropriate. To convert this text, which is incomprehensible even when we try to interpret it as a ladder diagram, into a ladder, we still need to create a parser. However, this is difficult for the average user.

[0102] As shown in Examples A and B, if EBNF is not specified, the answer text obtained may be difficult to convert into a ladder diagram. Therefore, specifying EBNF is useful for obtaining the desired answer text quickly and easily.

[0103] <Technical Ideas Derived from the Examples> [Viewpoint 1] The PC 2 is an example of a program creation support device that supports the creation of a control program for use with a programmable logic controller. The CPU 11, the operation unit 8, and the information receiving unit 41 may receive, in natural language, first information about input / output devices connected to the programmable logic controller, second information about at least one of instructions or program modules for controlling the input / output devices, and third information indicating control content achieved in combination with the instructions or program modules. The CPU 11 and the prompt generation unit 42 may generate a natural language prompt for generating text code corresponding to a ladder diagram based on the first information, second information, and third information received by the information receiving unit 41. The CPU 11, the communication unit 13, and the LLM interface 43 may transmit the prompt generated by the prompt generation unit 42 to a large-scale language model (LLM) and receive a response sentence corresponding to the prompt from the large-scale language model. The CPU 11 and the language conversion unit 44 may convert the text code included in the response sentence received via the LLM interface 43 into a ladder diagram. Here, the CPU 11 and the prompt generation unit 42 may add fourth information to the prompt, which restricts the text code included in the answer sentence so that it is suitable for conversion into a ladder diagram by the language conversion unit 44. This allows users who create control programs used in programmable logic controllers, such as ladder programs, to enjoy the benefits of LLM.

[0104] [Viewpoint 2] The fourth information may be a template of a text code written in a general-purpose programming language. By transmitting a template of the text code to be included in the answer to the LLM server 100 in advance, the LLM server 100 can create the answer based on this template. As a result, the text code more likely to be desired by the user can be obtained.

[0105] [Aspect 3] The fourth information may be a candidate instruction set consisting of multiple instructions. By presenting a set of instructions that can be used in text code to the LLM server 100 in advance, the LLM server 100 will generate text code using the presented instruction set. As a result, the text code that the user desires will be obtained.

[0106] [Viewpoint 4] The second information may include definition information that defines the input and output of the program module. The CPU 11 and the language conversion unit 44 may convert the text code into a ladder diagram that includes instructions for calling the program module. This will generate a ladder diagram that allows the user to call the program module desired. The second information may also include the name of the program module.

[0107] [Viewpoint 5] The fourth information may include constraint information that constrains the text code so that a program module is called from the ladder diagram. As described above, without the constraint information, it is difficult to uniquely determine a ladder diagram from the text code. Therefore, by using the constraint information to limit the text code (e.g., mnemonic) to be included in the answer, the user may be able to obtain the ladder diagram they desire.

[0108] [Viewpoint 6] The program module may be a program module that executes access to a predetermined file, in which case the constraint information includes path information required to access the predetermined file.

[0109] [Viewpoint 7] The program module may be a program module that executes access to a predetermined database (e.g., DB 150). The constraint information includes information required to access the predetermined database (e.g., the network address of DB 150, a query format).

[0110] [Aspect 8] The program module may be a program module that executes access to a predetermined FTP server. FTP is an abbreviation for File Transfer Protocol. The restriction information may include address information required to access the predetermined FTP server.

[0111] [Aspect 9] The programmable logic controller may include a motion unit (e.g., the motor driver 4). The fourth information may include a point parameter indicating a moving coordinate of a control target in the motion unit.

[0112] [Aspect 10] The fourth information may include information specifying a logical operation to be executed in the ladder diagram (e.g., BIT operation, arithmetic operation). This will result in obtaining text code that can be converted into a ladder diagram. The fourth information may include information specifying a timer referenced in the ladder diagram. This will result in obtaining text code that can be converted into a ladder diagram that can reference the timer. The fourth information may include a counter referenced in the ladder diagram. This will result in obtaining text code that can be converted into a ladder diagram that can reference the counter. Alternatively, the fourth information may include information specifying a special relay referenced from the ladder diagram. This will result in obtaining text code that can be converted into a ladder diagram that can reference the special relay.

[0113] [Viewpoint 11] Conversion of a first text code into a ladder diagram may fail due to insufficient information contained in the first answer sentence received by the LLM interface 43. In this case, the CPU 11, the display unit 7, and the message output unit 45 may function as output means for outputting a message prompting the user to input the missing information. The prompt generation unit 42 may generate a prompt including additional information input by the user. The LLM interface 43 may transmit the prompt generated by the prompt generation unit 42 to the large-scale language model and receive a second answer sentence corresponding to the prompt from the large-scale language model. The language conversion unit 44 may convert the second text code contained in the second answer sentence received via the LLM interface 43 into a ladder diagram. In this way, if an appropriate text code cannot be obtained due to insufficient input information, it is possible to prompt the user to add the input information. As a result, a text code that can be converted into the desired ladder diagram may be obtained.

[0114] [Aspect 12] The first information may include role information indicating the roles of each of a plurality of input devices (e.g., IO unit, analog input unit) connected to the programmable logic controller, which enables the LLM server 100 to generate text codes according to the roles of the plurality of input devices.

[0115] [Viewpoint 13] The role information included in the first information may be reflected in variable names or comments in the ladder diagram. This will allow the user to easily check whether a ladder diagram appropriate for the role of the input device has been generated by referring to the variable names and comments written in the ladder diagram. This will also save the user the trouble of inputting comments into the ladder diagram.

[0116] [Aspect 14] The fourth information may be described by a metalanguage used to define a context-free grammar, which may increase the probability of obtaining the text code desired by the user.

[0117] [Viewpoint 15] The CPU 11 and the error detection unit 46 may function as a detection unit for detecting program errors in ladder diagrams or text code. The prompt generation unit 42 may create a prompt for requesting a correction suggestion for resolving the program error from the large-scale language model. This may allow the program error to be resolved quickly.

[0118] [Viewpoint 16] The CPU 11 and the library conversion unit 47 may function as a second conversion unit that converts each of a plurality of program components usable in a ladder program based on a ladder diagram into a library function written in a general-purpose programming language. In this case, the fourth information may include a plurality of library functions converted by the second conversion unit. By presenting the library functions usable in the text code to the LLM server 100, the text code generated by the LLM server 100 is restricted, making it easier for the user to obtain the text code they desire.

[0119] [Viewpoint 17] The fourth information may include constraint information that restricts the text code to be written using only bit operations and arithmetic operations. This will result in a text code that is easy to convert into a ladder diagram.

[0120] [Viewpoint 18] The fourth information may include constraint information indicating that the specification of a ladder program using a ladder diagram is constrained by the language usage expression format. This may make it easier to obtain text code that conforms to the ladder program specification. For example, it may make it easier to obtain mnemonic text code that can be converted into a ladder diagram.

[0121] [Aspect 19] The language usage expression format may be Extended Backus-Naur Form (EBNF). This may facilitate obtaining text codes that can be converted into ladder diagrams. For example, it may facilitate obtaining mnemonic text codes that can be converted into ladder diagrams.

[0122] [Aspect 20] A computer program for assisting in the creation of a control program to be used in a programmable logic controller may be configured to cause a computer to: accept, in natural language, first information regarding input / output devices connected to the programmable logic controller, second information regarding at least one of instructions or program modules for controlling the input / output devices, and third information indicating control content to be realized in combination with the instructions or program modules; generate a natural language prompt for generating text code corresponding to a ladder diagram based on the accepted first information, second information, and third information; send the generated prompt to a large scale language model (LLM) and receive from the large scale language model an answer sentence corresponding to the prompt; convert the text code included in the answer sentence received from the large scale language model into a ladder diagram; and add fourth information to the prompt that constrains the text code included in the answer sentence so that it is suitable for conversion into a ladder diagram.

[0123] The invention is not limited to the above-described embodiment, and various modifications and variations are possible within the scope of the gist of the invention.

Claims

1. A program creation support device for supporting the creation of a control program used in a programmable logic controller, comprising: an information reception unit that receives, in natural language, first information regarding input / output devices connected to the programmable logic controller, second information regarding at least one of instructions or program modules for controlling the input / output devices, and third information indicating control content realized in combination with the instructions or the program modules; a prompt generation unit that generates a natural language prompt for generating a text code corresponding to a ladder diagram based on the first information, the second information, and the third information received by the information reception unit; an LLM interface that transmits the prompt generated by the prompt generation unit to a large language model (LLM) and receives a response sentence corresponding to the prompt from the large language model; and a conversion unit that converts the text code included in the response sentence received via the LLM interface into a ladder diagram, wherein the prompt generation unit adds fourth information that constrains the text code included in the response sentence to be suitable for conversion into the ladder diagram by the conversion unit.

2. The program creation support device according to claim 1, wherein the fourth information is a template of the text code in a general-purpose programming language.

3. The program creation support device according to claim 1, wherein the fourth information is a candidate of an instruction set composed of a plurality of instructions.

4. The second information includes definition information that defines the input / output of the program module, and the conversion unit converts the text code into a ladder diagram including calling the program module. The program creation support device according to claim 1, characterized in that.

5. The program creation support device according to claim 1, wherein the fourth information includes constraint information that constrains the text code to call the program module from the ladder diagram.

6. The program module is a program module that executes access to a predetermined file, and the constraint information includes path information necessary for accessing the predetermined file. The program creation support device according to claim 5, characterized in that.

7. The program module is a program module that executes access to a predetermined database, and the constraint information includes information necessary for accessing the predetermined database. The program creation support device according to claim 5, characterized in that.

8. The program module is a program module that executes access to a predetermined FTP server, and the constraint information includes address information necessary for accessing the predetermined FTP server. The program creation support device according to claim 5, characterized in that.

9. The programmable logic controller includes a motion unit, and the fourth information includes point parameters indicating the moving coordinates of the control target in the motion unit. The program creation support device according to claim 1, characterized in that.

10. The fourth information includes information specifying a logical operation executed in the ladder diagram, information specifying a timer referenced in the ladder diagram, a counter referenced in the ladder diagram, or information specifying a special relay referenced from the ladder diagram. The program creation support device according to claim 1, characterized in that.

11. When the conversion of the first text code included in the first response sentence received by the LLM interface fails to convert the first text code into the ladder diagram due to insufficient information, an output means for outputting a message prompting the user to input the insufficient information is further provided. The prompt generation unit generates a prompt including the information additionally input by the user. The LLM interface transmits the prompt generated by the prompt generation unit to the large language model and receives a second response sentence corresponding to the prompt from the large language model. The conversion unit is configured to convert the second text code included in the second response sentence received via the LLM interface into the ladder diagram. The program creation support device according to claim 1, characterized in that.

12. The program creation support device according to claim 1, wherein the first information includes role information indicating the role of each of a plurality of input devices connected to the programmable logic controller.

13. The program creation support device according to claim 12, wherein the role information included in the first information is reflected in a variable name or a comment in the ladder diagram.

14. The program creation support device according to claim 1, wherein the fourth information is described in a metalanguage used to define a context-free grammar.

15. The program creation support device according to claim 1, further comprising a detection means for detecting a program error in the ladder diagram or the text code, wherein the prompt generation unit creates a prompt for requesting the large language model for a correction proposal for eliminating the program error.

16. The program creation support device according to claim 1, further comprising a second conversion unit that converts each of a plurality of program components usable in the ladder program according to the ladder diagram into a library function described in a general-purpose programming language, wherein the fourth information includes the plurality of library functions converted by the second conversion unit.

17. The program creation support device according to claim 1, wherein the fourth information includes constraint information for restricting the description of the text code to use only bit operations and arithmetic operations.

18. The program creation support device according to claim 1, wherein the fourth information includes constraint information indicating that the specification of the ladder program according to the ladder diagram is restricted by a language usage expression form.

19. The program creation support device according to claim 18, wherein the language usage expression form is an extended Backus-Naur form (EBNF).

20. A computer program for assisting in creating a control program used in a programmable logic controller, causing a computer to: receive, in natural language, first information regarding input / output devices connected to the programmable logic controller, second information regarding at least one of instructions or program modules for controlling the input / output devices, and third information indicating control content realized in combination with the instructions or the program modules; generate a natural language prompt for generating a text code corresponding to a ladder diagram based on the received first information, second information, and third information; transmit the generated prompt to a large language model (LLM) and receive a response sentence corresponding to the prompt from the large language model; convert the text code included in the response sentence received from the large language model into a ladder diagram; and add fourth information for restricting the text code included in the response sentence so as to be suitable for conversion into the ladder diagram to the prompt.

Citation Information

Patent Citations

  • Method and device for assisting program generation

    JP2000242307A

  • Programmable controller

    JP2010134593A

  • Program creation device, program creation method, and program

    JP2022101878A

  • Systems and methods for a conversational framework of program synthesis

    US20230280985A1

Cited By

  • Information processing system, information processing method, and program

    JP7855156B1

  • Information processing system, information processing method, and program

    JP7858963B1

  • Method and system for automating artificial intelligence-based microcontroller programming

    KR102977723B1