Translation program, translation device, and translation method
The sequential control program is translated from a first language to a general high-level language by a translation device, which distinguishes between shared and non-shared memory variables, solves the problems of machine type dependence and observation requirements, and realizes the interoperability of the program between different controllers and optimizes the execution speed and observability.
Patent Information
- Application Number
- CN202380100120.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-20
- Publication Date
- 2026-02-13
AI Technical Summary
In the existing technology, the programming languages used for sequential control have high machine type dependence, which makes it impossible for programs to communicate with each other between different programmable controllers, and the requirement to observe the program's execution actions leads to complicated translation and rewriting work.
The translation device translates the program written in the first language for sequence control into a general high-level language, distinguishes between shared memory variables and non-shared memory variables, adjusts the execution and observability of the program according to the specified monitoring variables, and provides index value calculations to optimize the translation results.
It reduces the workload of program translation, enables interoperability between different programmable controllers, simplifies the requirements for observing program execution actions, and improves program execution speed and observability.
Smart Images

Figure CN121532746A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to translation programs, translation devices, and translation methods. Background Technology
[0002] In Factory Automation (FA), sequential control of various instruments is implemented in the field. The programming languages used to define this sequential control were developed by programmable logic controller (PLC) suppliers after the advent of PLCs, resulting in numerous independent developments of various programming languages. Therefore, the IEC (International Electrotechnical Commission) published IEC 61131-3, which defines five programming languages for sequential control.
[0003] However, programs written in programming languages used for sequential control still tend to be highly dependent on specific machine types. Specifically, a program that can be executed by a programmable logic controller (PLC) from one vendor may not be executed by a control device from another vendor, and in most cases, reprogramming is necessary.
[0004] Therefore, a technique for obtaining machine-independent programs has been proposed (for example, see Patent Document 1). Patent Document 1 describes a program generation apparatus that translates a program written in a sequential command language into a program written in a high-level language for general-purpose computers. According to this apparatus, a machine-independent program that performs the same function as a program written in a sequential command language can be obtained.
[0005] Patent Document 1: Japanese Patent Application Publication No. 07-295612 Summary of the Invention
[0006] However, programs translated using methods like those in Patent Document 1 sometimes fail to meet the on-site requirements for debugging and future development, such as observing the behavior of the program executing in the programmable controller. Therefore, on-site operators must repeatedly perform this translation trial by rewriting the translated program using a sequence command language until a program that meets the requirements is obtained, potentially leading to cumbersome work. Furthermore, even if a program that meets the requirements is temporarily created, rewriting the program using a sequence command language may still occur when new requirements arise for observing other behaviors. Therefore, there is room to reduce the workload of translating programs used for sequence control to obtain new programs that meet the requirements for observing their behavior.
[0007] The present invention was made in view of the above circumstances, and its purpose is to reduce the workload of translating the program used for sequence control to obtain a new program that meets the requirement of observing its behavior.
[0008] To achieve the above objectives, the translation program of the present invention enables a translation device to function as both a receiving unit and a translation unit. This translation device translates a first source code, written in a first language, into a second source code, written in a second language different from the first language, which is executed by a programmable controller (PLC) to control a controlled instrument. The receiving unit receives the specification of a monitoring variable (i.e., a value of the monitoring object) among the variables contained in the first source code and substituted into the monitoring object during program execution. The translation unit transforms the variable codes in the first source code related to shared memory variables (which store values in the shared memory of the PLC and the controlled instrument) into first transformation codes related to variables stored in the shared memory if the shared memory variable is a monitoring variable, and into second transformation codes related to variables stored in non-shared memory (which are different from the shared memory of the PLC) if the shared memory variable is different from the monitoring variable. Thus, the first source code is translated into the second source code.
[0009] The effects of the invention
[0010] According to the present invention, the workload of translating the sequence control program to obtain a new program that meets the requirement of observing its behavior can be reduced. Attached Figure Description
[0011] Figure 1 This is a diagram showing an outline of the PLC (Programmable Logic Controller) involved in Implementation Method 1.
[0012] Figure 2 This is the first diagram showing the execution of the program involved in the scale.
[0013] Figure 3 This is the second diagram showing the execution of the program involved in the scale.
[0014] Figure 4 This is a diagram showing the hardware structure of the PLC program development environment involved in Implementation Method 1.
[0015] Figure 5 This is a diagram showing the functional structure of the PLC program development environment involved in Implementation Method 1.
[0016] Figure 6 This is a diagram illustrating the first example of the translation involved in Implementation Method 1.
[0017] Figure 7 This is a diagram illustrating the second example of the translation involved in Implementation Method 1.
[0018] Figure 8This is a diagram showing an example of a list of monitoring variables involved in Implementation 1.
[0019] Figure 9 This is a diagram illustrating an example of the description of the second source code involved in Implementation Method 1.
[0020] Figure 10 This is a diagram illustrating the first example of a translation involving a specified monitoring variable in Implementation 1.
[0021] Figure 11 This is a diagram illustrating a second example of the translation involving the specified monitoring variables in Implementation 1.
[0022] Figure 12 This is a flowchart illustrating the translation process involved in Implementation Method 1.
[0023] Figure 13 This is a flowchart illustrating the index value calculation process involved in Implementation Method 1.
[0024] Figure 14 This is a diagram showing the functional structure of the PLC program development environment involved in Implementation Method 2.
[0025] Figure 15 This is a diagram representing the attribute information involved in Implementation Method 2.
[0026] Figure 16 This is a diagram representing an example of specifying the watch variable in a variant example.
[0027] Figure 17 This is a diagram showing the functional structure of the PLC program development environment involved in Implementation Method 3. Detailed Implementation
[0028] The PLC program development environment involved in the embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0029] Implementation Method 1
[0030] like Figure 1As shown, the PLC program development environment 10 involved in this embodiment is equivalent to an auxiliary terminal connected to the programmable controller, i.e., PLC 30, to assist the user in developing the program 23 used to control the controlled instrument 40 by the PLC 30. Specifically, the PLC program development environment 10 is equivalent to an example of a translation device that translates first source code 21 written in a first language for sequential control into second source code 22 written in a general-purpose high-level language different from the first language, and writes the program 23 obtained by compiling the second source code 22 into the non-shared memory 302 of the PLC 30. When the program 23 is executed, the values of the monitoring variables used by the program 23 are stored in the shared memory 301. The shared memory 301 is a memory shared with the controlled instrument 40, and in most cases, tools are provided for obtaining this data from the outside in real time. Therefore, if such tools are used, the actions of the program 23 can be easily observed by monitoring the values of the monitoring variables. Figure 1 The image shows the monitoring of the value of the monitored variable by the monitoring unit 17 of the PLC program development environment 10, which serves as an auxiliary terminal.
[0031] With many monitored variables, the actions of program 23 can be observed in detail, but the process of program 23 accessing shared memory 301 from non-shared memory 302 also increases, thus slowing down the execution speed of program 23. On the other hand, with fewer monitored variables, the scope of observation regarding the actions of program 23 becomes narrower, but the execution speed is faster. Hereinafter, the property of a program that allows for the observation of its actions during execution is sometimes labeled as observability. As mentioned above, there is a trade-off between observability and execution speed. Users of the PLC program development environment 10 can adjust observability and execution speed appropriately by specifying the monitored variables to meet their requirements.
[0032] <Execution of the program implemented by PLC 30>
[0033] The PLC 30 is a control device used in the factory to control the controlled instrument 40. Through the control of the PLC 30, various processes, such as the processing and inspection of workpieces transported on the production line, can be implemented. Furthermore, in... Figure 1The diagram typically shows a single controlled instrument 40, but control is usually achieved through the coordinated operation of multiple controlled instruments 40. For example, sensing results obtained by sensors, i.e., the controlled instrument 40, are input to a PLC 30. Based on this input, operating commands determined by the program are output from the PLC 30 to the robot, i.e., the controlled instrument 40, thereby performing workpiece processing. The PLC 30 and the controlled instrument 40 are connected via signal lines that transmit current or voltage signals, or via a network such as a field network or LAN (Local Area Network).
[0034] In addition to the shared memory 301 and the non-shared memory 302 mentioned above, the PLC 30 has: an I / O (Input / Output) terminal 31 for inputting signals from the controlled instrument 40 or outputting signals to the controlled instrument 40; a processor 32; an OS (Operating System) 33; and a control platform 34 that operates on the OS 33.
[0035] Shared memory 301 and non-shared memory 302 are each equivalent to RAM (Random Access Memory). Processor 32 includes a CPU (Central Processing Unit) or MPU (Micro-Processing Unit) as processing circuitry to execute programs.
[0036] The control platform 34 serves as the foundation for the control implemented by the PLC 30 within the application software that operates on the OS 33. Specifically, the control platform 34 calls and executes other programs at pre-defined time intervals and manages the shared memory 301 that stores the execution results. Multiple programs can be called by the control platform 34. Figure 1 There can be multiple programs 23 shown. The timing of calling the program can also be different for each program, such as a specific time, a pre-defined period, or a timing that generates a specific event.
[0037] In addition to the execution results described above, the shared memory 301 also stores input / output information that is periodically synchronized with the status of the control platform 34 and I / O terminals 31. Thus, signals input from the controlled instrument 40 to the PLC 30 are reflected in the shared memory 301, and data in the shared memory 301 is reflected in signals output from the PLC 30 to the controlled instrument 40. Furthermore, the entire program stored in the PLC 30 can generally access the data in the shared memory 301 via the control platform 34; therefore, the data in the shared memory 301 is processed as global data between multiple programs. The shared memory 301 is a standard structural element for performing the basic functions of the PLC 30, and its capacity is the specified value listed in the PLC 30 catalog.
[0038] In addition, without passing Figure 1 The translation unit 12 shown translates the first source code 21 into the second source code 22. When the program 211 executing the first source code 21 is in the shared memory 301, as shown... Figure 2 As shown, the program 211 is loaded, and the values of all variables contained in the first source code 21 are also stored in the shared memory 301. Furthermore, the variables whose values are stored in the shared memory 301 are also referred to as devices or tags.
[0039] The first language used to describe the first source code 21 is a programming language used to enable the PLC 30 to perform sequential control, such as an instruction list, ladder diagram, function block diagram, structure text, or sequence function chart as specified in IEC 61131-3. Hereinafter, structure text will sometimes be appropriately labeled as ST (Structured Text) language, and instruction lists as IL (Instruction List) language.
[0040] Figure 2 The example is comparable to executing a traditional program via PLC 30. In this method, the values of all variables can be observed, but the first source code 21 and program 211 have a high machine dependency. According to... Figure 2 It can be seen that the first source code 21 is equivalent to an example of the source code of program 211 executed by PLC 30 without storing the values of variables in non-shared memory 302.
[0041] On the other hand, even though the first source code 21 is translated into the second source code 22, if no watch variable is set at this time, such as Figure 3 As shown, program 23 is written to non-shared memory 302 and executed, and the values of the variables contained in the second source code 22 are also stored in non-shared memory 302.
[0042] Figure 3 The example corresponds to the technology in Patent Document 1 mentioned above. Figure 3 In the example, the second language used to describe the second source code 22 is a typical high-level language. When program 23 is executed on a general-purpose processor, machine dependency is low, but observability is also low. Here, the high-level language is, for example, C, and program 23 is equivalent to object code compiled from the second source code 22. However, the second language is not limited to C and can be other languages.
[0043] Furthermore, the general-purpose processor of the execution program 23 can be the same as or different from the processor 32 of the execution control platform 34. Figure 1 , 3 In this example, only one processor 32 is shown, but the PLC 30 may also have a separate processor 32 for enabling the control platform 34 to operate, and a general-purpose processor 32 for executing program 23. Furthermore, the processor 32 executing the control platform 34 may be a dedicated processor for the PLC 30 or a general-purpose processor.
[0044] Regarding programs written in typical high-level languages, due to the accumulation of techniques for high-speed execution by general-purpose processors, therefore... Figure 3 The program 23 shown can be executed at high speed. To ensure the execution speed of program 23, it is preferable that the non-shared memory 302 on which program 23 is loaded is a general-purpose processor-specific memory, different from the shared memory 301 managed by the control platform 34. In cases where the functionality of the PLC 30 executing the program, implemented by a general-purpose processor, is handled as an external or optional feature by its supplier, the non-shared memory 302 can become an auxiliary structural element in the PLC 30, and therefore is installed as a different storage device from the shared memory 301.
[0045] Furthermore, to emphasize that the values of the variables processed by program 23 are stored in non-shared memory 302, Figure 3 The values stored in shared memory 301 are omitted from the text. In fact, data in shared memory 301 is also stored for program 23 to be called and executed by control platform 34. Such data includes, for example, input data for program 23, execution results of program 23, input / output data of PLC 30 processed by program 23, and global data shared by program 23 with other programs. This data can be stored as variable values in shared memory 301.
[0046] However, regarding the intermediate data and values of local variables processed within program 23, Figure 3 In the example, it is stored in non-shared memory 302. In contrast, such as... Figure 1As shown, in order to observe the behavior of Program 23 during execution, the PLC program development environment 10 according to this embodiment generates the second source code 22, and the second source code 22 stores the values of at least a part of the monitored variables among the variables processed by Program 23 in the shared memory 301. That is, it can be said that the PLC program development environment 10 appropriately changes the storage destination of the values of the variables stored in the non-shared memory 302 in the example of Figure 3 to the shared memory 301 shown in Figure 1 .
[0047] <Hardware Structure of PLC Program Development Environment 10>
[0048] The PLC program development environment 10 is an industrial personal computer (PC) and is connected to the PLC 30 via a communication line such as a USB (Universal Serial Bus) cable or the above network. The PLC program development environment 10 is composed of hardware elements for functioning as a computer. Specifically, as shown in Figure 4 , the PLC program development environment 10 includes a processor 101, a main storage unit 102, an auxiliary storage unit 103, an input unit 104, an output unit 105, and a communication unit 106. The main storage unit 102, the auxiliary storage 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.
[0049] The processor 101 includes a CPU or MPU as a processing circuit. The processor 101 realizes various functions by executing the program P1 stored in the auxiliary storage unit 103 and executes the processing described later. The program P is equivalent to a so-called engineering design tool and is an example of a translation program that makes the PLC program development environment 10 function as described later.
[0050] The main storage unit 102 includes a RAM. The program P1 is loaded from the auxiliary storage unit 103 into the main storage unit 102. Moreover, the main storage unit 102 is used as the working area of the processor 101.
[0051] The auxiliary storage unit 103 includes non-volatile memories represented by 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 for the processing of the processor 101. The auxiliary storage unit 103 supplies the data used by the processor 101 to the processor 101 according to the instruction of the processor 101. In addition, the auxiliary storage unit 103 stores the data supplied from the processor 101.
[0052] The input unit 104 includes input devices represented by hardware switches, input keys, keyboards, and pointing devices. The input unit 104 acquires information input by the user and notifies the acquired information to the processor 101.
[0053] The output unit 105 includes output devices represented by LEDs (Light Emitting Diodes), LCDs (Liquid Crystal Displays), and speakers. The output unit 105 presents various information to the user according to the instructions of the processor 101.
[0054] The communication unit 106 includes a communication interface circuit for communicating with external devices. The communication unit 106 receives a signal from the outside and outputs the data indicated by the signal to the processor 101. In addition, the communication unit 106 transmits a signal representing the data output from the processor 101 to an external device.
[0055] <Functions of the PLC program development environment 10>
[0056] Through the cooperation of the above hardware structure, the PLC program development environment 10 functions as an engineering design tool, which is a development environment for the program executed by the PLC 30. Through this engineering design tool, a function of translating the first source code 21 into the second source code 22 is provided. The PLC program development environment 10 corresponds to an example of a translation device that translates the first source code described in the first language of a program for a programmable controller to control a controlled instrument into the second source code described in a second language different from the first language. As Figure 5 shown, the PLC program development environment 10 has, as its functions: an acquisition unit 11 that acquires the first source code 21; a translation unit 12 that translates the first source code 21 into the second source code 22; a reception unit 13 that receives the setting of information required for the translation of the first source code 21; an index value calculation unit 14 that calculates an index value representing 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 is used to monitor the values of monitored variables. Although the translation unit 12, the compiler 16, and the monitoring unit 17 are shown in Figure 1 this figure, their functions will be described in more detail below.
[0057] The acquisition unit 11 is mainly implemented by the input unit 104 or the communication unit 106. The acquisition unit 11 can acquire the first source code 21 created by the user using the engineering design tool, or can read out the first source code 21 stored at the address specified by the user.
[0058] The translation unit 12 is mainly implemented by the processor 101. The translation unit 12 parses the first source code 21, and transforms the code components constituting the first source code 21 into code components in the second language corresponding to the code components, thereby generating the second source code 22. Translation refers to transforming the first source code into a second source code in another format, such that the PLC 30 executing the program can perform the same function.
[0059] exist Figure 6 , 7 Examples of translations performed by the translation department 12 are shown below. Figure 6 In the example, the IF statement in Language 1 (ST) is transformed into an if statement in Language 2 (C). Additionally, in... Figure 7 In the example, the FOR statement in ST language is transformed into a for statement in C language. At this time, the variables COND, VAR0, and ITR contained in the first source code 21 are transformed into the variables Cond, Var0, and Itr contained in the second source code 22, respectively. Figure 6 , 7 The variables in the second source code 22 shown are not monitor variables; their values are stored in non-shared memory 302. That is, according to... Figure 6 , 7 Source code 22, generated with Figure 3 Program 23 is executed in the manner shown.
[0060] The receiving unit 13 is mainly implemented by the input unit 104 or the communication unit 106. The receiving unit 13 receives the designations of variables in the first source code 21 that should be set as monitoring variables during translation. The receiving unit 13 can receive a monitoring variable list 51 input by the user, or it can read the monitoring variable list 51 stored at an address specified by the user. Figure 8 An example of the monitoring variable list 51 is shown below. Based on this monitoring variable list 51, Figure 6 , 7 In the first source code 21 shown, the values of the variables COND and VAR0 are set as monitoring objects. The receiving unit 13 is equivalent to an example of a receiving unit, which receives the designation of the monitoring variables, i.e., the monitoring objects, when the program is executed, from the variables contained in the first source code.
[0061] exist Figure 9 The image shows an example of second-language code generated corresponding to the settings of the watch variables. Figure 9The code 61, "Var0 = Var1 + 100;", indicates that, without setting a watch variable, the sum of the value of variable Var1 and 100 is substituted into variable Var0. The code 62, "Var0 = API_PF_READ(VAR1) + 100;", indicates that in an equivalent operation to code 61, VAR1 is set as a watch variable, and the value of this watch variable stored in shared memory 301 is read using a function like "API_PF_READ". Furthermore, variable Var1 corresponds to variable VAR1.
[0062] in addition, Figure 9 The code 63, "API_PF_WRITE(VAR0, Var1+100);", indicates that in an operation equivalent to code 61, VAR0 is set as a watch variable, and the result is written using a function like "API_PF_WRITE". Additionally, code 64 indicates that both VAR0 and VAR1 are set as watch variables, and the same operation as code 61 is performed. Figure 9 The functions shown are provided as the API (Application Programming Interface) of the control platform 34.
[0063] exist Figure 10 The use of Figure 9 Such a function will Figure 8 The list of monitored variables 51 is applied to Figure 6 An example of translating an IF statement. Figure 10 In the middle, bold text indicates from Figure 6 The second part of the source code 22 has been changed. For example, the notation used to read the value of the watch variable COND is set to "API_PF_READ(COND)", and the notation used to write the value 100 to the watch variable VAR0 is set to "API_PF_WRITE(VAR0, 100)". Additionally, in Figure 11 shown in the Figure 8 The list of monitored variables 51 is applied to Figure 7 Examples of translations based on FOR statements.
[0064] Return to Figure 5 The index calculation unit 14 is mainly implemented by the processor 101. The index calculation unit 14 calculates the index value of the execution speed when executing the second source code 22 generated according to the specification of the monitoring variables received by the receiving unit 13. The method for calculating this index value will be described later.
[0065] The indicator value prompting unit 15 is mainly implemented by the output unit 105. The indicator value prompting unit 15 informs the user of the calculated indicator value, thereby indicating to what extent the execution speed is accelerated by specifying the monitoring variable provided by the user, and providing judgment material related to the trade-off between user feedback and execution speed. The user, having received the indicator value prompt, translates the first source code 21 by re-specifying the monitoring variable, thereby adjusting both observation and execution speed. The indicator value prompting unit 15 is equivalent to an example of an indicator value prompting unit that prompts calculated indicator values.
[0066] Compiler 16 is primarily implemented by processor 101. When the second language is C, compiler 16 is, for example, gcc (GNU Compiler Collection) or Clang.
[0067] The monitoring unit 17 is mainly implemented through the cooperation of the processor 101, the communication unit 106, and the output unit 105. The monitoring unit 17 reads the values of the monitoring variables stored in the shared memory 301 and displays them to the user.
[0068] Translation Processing
[0069] Next, use Figures 12-13 The translation process performed by the PLC program development environment 10 will be described. The translation process is equivalent to an example of a translation method performed by a translation device.
[0070] In translation processing, such as Figure 12 As shown, the acquisition unit 11 acquires the first source code 21 (step S1), and the receiving unit 13 receives the specification of the monitoring variable (step S2). Then, the translation unit 12 parses the words and grammar of the first source code 21 (step S3). Specifically, the translation unit 12 extracts code components from the first source code 21 that can be transformed into a second language by decomposing the first source code 21 into words and sentences and parsing the meaning of the sentences from the arrangement of words and sentences.
[0071] Next, the translation unit 12 selects one unselected code component from 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 transforms the selected code component into the corresponding second language code (step S6), and the process proceeds to step S10. For example, as... Figure 6 As shown, the translation unit 12 transforms the code component "ELSEIF" in the first source code 21 into code such as "}else if (".
[0072] On the other hand, if the selected code component is determined to be a variable (step S5; Yes), the translation unit 12 determines whether the code component as a variable is designated as a monitoring variable (step S7). This code component corresponds to an example of variable code regarding shared memory variables. If the code component is designated as a monitoring variable (step S7; Yes), the translation unit 12 transforms the code component into code referring to shared memory 301 (step S8). Specifically, as follows... Figure 9 As shown, the translation unit 12 uses the API of the control platform 34 to transform the code components into descriptions for accessing the shared memory 301. The code obtained through the transformation in step S8 is equivalent to an example of the first transformed code. Afterwards, the processing executed by the PLC program development environment 10 is transferred to step S10.
[0073] On the other hand, if the code component that is a variable is not designated as a monitoring variable (step S7; No), the translation unit 12 transforms the code component into code that refers to the non-shared memory 302 (step S9). Specifically, as Figure 9 As shown, without utilizing the API of the control platform 34, the translation unit 12 transforms the code components into a description in the second language that only refers to variables. The code obtained through the transformation in step S9 is equivalent to an example of the second transformed code. As mentioned above, if program 23 refers to the monitoring variables of the shared memory 301, the execution speed is slow. Therefore, compared with the case where the variable code of the first source code 21 is transformed into the second transformed code, the execution time of program 23 of the second source code 22 executed by the PLC 30 is shorter when it is transformed into the first transformed code.
[0074] Next, the translation unit 12 determines whether all code components have been selected (step S10). If it is determined that not all code components have been selected (step S10; No), the translation unit 12 repeats the process after step S4. Thus, the code components constituting the first source code 21 are selected sequentially from the beginning of the first source code 21 and transformed into code in the second language.
[0075] If it is determined that all code components have been selected (step S10; Yes), the translation unit 12 combines the transformed code to generate the second source code 22 (step S11). Here, if the order of the code components described by the first language and the second language is different, the translation unit 12 appropriately changes the order to combine the code components.
[0076] Next, the index value calculation unit 14 performs index value calculation processing (step S12) to calculate the index values of the second source code 22 generated in step S11. In the index value calculation processing, as... Figure 13As shown, the index value calculation unit 14 counts the number of references for each variable (step S121). For example, for... Figure 10 The second source code 22 shown counts the reference count of variable COND as 1 and the reference count of variable VAR0 as 1. Additionally, regarding... Figure 11 The second source code 22 shown counts the reference count of variable Itr as 10 times due to repeated processing. For variable VAR0, since each of the 10 repeated processes includes one read and one write operation, the reference count is 20 times.
[0077] Next, the indicator value calculation unit 14 sets B as the total number of references for all variables and C as the total number of references for the monitored variables, and calculates the value of indicator value A using the following formula (1) (step S122).
[0078] A = C / B × 100 (1)
[0079] The metric value A is 100 when all variables are set as monitored variables. Compared to this case, a smaller relative value indicates faster execution. This metric value A corresponds to the execution time. For example, in... Figure 10 In the example, the indicator value is calculated as 100, for Figure 10 For example, instead of using a function like "API_PF_WRITE", it would be like... Figure 6 When the variable Var0 is shown, the index value is calculated to be 40. Afterwards, the processing executed by the PLC program development environment 10... Figure 13 The index value calculation and processing is returned to Figure 12 Translation processing. The index value calculation unit 14 is equivalent to an example of an index value calculation unit that calculates index values that correspond to the execution time length when the program executing the second source code is executed.
[0080] Return to Figure 12 After the index value calculation process in step S12, the index value prompting unit 15 prompts the user with the index value calculated in step S12 (step S13). The prompting by the index value prompting unit 15 can be displayed on the screen, played as a reading, or output to the UI (User Interface) terminal via the network.
[0081] Next, the receiving unit 13 determines whether there has been a change in the monitored variable (step S14). Specifically, the receiving unit 13 determines whether there is a new monitored variable that is different from the monitored variable received in the previous step S2. If at least one of the following occurs: a variable that was not a monitored variable in the previous step is changed to a monitored variable, or a previously monitored variable is removed from the monitored object, the determination in step S14 is affirmative.
[0082] If a change in the monitored variable is detected (step S14; Yes), the PLC program development environment 10 repeats the process following step S2. This allows users to easily investigate the balance between acceptable observability and execution speed while simultaneously verifying the indicator values and changing the monitored variable. For example, regarding... Figure 10 In source code 22, if the variable VAR0 is removed from the monitored object, the indicator value will be confirmed to have improved to 50. Additionally, regarding... Figure 11 In the second source code 22, if the variable ITR corresponding to the variable Itr is set as the monitoring variable and the variable VAR0 is removed from the monitoring object, it will be confirmed that the indicator value has been improved to 33.3.
[0083] On the other hand, if there is no change in the monitored variable, and the user determines that the second source code 22 has been completed and inputs a write instruction (step S14; No), the second source code 22 is compiled by the compiler 16 to generate program 23, and the generated program 23 is written into PLC 30 (step S15), and the translation process ends.
[0084] <Effect>
[0085] As explained above, the receiving unit 13 receives the designation of the monitored variable, and the translation unit 12, for the variable-related code components in the first source code 21, converts them into code referencing shared memory 301 if the variable is not a monitored variable, and converts them into code referencing non-shared memory 302 if the variable is different from the monitored variable. Therefore, by changing the designation of the monitored variable, the user can adjust the execution speed and observability of program 23. Thus, the workload of translating the program used for sequence control to obtain a new program that meets the requirement of observing its behavior can be reduced.
[0086] like Figure 3As shown, when employing the technique of simply translating the first source code 21, written in the first language for sequence control, into the second source code 22, written in the second language, it is considered that during the creation stage of the first source code 21, the variable whose value should be set as the monitoring object is set as a global variable stored in the shared memory 301. However, creating such a first source code 21 is a cumbersome task. In contrast, according to the PLC program development environment 10 according to this embodiment, the user can easily obtain program 23 by changing only the specification of the monitoring variable without changing the first source code 21.
[0087] Translation unit 12 is equivalent to an example of a translation unit. This translation unit transforms the variable code in the first source code, which is related to the shared memory variable whose value is stored in the shared memory of the programmable controller and shared with the controlled instrument, into a first transformation code related to the variable whose value is stored in the shared memory when the shared memory variable is a monitoring variable. When the shared memory variable is different from the monitoring variable, it is transformed into a second transformation code related to the variable whose value is stored in a non-shared memory that is different from the shared memory of the programmable controller. In this way, the first source code is translated into the second source code.
[0088] Furthermore, after the user is prompted with the index value calculated by the index value calculation unit 14, the receiving unit 13 receives the specification of the monitoring variable again, and the translation unit 12 translates the first source code 21 into the second source code 22 according to the newly received specification. Thus, the user can quantitatively evaluate the execution speed of the program 23 while setting appropriate monitoring variables.
[0089] The aforementioned metric values are calculated based on the number of references to shared memory 301 during the execution of program 23. Specifically, the metric values are calculated by comparing this number of references with a baseline number of references to shared memory 301 during the execution of program 23 when all variables contained in the second source code 22 are monitoring variables. Thus, metric values corresponding to the specified execution time with or without monitoring variables can be obtained.
[0090] In addition, the receiving unit 13 receives a list of names of variables that are individually specified as monitoring variables. This allows the user to flexibly specify the monitoring variables.
[0091] In addition, Figure 11In the illustrated iterative process, since the number of repetitions is specified as 10, the reference number can be easily calculated. However, it is also conceivable that the number of repetitions is specified by the value of a variable. In such a case, for example, an estimated value for the number of repetitions can be used. The estimated value for the number of repetitions can be, for example, a pre-defined fixed value, a value obtained by prompting the user for input, or a value calculated by other methods.
[0092] In addition, I also thought of... Figure 10 In the example if statement, the variable VAR0 is referenced in any processing according to the conditional branch, but the referenced variable differs depending on the branch target. In such cases, for example, the average number of references to each branch target can be calculated by dividing the sum of the references to each branch target by the number of branches. Furthermore, the branches can be weighted when calculating the average. This weighting can also be specified by the user.
[0093] Additionally, the reference count illustrates an example where reads and writes are treated as equal, but it is also possible to add a weight greater than 1 to the number of reads that take longer to count the reference count.
[0094] Implementation Method 2
[0095] Next, Embodiment 2 will be described focusing on its differences from Embodiment 1 described above. Furthermore, structures that are the same as or equivalent to those in Embodiment 1 will be represented using the same reference numerals. In Embodiment 1, the monitoring variables were specified individually, but if the program is large and has many variables, it is difficult to specify them individually. Therefore, if a group of monitoring variables can be specified, the creation of program 23 becomes easier. The difference between this embodiment and Embodiment 1 is that the monitoring variables are specified through their attributes.
[0096] like Figure 14 As shown, the receiving unit 13 in this embodiment receives attribute information 52 of the attribute of a specified monitored variable. In Figure 15 This section provides an overview of examples of attribute information. Figure 15 In attribute information 52, four strings are listed to specify the category of variables. Specifically, when a string such as "ATTR_IO" is specified, variables related to the input and output of PLC 30 are designated as monitor variables. Additionally, when a string such as "ATTR_POU" is specified, variables that are program organization units are designated as monitor variables. When a string such as "ATTR_FB" is specified, variables that are functional modules are designated as monitor variables. When a string such as "ATTR_GLOBAL" is specified, global variables are designated as monitor variables.
[0097] In addition, Figure 15 In section 52, as attribute information, four strings are shown that specify such attributes in conditionals used in language-specific control syntax. Specifically, when the string "ATTR_IF_CONDITION" is specified, the variable used in the conditional expression of the IF statement is designated as a watch variable. When the string "ATTR_FOR_CONDITION" is specified, the variable used in the control expression of the FOR statement is designated as a watch variable. When the string "ATTR_WHILE_CONDITION" is specified, the variable used in the conditional expression of the WHILE statement is designated as a watch variable. When the string "ATTR_CASE_CONDITION" is specified, the variable used in the conditional expression of the CASE statement is designated as a watch variable.
[0098] In addition, Figure 15 As shown, variables used in expressions different from the conditional expressions in the control syntax are designated as monitor variables via the string "ATTR_EXPRESSION" as attribute information 52. Additionally, it is shown that via "iBASE..." Variables with names starting with iBASE, such as those containing the string "iBASE", are designated as watch variables. As mentioned above, they can also be specified as attributes containing a specific string. The method for specifying watch variable names is arbitrary; for example, they can be specified using regular expressions. Furthermore, they can also be... Figure 15 The example shows any combination of strings.
[0099] As explained above, if the variables that should be monitored can be specified through their properties, then even when multiple variables are used in the first source code 21, the observability and execution speed can be flexibly adjusted.
[0100] Furthermore, examples of specifying the attributes of variables have been illustrated, but the ratio of variables used in source code 21 in section 1 can also be specified. For example, it can also be as follows: Figure 16 As exemplified, when a string such as "50%" is specified, 50% of the variables contained in the first source code 21 are randomly selected and designated as monitoring variables. Alternatively, when a string such as "RANK_50%" is specified, the top 50% of the variables whose reference counts have been counted, in the same manner as in Embodiment 1 described above, are designated as monitoring variables.
[0101] Implementation Method 3
[0102] Next, Embodiment 3 will be described focusing on its differences from Embodiment 1 described above. Furthermore, equivalent reference numerals will be used for structures that are the same as or equivalent to those in Embodiment 1 described above. As explained in Embodiment 1, there is a case where non-shared memory 302 is an auxiliary structural element, in which case the capacity of non-shared memory 302 may be relatively small. Here, if a program 23 with a fast execution speed is desired, more of this variable will be stored in non-shared memory 302, potentially straining or exceeding the capacity of non-shared memory 302. That is, it can be said that there is a trade-off between execution speed and the amount of non-shared memory 302 used. Therefore, it is preferable to be able to adjust the execution speed and the amount of non-shared memory 302 used. Next, the method of prompting the user about the amount of non-shared memory 302 used for the second source code 22 obtained through translation will be described.
[0103] like Figure 17 As shown, the PLC program development environment 10 according to this embodiment includes: a usage calculation unit 18, which calculates the usage of the non-shared memory 302 based on the second source code 22; and an information prompting unit 19, which prompts information related to the calculated usage.
[0104] Usage calculation unit 18 is primarily implemented by processor 101. Usage calculation unit 18 calculates the sum of the sizes of variables other than the monitored variables contained in the second source code 22. For example, usage calculation unit 18 counts 4 bytes for each int type variable and 4 × (arrangement size) bytes for an int type array. Usage calculation unit 18 is comparable to an example of a usage calculation unit that calculates the usage of non-shared memory 302 during program execution 23.
[0105] The information prompting unit 19 is mainly implemented by the output unit 105 or the communication unit 106. The information prompting unit 19 can, for example, directly prompt the calculated usage amount, or it can prompt the comparison result of the usage amount with a predetermined threshold. The threshold is, for example, an upper limit value corresponding to the capacity of the non-shared memory 302. Alternatively, the information prompting unit 19 can also warn the user if the usage amount exceeds the threshold, providing a list of the memory capacity exceeding the threshold and the magnitude of each variable as auxiliary information to assist in reducing usage. The user, having received this auxiliary information, can suppress the usage of the non-shared memory 302 by selecting a variable corresponding to the memory capacity exceeding the threshold and designating it as a new monitoring variable, thus preventing it from exceeding the threshold. Furthermore, the auxiliary information prompted by the information prompting unit 19 can also be presented in descending order of size or in descending order of the number of references. The information prompting unit 19 is an example of an information prompting unit that prompts information related to the calculated usage amount.
[0106] As explained above, by calculating the usage of the non-shared memory 302 and providing information related to the usage, the user can adjust the actual usage of the non-shared memory 302 in advance. That is, the usage calculation unit 18 calculates the total size of the variables whose values are stored in the non-shared memory among the variables contained in the second source code 22 as the usage and provides it to the user. After the receiving unit 13 provides the information related to the usage through the information prompting unit 19, it receives the specification of the monitored variable again, and the translation unit 12 translates the first source code 21 into the second source code 22 according to the specification received again.
[0107] The embodiments of the present invention have been described above, but the present invention is not limited to the above embodiments.
[0108] For example, it is described that the shared memory 301 is shared with the controlled instrument 40, but it is also possible that not all the data in the shared memory 301 is shared with each of the controlled instruments 40. The shared memory 301 is simply a storage device that shares data stored in at least a portion of its storage area with the controlled instruments 40.
[0109] Additionally, it is explained that program 23 is written to shared memory 301 by PLC program development environment 10, but program 23 written by PLC program development environment 10 to non-volatile memory (not shown) of PLC 30 may also be loaded into shared memory 301 by control platform 34 at appropriate timing.
[0110] Alternatively, a translation system can be constructed from the PLC program development environment 10 and the PLC 30, and this translation system can be provided to the FA field.
[0111] In addition, an example was given in which the translation unit 12 sequentially transforms the code components constituting the first source code 21. However, it is also possible that the code component contains other code components, and the translation unit 12 parses the nested code components and transforms them appropriately.
[0112] Furthermore, the example given is the reference count for calculating the index value, where all variables included in the second source code 22 are monitored variables, but it is not limited to this. The reference count is simply the number of times the shared memory 301 is referenced during program execution when variables satisfying the predefined conditions included in the second source code 22 are monitored variables. The predefined conditions could be, for example, actually storing certain values during program 21 execution, local variables that can be set as monitored variables, variables of a specific type, or other conditions.
[0113] Alternatively, the above implementation methods can be combined in any way. In particular, by combining implementation methods 1 and 3, if information related to usage is provided along with indicator values, the user can create program 23 by considering the trade-offs between observability, execution speed, and memory usage.
[0114] The functions of the PLC program development environment 10 described above can also be implemented using dedicated hardware or a conventional computer system.
[0115] For example, by distributing the program P1 stored on a computer-readable recording medium such as a floppy disk, CD-ROM (Compact Disk Read-Only Memory), DVD (Digital Versatile Disk), or MO (Magneto-Optical disk), and installing the program P1 into a computer, an apparatus for performing the above-described processing can be constructed.
[0116] Alternatively, the program P1 can be pre-stored on a disk device of a server device on a communication network such as the Internet, for example, superimposed on a carrier wave, and downloaded to a computer.
[0117] Alternatively, the above processing can also be achieved by starting and executing a network forwarding program P1, such as the Internet.
[0118] Furthermore, by executing all or part of program P1 on a server device, the computer can send and receive information related to the processing via a communication network and execute program P1, thereby achieving the aforementioned processing.
[0119] Furthermore, when the above functions are implemented by the OS or through the collaboration of the OS and applications, the parts outside the OS can be stored on the medium for distribution, or they can be downloaded to a computer.
[0120] Furthermore, the methods for implementing the functions of the PLC program development environment 10 are not limited to software; some or all of them can also be implemented through dedicated hardware or circuits.
[0121] This invention can be implemented and modified in various ways without departing from its broad spirit and scope. Furthermore, the above-described embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. That is, the scope of the invention is not defined by the embodiments, but by the scope of the claims. Moreover, various modifications applied within the scope of the claims and their equivalents are considered to be within the scope of the invention.
[0122] Industrial applicability
[0123] This invention is applicable to the development of control programs for use in FA field.
[0124] Explanation of the label
[0125] 10 PLC program development environment, 11 Acquisition unit, 12 Translation unit, 13 Receiving unit, 14 Index value calculation unit, 15 Index value prompting unit, 16 Compiler, 17 Monitoring unit, 18 Usage calculation unit, 19 Information prompting 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 terminals, 32 Processor, 33 OS, 34 Control platform, 301 Shared memory, 302 Non-shared memory, 40 Controlled instruments, 51 Monitoring variable list, 52 Attribute information, 61-64 Code.
Claims
1. A translation program that enables a translation device to function as both a receiving unit and a translation unit, the translation device translating first source code, written in a first language, of a program executed by a programmable controller to control a controlled instrument, into second source code written in a second language different from the first language. The receiving unit receives the specified monitoring variables, i.e., the monitoring objects whose values are to be substituted into the variables contained in the first source code when executing the program. The translation unit transforms the variable code in the first source code, which relates to the shared memory variable stored in the shared memory of the programmable controller and shared with the controlled instrument, into a first transformation code related to the variable stored in the shared memory if the shared memory variable is the monitoring variable. If the shared memory variable is different from the monitoring variable, it transforms it into a second transformation code related to the variable stored in a non-shared memory that is different from the shared memory of the programmable controller, thereby translating the first source code into the second source code.
2. The translation procedure according to claim 1, wherein, The first source code is the source code of the program executed by the programmable controller without storing the values of the variables in the non-shared memory.
3. The translation procedure according to claim 1 or 2, wherein, The first language is an instruction list, ladder diagram, functional block diagram, structured text, or sequential function chart.
4. The translation procedure according to any one of claims 1 to 3, wherein, The program of the second source code when the variable code is transformed into the second transformation code has a shorter execution time when executed by the programmable controller compared to the program of the second source code when the variable code is transformed into the first transformation code.
5. The translation procedure according to any one of claims 1 to 4, wherein, The translation device further functions as the following unit: An index value calculation unit calculates an index value corresponding to the length of the execution time when the program executing the second source code is executed; and The indicator value prompting unit prompts the user for the calculated indicator value. After the indicator value is indicated by the indicator value prompting unit, the receiving unit receives the specified monitoring variable again. The translation unit translates the first source code into the second source code according to the received specification.
6. The translation procedure according to claim 5, wherein, The indicator value calculation unit calculates the indicator value based on the number of times the program of the second source code is executed with reference to the shared memory.
7. The translation procedure according to claim 6, wherein, The indicator value calculation unit calculates the indicator value based on a comparison between the number of times and a baseline number of times the program is executed with reference to the shared memory when the variable satisfies the pre-defined conditions contained in the second source code is the monitoring variable.
8. The translation procedure according to any one of claims 1 to 7, wherein, The translation device further functions as the following unit: Usage calculation unit, which calculates the usage of the non-shared memory when executing the program of the second source code; and The information prompting unit provides information related to the calculated usage amount. After the information prompting unit provides the information, the receiving unit receives the specified monitoring variable again. The translation unit translates the first source code into the second source code according to the received specification.
9. The translation procedure according to claim 8, wherein, The usage calculation unit calculates the total size of the variables whose values are stored in the non-shared memory among the variables contained in the second source code as the usage. The information prompting unit provides information to assist in reducing the amount of usage.
10. The translation procedure according to any one of claims 1 to 9, wherein, The receiving unit receives a list of names of variables that are individually designated as the monitoring variables.
11. The translation procedure according to any one of claims 1 to 9, wherein, The receiving unit receives the specification of the attributes that the variable becoming the monitored variable should have. The attribute is the input / output of the programmable controller, a global variable, a program organization unit or functional module (i.e., the category of the variable), used in a conditional expression of a specific control syntax in the first language, used in an expression different from the conditional expression, or has a name containing a specific string.
12. A translation apparatus that translates first source code, written in a first language, of a program executed by a programmable controller for controlling a controlled instrument, into second source code, written in a second language different from the first language. The translation device has the following features: A receiving unit that receives the specification of the monitoring variable (i.e., the value of the monitoring object) from the variables contained in the first source code during program execution; and The translation unit translates the variable code in the first source code related to the shared memory variable whose stored value is in the shared memory of the programmable controller and shared with the controlled instrument. If the shared memory variable is the monitoring variable, the translation unit transforms it into a first transformation code related to the variable whose stored value is in the shared memory. If the shared memory variable is different from the monitoring variable, the translation unit transforms it into a second transformation code related to the variable whose stored value is in the non-shared memory that is different from the shared memory of the programmable controller. This process translates the first source code into the second source code.
13. A translation method, performed by a translation device, which translates first source code of a program executed for a programmable controller to control a controlled instrument, written in a first language, into second source code written in a second language different from the first language. This translation method includes: The receiving unit receives the specified monitoring variables, i.e., the monitoring objects whose values are to be substituted into the variables contained in the first source code when executing the program. The translation unit transforms the variable code in the first source code, which relates to the shared memory variable stored in the shared memory of the programmable controller and shared with the controlled instrument, into a first transformation code related to the variable stored in the shared memory if the shared memory variable is the monitoring variable, and into a second transformation code related to the variable stored in the non-shared memory that is different from the monitoring variable if the shared memory variable is different from the shared memory of the programmable controller. This process translates the first source code into the second source code.
Citation Information
Patent Citations
High-level language sequence instruction program generation part and general sequencer
JP1995295612A