Translation program, translation device, and translation method
The translation program and device address the machine dependence of sequence control programs by converting source code and allowing monitoring variable designation, reducing the workload and complexity of observing program behavior while balancing execution speed and observability.
Patent Information
- Application Number
- PCT/JP2023/026646
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-07-20
- Publication Date
- 2025-01-23
AI Technical Summary
Programs written in sequence control programming languages for programmable controllers are highly machine-dependent, requiring rewriting and translation to observe behavior and meet debugging demands, leading to cumbersome work and increased workload.
A translation program and device that converts source code from a first language to a second language, allowing designation of monitoring variables to store values in shared or non-shared memory, balancing observability and execution speed.
Reduces the workload of translating sequence control programs by allowing users to adjust observability and execution speed through monitoring variable designation, simplifying the process of observing program behavior without extensive rewriting.
Smart Images

Figure JP2023026646_23012025_PF_FP_ABST
Abstract
Description
Translation program, translation device, and translation method
[0001] The present disclosure relates to a translation program, a translation device, and a translation method.
[0002] In factory automation (FA), sequence control is performed on a variety of devices. Since the advent of programmable controllers, the programming languages used to define the sequence control have been developed by their vendors, resulting in numerous independent programming languages. For this reason, the International Electrotechnical Commission (IEC) has published IEC61131-3, which defines five programming languages for sequence control.
[0003] However, programs written in sequence control programming languages still have a high degree of model dependency. Specifically, a program that can be executed on a programmable controller from one vendor cannot be executed on a control device from another vendor, and in many cases the program must be rewritten.
[0004] Therefore, a technique for obtaining a program with low model dependency has been proposed (see, for example, Patent Document 1). Patent Document 1 describes a program generation device that translates a program written in a sequence command language into a program written in a high-level language for a general-purpose computer. This device makes it possible to obtain a program with low model dependency that performs the same functions as a program written in a sequence command language.
[0005] Japanese Patent Application Publication No. 07-295612
[0006] However, a program obtained by translation such as that described in Patent Document 1 may not satisfy the on-site need to observe the behavior of a program executed in a programmable controller for debugging and future development. Therefore, on-site workers must repeatedly rewrite the program to be translated in a sequence instruction language and translate it until they obtain a program that satisfies the need, which can result in cumbersome work. Furthermore, even if a program that meets the needs is created once, each time a new need arises to observe different behavior, the program may have to be rewritten in a sequence instruction language, which can be cumbersome work. Therefore, there is room for reducing the workload required to translate a sequence control program to obtain a new program that satisfies the need to observe its behavior.
[0007] The present disclosure has been made in light of the above-mentioned circumstances, and aims to reduce the workload required to translate a sequence control program and obtain a new program that satisfies the desire to observe its behavior.
[0008] In order to achieve the above-mentioned object, the translation program of the present disclosure functions as a translation device that translates first source code written in a first language of a program executed by a programmable controller to control a controlled device into second source code written in a second language different from the first language, and as a receiving means that receives the specification of a monitored variable, among the variables contained in the first source code, into which a value that is to be monitored when the program is executed is assigned, and a translation means that translates the first source code into a second source code by converting, if the shared memory variable is a monitored variable, a variable code related to a shared memory variable, among the first source code, whose value is stored in a shared memory possessed by the programmable controller and shared with the controlled device, into a first conversion code related to a variable whose value is stored in the shared memory, and if the shared memory variable is different from the monitored variable, into a second conversion code related to a variable whose value is stored in a non-shared memory different from the shared memory possessed by the programmable controller.
[0009] According to the present disclosure, it is possible to reduce the workload of translating a sequence control program to obtain a new program that satisfies the desire to observe its behavior.
[0010] FIG. 1 is a diagram showing an overview of a PLC (Programmable Logic Controller) according to the first embodiment; FIG. 1 is a diagram showing program execution according to a comparative example; FIG. 2 is a diagram showing program execution according to a comparative example; FIG. 2 is a diagram showing a hardware configuration of a PLC program development environment according to the first embodiment; FIG. 3 is a diagram showing a functional configuration of a PLC program development environment according to the first embodiment; FIG. 4 is a diagram showing a first example of translation according to the first embodiment; FIG. 5 is a diagram showing a second example of translation according to the first embodiment; FIG. 6 is a diagram showing an example of a monitored variable list according to the first embodiment; FIG. 7 is a diagram showing an example of a description of second source code according to the first embodiment;
[0011] Hereinafter, a PLC program development environment according to an embodiment of the present disclosure will be described in detail with reference to the drawings.
[0012] Embodiment 1. As shown in FIG. 1 , a PLC program development environment 10 according to this embodiment corresponds to a support terminal connected to a PLC 30, which is a programmable controller, and supports a user in developing a program 23 for causing the PLC 30 to control a controlled device 40. Specifically, the PLC program development environment 10 corresponds to an example of a translation device that translates first source code 21 written in a first language for sequence control into second source code 22 written in a general-purpose high-level language different from the first language, compiles the second source code 22, and writes the resulting program 23 into a non-shared memory 302 of the PLC 30. When the program 23 is executed, the values of monitored variables used in the program 23 are stored in a shared memory 301. The shared memory 301 is a memory shared with the controlled device 40, and in many cases, a tool for externally acquiring the data in real time is already available. Therefore, by using the tool, the behavior of the program 23 can be easily observed by monitoring the values of monitored variables. FIG. 1 shows that the values of the monitored variables are monitored by a monitoring unit 17 included in a PLC program development environment 10 serving as a support terminal.
[0013] When there are many monitored variables, the behavior of the program 23 can be observed in detail, but the number of procedures for the program 23 in the unshared memory 302 to access the shared memory 301 also increases, slowing down the execution speed of the program 23. On the other hand, when there are few monitored variables, the range of observability for the behavior of the program 23 is narrowed, but the execution speed is fast. The property of a program that allows the behavior of the program 23 to be observed during execution may be referred to as observability hereinafter. As described above, observability and execution speed are in a trade-off relationship, and the user of the PLC program development environment 10 can adjust the observability and execution speed to meet their needs by appropriately specifying monitored variables.
[0014] <Program Execution by PLC 30> The PLC 30 is a control device that controls the controlled devices 40 in a factory. The PLC 30 controls various processes, such as machining and inspection of workpieces flowing through a production line. While FIG. 1 shows a single controlled device 40 as a representative example, typically, multiple controlled devices 40 are controlled to work together. For example, sensing results from the controlled device 40, which is a sensor, are input to the PLC 30, and operating commands determined by a program based on this input are output from the PLC 30 to the controlled device 40, which is a robot, thereby machining the workpiece. The PLC 30 and the controlled devices 40 are connected via signal lines that transmit current signals or voltage signals, or via a network such as a field network or LAN (Local Area Network).
[0015] In addition to the shared memory 301 and non-shared memory 302 described above, the PLC 30 has an I / O (Input / Output) terminal 31 for inputting signals from the controlled device 40 or outputting signals to the controlled device 40, a processor 32, an OS (Operating System) 33, and a control platform 34 that runs on the OS 33.
[0016] The shared memory 301 and the unshared memory 302 each correspond to a random access memory (RAM). The processor 32 includes a central processing unit (CPU) or a micro-processing unit (MPU) as a processing circuit, and executes programs.
[0017] The control platform 34 is application software that runs on the OS 33 and performs functions that form the basis of control by the PLC 30. Specifically, the control platform 34 calls and executes other programs at predetermined times and manages the shared memory 301 in which the execution results are saved. The control platform 34 may call multiple programs. There may also be multiple programs 23 shown in FIG. 1 . The timing at which a program is called may differ for each program, and may be, for example, at a specific time, at predetermined intervals, or when a specific event occurs.
[0018] In addition to the execution results described above, the shared memory 301 stores input / output information that is periodically synchronized by the control platform 34 with the state of the I / O terminal 31. As a result, signals input from the controlled device 40 to the PLC 30 are reflected in the shared memory 301, and the data in the shared memory 301 is reflected in signals output from the PLC 30 to the controlled device 40. Furthermore, all programs stored in the PLC 30 can normally access the data in the shared memory 301 via the control platform 34, so the data in the shared memory 301 is treated as global data between multiple programs. The shared memory 301 is a standard component for achieving the basic functions of the PLC 30, and its capacity is a specification value listed in the catalog for the PLC 30.
[0019] 1 to the second source code 22, the program 211 of the first source code 21 is loaded into the shared memory 301, as shown in Fig. 2, and the values of all variables included in the first source code 21 are also stored in the shared memory 301. The variables whose values are stored in the shared memory 301 are also called devices or labels.
[0020] The first language for writing the first source code 21 is a programming language for causing the PLC 30 to execute sequence control, and is, for example, an instruction list, a ladder diagram, a function block diagram, structured text, or a sequence function chart, as defined in IEC 61131-3. Hereinafter, structured text may be referred to as an ST (Structured Text) language, and an instruction list may be referred to as an IL (Instruction List) language, as appropriate.
[0021] 2 corresponds to a conventional program execution mode performed by the PLC 30. In this mode, it is possible to observe the values of all variables, but the first source code 21 and the program 211 are highly model-dependent. As can be seen from FIG. 2 , the first source code 21 corresponds to an example of source code of the program 211 that is executed by the PLC 30 without storing the values of the variables in the non-shared memory 302.
[0022] On the other hand, if the first source code 21 is translated into the second source code 22 but no monitoring variables are set at that time, as shown in Figure 3, the program 23 is written to the non-shared memory 302 and executed, and the values of the variables contained in the second source code 22 are also stored in the non-shared memory 302.
[0023] The example in Fig. 3 corresponds to the technology of Patent Document 1 mentioned above. In the example in Fig. 3, if the second language for writing the second source code 22 is a general high-level language and the program 23 is executed by a general-purpose processor, the model dependency will be low, but observability will also be low. Here, the high-level language is, for example, C, and the program 23 corresponds to object code compiled from the second source code 22. However, the second language is not limited to C and may be another language.
[0024] Furthermore, the general-purpose processor that executes the program 23 may be the same as or different from the processor 32 that executes the control platform 34. Although only one processor 32 is shown in Figures 1 and 3 as a representative example, the PLC 30 may have a separate processor 32 for operating the control platform 34 and a general-purpose processor 32 for executing the program 23. Note that the processor 32 that executes the control platform 34 may be a processor dedicated to the PLC 30 or may be a general-purpose processor.
[0025] 3 can be executed at high speed because technologies for executing programs written in general high-level languages at high speed on general-purpose processors have been accumulated. In order to ensure the execution speed of program 23, it is desirable that non-shared memory 302 into which program 23 is loaded be a memory dedicated to the general-purpose processor, different from shared memory 301 managed by control platform 34. If the function of PLC 30 that executes programs using a general-purpose processor is treated as non-standard or optional by its vendor, non-shared memory 302 can be an additional component of PLC 30, and therefore is implemented as a storage device different from shared memory 301.
[0026] 3 omits the values stored in the shared memory 301 to emphasize that the values of variables handled by the program 23 are stored in the unshared memory 302. In reality, the program 23 is called and executed by the control platform 34, and therefore there is also data in the shared memory 301 handled by the program 23. Examples of such data include input data for the program 23, execution results of the program 23, input / output data of the PLC 30 handled by the program 23, and global data shared by the program 23 with other programs. These pieces of data can be stored in the shared memory 301 as variable values.
[0027] However, in the example of Fig. 3, intermediate data and local variable values that are handled entirely within the program 23 are stored in the unshared memory 302. In contrast, in order to observe the behavior of the program 23 during execution, the PLC program development environment 10 according to this embodiment generates the second source code 22 that stores the values of at least some of the monitored variables handled by the program 23 in the shared memory 301, as shown in Fig. 1. In other words, it can be said that the PLC program development environment 10 appropriately changes the storage destination of the variable values stored in the unshared memory 302 in the example of Fig. 3 to the shared memory 301 as shown in Fig. 1.
[0028] <Hardware Configuration of PLC Program Development Environment 10> The PLC program development environment 10 is an industrial personal computer (PC) that is connected to the PLC 30 via a communication line such as a universal serial bus (USB) cable or via the network described above. The PLC program development environment 10 is configured with hardware elements that function as a computer. In detail, as shown in FIG. 4 , the PLC program development environment 10 includes a processor 101, a main memory unit 102, an auxiliary memory unit 103, an input unit 104, an output unit 105, and a communication unit 106. The main memory unit 102, the auxiliary memory unit 103, the input unit 104, the output unit 105, and the communication unit 106 are all connected to the processor 101 via an internal bus 107.
[0029] The processor 101 includes a CPU or an MPU as a processing circuit. The processor 101 realizes various functions and executes the processes described below by executing a program P1 stored in the auxiliary storage unit 103. The program P1 corresponds to a so-called engineering tool and is an example of a translation program that causes the PLC program development environment 10 to function as described below.
[0030] The main memory unit 102 includes a RAM. A program P1 is loaded into the main memory unit 102 from the auxiliary memory unit 103. The main memory unit 102 is used as a work area for the processor 101.
[0031] The auxiliary storage unit 103 includes a non-volatile memory such as an EEPROM (Electrically Erasable Programmable Read-Only Memory) and an HDD (Hard Disk Drive). In addition to the program P1, the auxiliary storage unit 103 stores various data used in the processing of the processor 101. The auxiliary storage unit 103 supplies the processor 101 with data used by the processor 101 in accordance with instructions from the processor 101. The auxiliary storage unit 103 also stores data supplied from the processor 101.
[0032] The input unit 104 includes input devices such as hardware switches, input keys, a keyboard, and a pointing device. The input unit 104 acquires information input by a user and notifies the processor 101 of the acquired information.
[0033] The output unit 105 includes output devices such as a light emitting diode (LED), a liquid crystal display (LCD), and a speaker, and presents various information to the user in accordance with instructions from the processor 101.
[0034] The communication unit 106 includes a communication interface circuit for communicating with an external device. The communication unit 106 receives a signal from the outside and outputs data indicated by this signal to the processor 101. The communication unit 106 also transmits a signal indicating the data output from the processor 101 to the external device.
[0035] <Functions of PLC Program Development Environment 10> The above-described hardware configurations work together, causing the PLC program development environment 10 to function as an engineering tool, which is a development environment for a program executed by the PLC 30. This engineering tool provides a function for translating first source code 21 into second source code 22. The PLC program development environment 10 corresponds to an example of a translation device that translates first source code, written in a first language of a program executed by a programmable controller to control a controlled device, into second source code written in a second language different from the first language. 5, the PLC program development environment 10 has, as its functions, an acquisition unit 11 that acquires first source code 21, a translation unit 12 that translates the first source code 21 into second source code 22, a reception unit 13 that receives settings of information necessary for translating the first source code 21, an index value calculation unit 14 that calculates an index value that indicates the execution speed when the second source code 22 is executed, an index value presentation unit 15 that presents the calculated index value, a compiler 16 that compiles the second source code 22, and a monitoring unit 17 that monitors the values of monitored variables. The translation unit 12, the compiler 16, and the monitoring unit 17 are also shown in FIG. 1, but their functions will be described in more detail below.
[0036] The acquisition unit 11 is mainly realized by the input unit 104 or the communication unit 106. The acquisition unit 11 may acquire the first source code 21 created by a user using an engineering tool, or may acquire the first source code 21 by reading it out from an address specified by the user.
[0037] The translation unit 12 is mainly realized by the processor 101. The translation unit 12 analyzes the first source code 21 and sequentially converts code components constituting the first source code 21 into code components in a second language corresponding to the code components, thereby generating the second source code 22. The translation means converting the first source code into a second source code in a different format that enables the PLC 30 that executes the program to perform equivalent functions.
[0038] 6 and 7 each show an example of translation by the translation unit 12. In the example of FIG. 6, an IF statement in ST language, which is a first language, is converted into an IF statement in C language, which is a second language. Also, in the example of FIG. 7, a FOR statement in ST language is converted into a FOR statement in C language. In this case, variables COND, VAR0, and ITR included in the first source code 21 are converted into variables Cond, Var0, and Itr included in the second source code 22, respectively. None of the variables in the second source code 22 shown in FIGS. 6 and 7 are monitored variables, and their values are stored in the non-shared memory 302. That is, according to the second source code 22 of FIGS. 6 and 7, a program 23 executed in the manner shown in FIG. 3 is generated.
[0039] The reception unit 13 is mainly realized by the input unit 104 or the communication unit 106. The reception unit 13 receives designation of variables included in the first source code 21 that should be used as monitored variables during translation. The reception unit 13 may receive a monitored variable list 51 input by the user, or may receive the monitored variable list 51 by reading it from an address specified by the user. FIG. 8 shows an example of the monitored variable list 51. According to this monitored variable list 51, the values of two variables, COND and VAR0, included in the first source code 21 shown in FIGS. 6 and 7 are set as monitored variables. The reception unit 13 corresponds to an example of a receiving means for receiving designation of monitored variables that are assigned values to be monitored when a program is executed, among variables included in the first source code.
[0040] 9 shows an example of code in the second language generated according to the setting of a monitoring variable. The code 61 shown in FIG. 9, "Var0=Var1+100;," represents an operation in which the sum of the value of the variable Var1 and 100 is assigned to the variable Var0 when no monitoring variable is set. The code 62, "Var0=API_PF_READ(VAR1)+100;," represents an operation equivalent to the code 61, in which VAR1 is used as a monitoring variable and the value of the monitoring variable stored in the shared memory 301 is read using the function "API_PF_READ." The variable Var1 corresponds to the variable VAR1.
[0041] 9 indicates that in an operation equivalent to the code 61, VAR0 is used as a monitored variable and the operation result is written as the value of the monitored variable using the function "API_PF_WRITE." Code 64 indicates that an operation equivalent to the code 61 is executed using both VAR0 and VAR1 as monitored variables. The functions shown in FIG. 9 are provided as APIs (Application Programming Interfaces) of the control platform 34.
[0042] An example of translation using the function shown in Figure 9 and applying the monitored variable list 51 of Figure 8 to the IF statement of Figure 6 is shown in Figure 10. In Figure 10, the parts changed from the second source code 22 of Figure 6 are shown in bold. For example, the statement for reading the value of the monitored variable COND is "API_PF_READ(COND)," and the statement for writing a value of 100 to the monitored variable VAR0 is "API_PF_WRITE(VAR0, 100)." Also, an example of translation using the monitored variable list 51 of Figure 8 to the FOR statement of Figure 7 is shown in Figure 11.
[0043] 5, the index value calculation unit 14 is mainly realized by the processor 101. The index value calculation unit 14 calculates an index value of the execution speed when the second source code 22 generated in accordance with the specification of the monitoring variable accepted by the acceptance unit 13 is executed. The method of calculating this index value will be described later.
[0044] The index value presenting unit 15 is mainly realized by the output unit 105. By presenting the calculated index value to the user, the index value presenting unit 15 notifies the user of how much the execution speed will be increased by the user's specification of the monitoring variables, and provides the user with feedback on the trade-off between observability and execution speed. The user, having been presented with this index value, adjusts the observability and the execution speed by re-specifying the monitoring variables and translating the first source code 21. The index value presenting unit 15 corresponds to an example of an index value presenting means for presenting the calculated index value.
[0045] The compiler 16 is mainly realized by the processor 101. When the second language is the C language, the compiler 16 is, for example, gcc (GNU Compiler Collection) or Clang.
[0046] The monitoring unit 17 is realized mainly by cooperation of the processor 101, the communication unit 106, and the output unit 105. The monitoring unit 17 reads out the values of the monitoring variables stored in the shared memory 301 and presents them to the user.
[0047] <Translation Processing> Next, the translation processing executed by the PLC program development environment 10 will be described with reference to Figures 12 and 13. The translation processing corresponds to an example of a translation method executed by a translation device.
[0048] 12 , in the translation process, the acquisition unit 11 acquires the first source code 21 (step S1), and the acceptance unit 13 accepts the designation of a monitored variable (step S2). Then, the translation unit 12 analyzes the lexical and syntactic components of the first source code 21 (step S3). Specifically, the translation unit 12 breaks down the first source code 21 into lexical components and analyzes the meaning of the sentence from the arrangement of the lexical components, thereby extracting code components that can be converted into the second language from the first source code 21.
[0049] Next, the translation unit 12 selects one unselected code component from the top of the code components obtained in step S3 (step S4), and determines whether the selected code component is a variable description (step S5). If it is determined that the selected code component is not a variable (step S5; No), the translation unit 12 converts the selected code component into a corresponding code in the second language (step S6), and proceeds to step S10. For example, as shown in FIG. 6, the translation unit 12 converts the code component "ELSEIF" in the first source code 21 into the code "}else if (".
[0050] On the other hand, if the translation unit 12 determines that the selected code component is a variable (Step S5; Yes), it determines whether the code component is designated as a monitored variable (Step S7). This code component corresponds to an example of a variable code related to a shared memory variable. If the code component is designated as a monitored variable (Step S7; Yes), the translation unit 12 converts the code component into code that references the shared memory 301 (Step S8). Specifically, the translation unit 12 converts the code component into a description for accessing the shared memory 301 using the API of the control platform 34, as shown in FIG. 9. The code obtained by the conversion in Step S8 corresponds to an example of a first conversion code. Thereafter, the processing by the PLC program development environment 10 proceeds to Step S10.
[0051] On the other hand, if the code component that is a variable is not designated as a monitored variable (step S7; No), the translation unit 12 converts the code component into code that references the unshared memory 302 (step S9). Specifically, as shown in FIG. 9 , the translation unit 12 converts the code component into a description in the second language that simply references the variable, without using the API of the control platform 34. The code obtained by the conversion in step S9 corresponds to an example of the second converted code. As described above, the execution speed of the program 23 decreases when the program 23 references the monitored variable in the shared memory 301. Therefore, when the variable code of the first source code 21 is converted into the second converted code, the program 23 of the second source code 22 is executed by the PLC 30 in a shorter execution time than when the program 23 is converted into the first converted code.
[0052] Next, the translation unit 12 determines whether all code components have been selected (step S10). If it is determined that all code components have not been selected (step S10; No), the translation unit 12 repeats the processes from step S4 onward. As a result, the code components constituting the first source code 21 are selected sequentially from the beginning of the first source code 21 and converted into code in the second language.
[0053] If it is determined that all code components have been selected (step S10; Yes), the translation unit 12 combines the converted codes to generate second source code 22 (step S11). Here, if the order of the code components written in the first language and the second language is different, the translation unit 12 changes the order as appropriate and combines the code components.
[0054] Next, the index value calculation unit 14 executes an index value calculation process to calculate an index value of the second source code 22 generated in step S11 (step S12). In the index value calculation process, as shown in Fig. 13, the index value calculation unit 14 counts the number of references for each variable (step S121). For example, for the second source code 22 shown in Fig. 10, the number of references for the variable COND is counted as one, and the number of references for the variable VAR0 is counted as one. For the second source code 22 shown in Fig. 11, the number of references for the variable Itr is counted as 10 due to the iterative process, and the number of references for the variable VAR0 is counted as 20 due to the 10 repetitions of a process including one read and one write.
[0055] Next, the index value calculation unit 14 calculates the value of index value A using the following formula (1), where B is the total number of references to all variables and C is the total number of references to the monitored variables (step S122).
[0056] A=C / B×100...(1)
[0057] This index value A is a relative value that is 100 when all variables are monitored variables, and decreases as the execution speed increases, corresponding to the execution time. For example, in the example of FIG. 10 , the index value is calculated as 100. If the example of FIG. 10 were written as variable Var0 as in FIG. 6 without using the function "API_PF_WRITE," the index value would be calculated as 40. Thereafter, the processing by the PLC program development environment 10 returns from the index value calculation processing of FIG. 13 to the translation processing of FIG. 12. The index value calculation unit 14 corresponds to an example of index value calculation means that calculates an index value corresponding to the length of execution time when the program of the second source code is executed.
[0058] 12 , following the index calculation process in step S12, the index presentation unit 15 presents the index calculated in step S12 to the user (step S13). Presentation by the index presentation unit 15 may be by displaying on a screen, by playing back a voice read out loud, or by outputting to a UI (User Interface) terminal via a network.
[0059] Next, the reception unit 13 determines whether or not there has been a change in the monitoring variable (step S14). Specifically, the reception unit 13 determines whether or not a new monitoring variable different from the designated monitoring variable previously accepted in step S2 has been designated. If at least one of the following has occurred: a variable that was not a monitoring variable previously has been changed to a monitoring variable; or a previous monitoring variable has been excluded from the monitoring target, the determination in step S14 is positive.
[0060] If it is determined that the monitored variables have been changed (Step S14; Yes), the PLC program development environment 10 repeats the processing from Step S2 onward. This allows the user to change the monitored variables while checking the index values, and easily find a balance between the desired observability and execution speed. For example, for the second source code 22 in FIG. 10, it is confirmed that excluding the variable VAR0 from the monitored variables improves the index value to 50. Furthermore, for the second source code 22 in FIG. 11, it is confirmed that excluding the variable ITR corresponding to the variable Itr from the monitored variables improves the index value to 33.3.
[0061] On the other hand, if there are no changes to the monitored variables and the user determines that the second source code 22 is complete and inputs a write instruction (step S14; No), the compiler 16 compiles the second source code 22 to generate a program 23, writes the generated program 23 to the PLC 30 (step S15), and the translation process is completed.
[0062] <Effects> As described above, the receiving unit 13 receives the designation of a monitored variable, and the translation unit 12 converts code components related to variables in the first source code 21 into code that references the shared memory 301 if the variable is a monitored variable, and into code that references the unshared memory 302 if the variable is different from the monitored variable. Therefore, the user can adjust the execution speed and observability of the program 23 by changing the designation of the monitored variable. This reduces the workload of translating a sequence control program to obtain a new program that satisfies the desire to observe its behavior.
[0063] 3 , when employing a technique for simply translating first source code 21 written in a first language for sequence control into second source code 22 written in a second language, it is conceivable that, in the creation stage of first source code 21, variables to which values to be monitored are assigned may be global variables stored in shared memory 301. However, creating such first source code 21 is a cumbersome task. In contrast, with PLC program development environment 10 according to the present embodiment, a user can easily obtain program 23 by simply changing the designation of monitored variables without changing first source code 21.
[0064] The translation unit 12 is an example of a translation means for translating a first source code into a second source code by converting a variable code relating to a shared memory variable in the first source code, whose value is stored in a shared memory possessed by the programmable controller and shared with the controlled device, into a first conversion code relating to a variable whose value is stored in the shared memory if the shared memory variable is a monitored variable, and into a second conversion code relating to a variable whose value is stored in a non-shared memory different from the shared memory possessed by the programmable controller if the shared memory variable is different from the monitored variable.
[0065] Furthermore, the index value calculated by the index value calculation unit 14 is presented to the user, the reception unit 13 again receives the designation of the monitoring variable after the index value is presented, and the translation unit 12 translates the first source code 21 into the second source code 22 in accordance with the designation received again. This allows the user to set appropriate monitoring variables while quantitatively evaluating the execution speed of the program 23.
[0066] The index value is calculated based on the number of times the shared memory 301 is referenced when the program 23 is executed. More specifically, the index value is calculated based on a comparison between the number of times the shared memory 301 is referenced when the program 23 is executed in the case where all variables included in the second source code 22 are monitored variables. This makes it possible to obtain an index value corresponding to the execution time depending on whether or not a monitored variable is specified.
[0067] The receiving unit 13 also receives a list of the names of variables that are individually designated as monitoring variables, thereby allowing the user to flexibly designate monitoring variables.
[0068] In the iterative process illustrated in FIG. 11 , the number of iterations is set to 10, making it easy to calculate the number of references. However, there may be cases where the number of iterations is determined by the value of a variable. In such cases, for example, an estimated value of the number of iterations may be used. The estimated value of the number of iterations may be, for example, a predetermined fixed value, a value obtained by prompting the user for input, or a value calculated using another method.
[0069] In the if statement illustrated in FIG. 10, the variable VAR0 is referenced in all branched processes according to the condition, but there may be cases where the variable referenced differs depending on the branch destination. In such cases, for example, the sum of the number of references at each branch destination may be divided by the number of branches to calculate the average number of references at the branch destinations. Furthermore, weights may be assigned to the branches when calculating the average value. These weights may be specified by the user.
[0070] Furthermore, in the above example, reads and writes are treated equally in counting the number of references, but the number of references may be counted by assigning a weight greater than 1 to the number of reads, which take longer.
[0071] Second Embodiment Next, the second embodiment will be described, focusing on the differences from the first embodiment described above. Note that the same reference numerals are used for configurations that are the same as or equivalent to those in the first embodiment described above. In the first embodiment described above, monitored variables were specified individually, but as the program size increases and the number of variables increases, it becomes difficult to specify them individually. Therefore, if a group of monitored variables can be specified, it becomes easier to create the program 23. This embodiment differs from the first embodiment in that monitored variables are specified by their attributes.
[0072] As shown in FIG. 14 , the receiving unit 13 according to this embodiment receives attribute information 52 that specifies the attributes of the monitored variables. FIG. 15 shows a list of examples of attribute information. FIG. 15 shows four character strings that specify the type of variable as attribute information 52. In detail, when the character string "ATTR_IO" is specified, a variable related to the input / output of the PLC 30 is specified as the monitored variable. When the character string "ATTR_POU" is specified, a variable that is a program organization unit is specified as the monitored variable. When the character string "ATTR_FB" is specified, a variable that is a function block is specified as the monitored variable. When the character string "ATTR_GLOBAL" is specified, a global variable is specified as the monitored variable.
[0073] 15 illustrates, as attribute information 52, four types of character strings that specify an attribute of being used in a conditional expression of a specific control syntax in the first language. In detail, when the character string "ATTR_IF_CONDITION" is specified, a variable used in the conditional expression of an IF statement is specified as a monitored variable. When the character string "ATTR_FOR_CONDITION" is specified, a variable used in the control expression of a FOR statement is specified as a monitored variable. When the character string "ATTR_WHILE_CONDITION" is specified, a variable used in the conditional expression of a WHILE statement is specified as a monitored variable. When the character string "ATTR_CASE_CONDITION" is specified, a variable used in the conditional expression of a CASE statement is specified as a monitored variable.
[0074] 15, the character string "ATTR_EXPRESSION" as attribute information 52 indicates that a variable used in an arithmetic expression different from the conditional expression of the control syntax is designated as a monitored variable. The character string "iBASE.*" indicates that a variable having a name starting with iBASE is designated as a monitored variable. In this way, having a name containing a specific character string may be designated as an attribute. The name of the monitored variable may be designated in any manner, for example, using a regular expression. Furthermore, the character strings exemplified in FIG. 15 may be combined in any manner.
[0075] As explained above, if it is possible to specify the variables to be monitored by their attributes, it is possible to flexibly adjust observability and execution speed even when many variables are used in the first source code 21.
[0076] Although the example of specifying the attributes of a variable has been described, the percentage of variables used in the first source code 21 may also be specified. For example, as illustrated in FIG. 16 , when the character string "50%" is specified, 50% of the variables included in the first source code 21 may be randomly selected and specified as monitored variables. Furthermore, when the character string "RANK_50%" is specified, the top 50% of the variables with the most references may be specified as monitored variables, among the variables whose reference counts have been counted, as in the first embodiment.
[0077] Third Embodiment. Next, the third embodiment will be described, focusing on the differences from the first embodiment. Note that the same or equivalent components as those in the first embodiment will be designated by the same reference numerals. As described in the first embodiment, the unshared memory 302 may be an auxiliary component, in which case the capacity of the unshared memory 302 may be relatively small. Here, if an attempt is made to obtain a program 23 with a fast execution speed, many of the variables will be stored in the unshared memory 302, which may overwhelm or exceed the capacity of the unshared memory 302. In other words, there is a trade-off between the execution speed and the amount of unshared memory 302 used. For this reason, it is desirable to be able to adjust the execution speed and the amount of unshared memory 302 used. Below, we will describe a form in which the amount of unshared memory 302 used is presented to the user for the second source code 22 obtained by translation.
[0078] As shown in FIG. 17 , the PLC program development environment 10 according to this embodiment includes a usage calculation unit 18 that calculates the usage of the non-shared memory 302 based on the second source code 22, and an information presentation unit 19 that presents information related to the calculated usage.
[0079] The usage calculation unit 18 is mainly realized by the processor 101. The usage calculation unit 18 calculates the sum of the sizes of variables included in the second source code 22, excluding the monitored variables. For example, the usage calculation unit 18 allocates 4 bytes for each int type variable, and 4 × (array size) bytes for an int type array. The usage calculation unit 18 corresponds to an example of usage calculation means that calculates the usage of the unshared memory 302 when the program 23 is executed.
[0080] The information presenting unit 19 is mainly realized by the output unit 105 or the communication unit 106. For example, the information presenting unit 19 may present the calculated usage amount as is, or may present the result of comparing this usage amount with a predetermined threshold. The threshold is, for example, an upper limit value corresponding to the capacity of the unshared memory 302. Furthermore, when the usage amount exceeds the threshold, the information presenting unit 19 may warn the user of this and present the memory capacity exceeding the threshold and a list of the sizes of each variable as support information to assist in reducing usage. The user who is presented with this support information can select a variable corresponding to the excess memory capacity and specify it as a new monitoring variable, thereby reducing the usage amount of the unshared memory 302 so that it does not exceed the threshold. Note that the support information presented by the information presenting unit 19 may be information showing a list of the sizes of each variable in descending order of size or in descending order of reference count. The information presenting unit 19 corresponds to an example of an information presenting means for presenting information related to the calculated usage amount.
[0081] As described above, by calculating the usage amount of the unshared memory 302 and presenting information regarding the usage amount, the user can adjust in advance the actual usage amount of the unshared memory 302. That is, the usage amount calculation unit 18 calculates the total size of the variables included in the second source code 22 whose values are stored in the unshared memory as the usage amount and presents it to the user, the reception unit 13 again accepts the designation of the monitored variable after the information presenting unit 19 presents the information regarding the usage amount, and the translation unit 12 translates the first source code 21 into the second source code 22 in accordance with the re-accepted designation.
[0082] Although the embodiments of the present disclosure have been described above, the present disclosure is not limited to the above-described embodiments.
[0083] For example, although it has been described that the shared memory 301 is shared with the controlled devices 40, all of the data in the shared memory 301 does not have to be shared with each of the controlled devices 40. The shared memory 301 may be a storage device in which data stored in at least a portion of its storage area is shared with the controlled devices 40.
[0084] Furthermore, although it has been explained that the program 23 is written to the shared memory 301 by the PLC program development environment 10, the program 23 written to the non-volatile memory (not shown) possessed by the PLC 30 by the PLC program development environment 10 may be loaded into the shared memory 301 by the control platform 34 at an appropriate timing.
[0085] Furthermore, the PLC program development environment 10 and the PLC 30 may constitute a translation system, which may be provided to the FA site.
[0086] Furthermore, although an example has been described in which the translation unit 12 sequentially converts the code components that make up the first source code 21, these code components may include other code components, and the translation unit 12 may analyze nested code components and convert them as appropriate.
[0087] Furthermore, although an example has been described in which the reference number of times used to calculate the index value is the reference number of times the shared memory 301 is referenced when all variables included in the second source code 22 are monitored variables, this is not limiting. The reference number may be any number of times the shared memory 301 is referenced when the program is executed when a variable included in the second source code 22 that satisfies a predetermined condition is a monitored variable. The predetermined condition may be, for example, that some value is actually stored when the program 21 is executed, that the variable is a local variable that can be set as a monitored variable, that the variable has a specific type, or any other condition.
[0088] In addition, the above-described embodiments may be combined in any manner. In particular, by combining the first and third embodiments and presenting information about usage together with the index value, the user can create the program 23 while taking into consideration the three trade-offs among observability, execution speed, and memory usage.
[0089] The functions of the PLC program development environment 10 according to the above-described embodiment can be realized by dedicated hardware or by a general computer system.
[0090] For example, by storing and distributing program P1 on a computer-readable recording medium such as a flexible disk, a CD-ROM (Compact Disk Read-Only Memory), a DVD (Digital Versatile Disk), or an MO (Magneto-Optical disk), and installing program P1 on a computer, a device that executes the above-mentioned processing can be configured.
[0091] Furthermore, the program P1 may be stored in a disk device of a server device on a communication network such as the Internet, and may be downloaded to a computer by superimposing it on a carrier wave, for example.
[0092] The above process can also be achieved by starting and executing the program P1 while transferring it via a network such as the Internet.
[0093] Furthermore, the above-described processing can also be achieved by executing all or part of program P1 on a server device, and executing program P1 while the computer sends and receives information about the processing via a communications network.
[0094] In addition, if the above-mentioned functions are realized by the OS or by the OS working together with an application, only the parts other than the OS may be stored on a medium and distributed, or may be downloaded to a computer.
[0095] Furthermore, the means for realizing the functions of the PLC program development environment 10 is not limited to software, and some or all of the functions may be realized by dedicated hardware or circuits.
[0096] The present disclosure allows various embodiments and modifications without departing from the broad spirit and scope of the present disclosure. Furthermore, the above-described embodiments are intended to explain the present disclosure and do not limit the scope of the present disclosure. In other words, the scope of the present disclosure is defined by the claims, not the embodiments. Various modifications made within the scope of the claims and the meaning of equivalent disclosures are considered to be within the scope of the present disclosure.
[0097] The present disclosure is suitable for developing control programs to be used in FA fields.
[0098] 10 PLC program development environment, 11 Acquisition unit, 12 Translation unit, 13 Reception unit, 14 Index value calculation unit, 15 Index value presentation unit, 16 Compiler, 17 Monitoring unit, 18 Usage calculation unit, 19 Information presentation unit, 101 Processor, 102 Main memory unit, 103 Auxiliary memory unit, 104 Input unit, 105 Output unit, 106 Communication unit, 107 Internal bus, 21 First source code, 211, 23, P1 Program, 22 Second source code, 30 PLC, 31 I / O terminal, 32 Processor, 33 OS, 34 Control platform, 301 Shared memory, 302 Non-shared memory, 40 Controlled device, 51 Monitoring variable list, 52 Attribute information, 61 to 64 Code.
Claims
1. A translation program for causing a translation device, which translates a first source code written in a first language of a program executed by a programmable controller to control a controlled device, into a second source code written in a second language different from the first language, to function as: a receiving means for receiving, from among variables contained in the first source code, a designation of a monitored variable to be assigned a value that is to be monitored when the program is executed; and a translation means for translating, from among variables contained in the first source code, a variable code relating to a shared memory variable whose value is stored in a shared memory owned by the programmable controller and shared with the controlled device, into a first conversion code relating to a variable whose value is stored in the shared memory if the shared memory variable is the monitored variable, and into a second conversion code relating to a variable whose value is stored in a non-shared memory owned by the programmable controller and different from the shared memory if the shared memory variable is different from the monitored variable, thereby translating the first source code into the second source code.
2. The translation program according to claim 1, wherein the first source code is source code of the program executed by the programmable controller without storing values of variables in the non-shared memory.
3. The translation program according to claim 1 or 2, wherein the first language is an instruction list, a ladder diagram, a function block diagram, a structured text or a sequence function chart.
4. A translation program as claimed in any one of claims 1 to 3, wherein the program of the second source code when the variable code is converted into the second conversion code has a shorter execution time when executed by the programmable controller than the program of the second source code when the variable code is converted into the first conversion code.
5. A translation program as described in any one of claims 1 to 4, further causing the translation device to function as an index value calculation means for calculating an index value corresponding to the length of execution time when the program of the second source code is executed, and an index value presentation means for presenting the calculated index value, wherein the receiving means re-accepts the designation of the monitored variable after the index value is presented by the index value presentation means, and the translation means translates the first source code into the second source code in accordance with the re-accepted designation.
6. The translation program according to claim 5, wherein said index value calculation means calculates said index value based on the number of times said shared memory is referenced when said program of said second source code is executed.
7. The translation program described in claim 6, wherein the index value calculation means calculates the index value based on a comparison between the number of times and a reference number of times the shared memory is referenced when the program is executed when a variable that satisfies a predetermined condition contained in the second source code is the monitored variable.
8. A translation program as described in any one of claims 1 to 7, further causing the translation device to function as: a usage calculation means for calculating the usage of the non-shared memory when the program of the second source code is executed; and an information presentation means for presenting information relating to the calculated usage; the receiving means re-accepts the designation of the monitored variable after the information is presented by the information presentation means; and the translation means translates the first source code into the second source code in accordance with the re-accepted designation.
9. The translation program according to claim 8, wherein the usage calculation means calculates the total size of variables included in the second source code whose values are stored in the non-shared memory as the usage, and the information presentation means presents the information to assist in reducing the usage.
10. The translation program according to any one of claims 1 to 9, wherein the accepting means accepts a list of names of variables individually designated as the monitored variables.
11. A translation program as described in any one of claims 1 to 9, wherein the receiving means receives specification of attributes that the variable to be the monitored variable should have, and the attributes are a type of variable that is an input / output of the programmable controller, a global variable, a program organization unit or a function block, being used in a conditional expression of a specific control syntax in the first language, being used in an arithmetic expression other than the conditional expression, or having a name that includes a specific character string.
12. A translation device that translates a first source code written in a first language of a program executed by a programmable controller to control a controlled device, into a second source code written in a second language different from the first language, comprising: a receiving means for receiving, from among variables included in the first source code, a designation of a monitoring variable to be assigned a value that is to be monitored when the program is executed; and a translation means for translating, from among the first source code, a variable code relating to a shared memory variable whose value is stored in a shared memory owned by the programmable controller and shared with the controlled device, into a first conversion code relating to a variable whose value is stored in the shared memory if the shared memory variable is the monitoring variable, and into a second conversion code relating to a variable whose value is stored in a non-shared memory owned by the programmable controller and different from the shared memory if the shared memory variable is different from the monitoring variable, thereby translating the first source code into the second source code.
13. A translation method executed by a translation device that translates first source code written in a first language of a program executed by a programmable controller to control a controlled device, into second source code written in a second language different from the first language, comprising: a receiving means that receives, from among variables included in the first source code, a designation of a monitoring variable to be assigned a value that is to be monitored when the program is executed; and a translation means that translates, from among variables included in the first source code, a variable code relating to a shared memory variable whose value is stored in a shared memory owned by the programmable controller and shared with the controlled device, into a first conversion code relating to a variable whose value is stored in the shared memory, if the shared memory variable is the monitoring variable, and into a second conversion code relating to a variable whose value is stored in a non-shared memory owned by the programmable controller and different from the shared memory, thereby translating the first source code into the second source code.
Citation Information
Patent Citations
Ladder program execution device
JP2008015826A
Application monitor system and method
US7921412B1
Cited By
Program control method and device of programmable logic controller and computer equipment
CN120742776A