CN109032056B - Programmable logic controller programming language conversion method - Google Patents

Programmable logic controller programming language conversion method Download PDF

Info

Publication number
CN109032056B
CN109032056B CN201810609274.9A CN201810609274A CN109032056B CN 109032056 B CN109032056 B CN 109032056B CN 201810609274 A CN201810609274 A CN 201810609274A CN 109032056 B CN109032056 B CN 109032056B
Authority
CN
China
Prior art keywords
conversion
icil
converting
language
programming language
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810609274.9A
Other languages
Chinese (zh)
Other versions
CN109032056A (en
Inventor
史建琦
黄滟鸿
何积丰
李昂
蔡方达
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Formal Tech Information Technology Co ltd
Original Assignee
Shanghai Fenglei Information Technology Co Ltd
East China Normal University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Fenglei Information Technology Co Ltd, East China Normal University filed Critical Shanghai Fenglei Information Technology Co Ltd
Priority to CN201810609274.9A priority Critical patent/CN109032056B/en
Publication of CN109032056A publication Critical patent/CN109032056A/en
Application granted granted Critical
Publication of CN109032056B publication Critical patent/CN109032056B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/04Programme control other than numerical control, i.e. in sequence controllers or logic controllers
    • G05B19/05Programmable logic controllers, e.g. simulating logic interconnections of signals according to ladder diagrams or function charts
    • G05B19/056Programming the PLC
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B2219/00Program-control systems
    • G05B2219/10Plc systems
    • G05B2219/13Plc programming
    • G05B2219/13106Natural language, use simple words like move, rotate

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Automation & Control Theory (AREA)
  • Programmable Controllers (AREA)

Abstract

The invention provides a programmable logic controller programming language conversion method, which comprises the following steps: the method comprises the steps of abstract syntax tree conversion, ladder diagram conversion, function block diagram conversion, sequence function table diagram conversion, structured text conversion, instruction table conversion and ICIL intermediate structure conversion. The method for converting the programming language of the programmable logic controller can realize the unified conversion of the IEC61131-3 language, does not need to write corresponding transplanting codes for each PLC language respectively in the development and transplanting processes of PLC products of different manufacturers, and is favorable for the subsequent deep development of formal modeling, analysis and verification work based on the intermediate language.

Description

Programmable logic controller programming language conversion method
Technical Field
The invention relates to the technical field of computers, in particular to a programming language conversion method of a programmable logic controller.
Background
In early PLC (Programmable Logic Controller) programming, different electrical equipment providers, including siemens, mitsubishi, befu, etc., all had their own PLC programming language specifications. This poses a great difficulty in the PLC program migration work between devices of different manufacturers. In 1993, the International Electrotechnical Commission (IEC) issued the International Standard IEC61131-3 for PLC programming. The standard unifies the specifications of five PLC programming languages (ladder diagram, function block diagram, sequence function table diagram, structured text and instruction table language), thereby providing a solution for solving the PLC program transplantation problem among different devices.
In order to meet the use requirements of different PLC programming groups and adapt to different PLC application scenes, the five languages of the IEC61131-3 have different characteristics. The ladder diagram language is derived from the logic control diagram of the electrical system, the function block diagram is derived from the signal processing field, the sequence function table diagram is used for describing the process, the function and the characteristic of the sequence function system, the instruction table language is similar to the assembly language and is a lower-level language, and the structured text language is a higher-level text language. Because the characteristics of each language are different, developers need to master multiple PLC language development skills when developing or migrating the PLC program. At present, some conversion works between different PLC languages, such as conversion from a sequential function chart to a ladder diagram, conversion from a ladder diagram to a structured text, conversion from a ladder diagram to a command list language, etc., are available, but all conversion works between single languages have great limitations in use.
In addition to the conversion between different PLC languages, there are some conversion technologies for converting a single PLC language into a formal model such as a time state automaton, a Petri net (a mathematical modeling tool for describing a discrete, distributed system), a NuSMV input model (a model detection tool) and the like, in order to formally verify a PLC application. The formalization method utilizes strict mathematical semantics to check each stage of software development, can be used to ensure that correctly implemented executable programs are obtained, and is largely used to verify various safety-related and life-critical systems. The above conversion technology is also a conversion from a single-class language to a formal model, and has a great limitation.
In view of the above problems, it is desirable to provide a PLC programming language conversion method that facilitates migration, development, and verification of a PLC program.
Disclosure of Invention
In view of the above problems, an object of the present invention is to provide a method for converting a programming language of a PLC, so as to solve the problem in the prior art that it is inconvenient to migrate, develop and verify a PLC program.
The invention provides a programmable logic controller programming language conversion method, which comprises the following steps:
the abstract syntax tree conversion step is used for converting the text PLC programming language into an abstract syntax tree;
the step of ladder diagram conversion, namely converting a ladder diagram into an ICIL intermediate structure;
the functional block diagram conversion step is used for converting the functional block diagram into an ICIL intermediate structure;
the step of converting the sequential function table diagram, namely converting the sequential function table diagram into an ICIL intermediate structure;
the step of converting the structured text, namely converting an abstract syntax tree obtained according to the conversion of the structured text into an ICIL intermediate structure;
the instruction table conversion step is used for converting the abstract syntax tree obtained by conversion according to the instruction table into an ICIL intermediate structure;
and the ICIL intermediate structure conversion step is used for converting the ICIL intermediate structure into an ICIL program.
Optionally, in the step of converting the abstract syntax tree, a text type PLC programming language is specifically used as an input, and the input text type PLC programming language is converted into the abstract syntax tree through lexical analysis and syntactic analysis;
wherein the text type PLC programming language comprises: a structured text language or an instruction sheet language.
Optionally, the step of converting the ladder diagram includes: the method comprises the steps of multi-coil decomposition, scanning sequence calculation, node logic relationship calculation and expression priority calculation; wherein,
the multi-coil decomposition step, the scanning sequence calculation step, the node logic relationship calculation step and the expression priority calculation step are respectively used for carrying out multi-coil step decomposition, node scanning sequence calculation, node logic relationship calculation and ladder diagram expression priority calculation.
Optionally, the step of converting the functional block diagram includes: a function block diagram analyzing step and a function block diagram conversion rule step;
the function block diagram parsing step is to parse the PLCOpen XML file corresponding to the function block diagram program into a first data structure, where the first data structure includes: function block programs, function block networks, function blocks and network input/output connection data;
and the step of the functional block diagram conversion rule is used for converting the first data structure output by the step of analyzing the functional block diagram into an ICIL intermediate structure according to the functional block conversion rule and a network expression input and output rule.
Optionally, the step of converting the sequential function chart includes: a step of analyzing a sequential function table diagram and a step of converting the sequential function table diagram into rules;
analyzing the sequence function table diagram, namely analyzing the PLCOPenXML file corresponding to the sequence function table diagram program into a second data structure, wherein the second data structure comprises: step, action block, migration, concurrent branch structure, concurrent merge structure, selective branch structure and selective merge structure;
and the step of converting the sequential function table diagram into a rule, namely converting the second data structure into an ICIL intermediate structure according to the step of converting the rule and an action block converting rule.
Optionally, in the step of converting the structured text, the abstract syntax tree generated in the step of converting the abstract syntax tree according to the structured text language is converted into an ICIL intermediate structure according to the structured text conversion rule.
Optionally, in the instruction table converting step, the abstract syntax tree generated by the instruction table language in the abstract syntax tree converting step is converted into an ICIL intermediate structure specifically according to the instruction table conversion rule.
Optionally, the ICIL intermediate structure converting step specifically includes analyzing the ICIL intermediate structure, and generating a code in the ICIL program according to an analysis result.
Optionally, the ICIL is an intermediate language of the industrial controller obtained by performing extension based on the CSP language, and the extension content of the ICIL includes a module element, a statement element, and a periodic channel element; wherein,
the module elements are used for unifying the definition of the program organization unit in IEC61131-3 to express the calling and running of functions, function blocks and programs in the original PLC programming language through the calling and running of the module;
the statement element is used for expressing assignment operation and module calling operation;
and the periodic channel element is used for periodically transmitting the messages on the channel.
Optionally, the module element includes: variable declaration and process definition; wherein,
the variable declaration is used for declaring variables used in the module;
the process definition is used to represent the execution behavior of the module by the process.
The beneficial effects of the invention include:
the method for converting the programming language of the programmable logic controller can realize the unified conversion of IEC61131-3 language, and does not need to compile corresponding transplanting codes for each PLC language respectively in the development and transplanting processes of PLC products of different manufacturers; in addition, the formal modeling language ICIL and the conversion method thereof provided by the invention are beneficial to the subsequent deep development of the formal modeling, analysis and verification work based on the intermediate language, and since the IEC61131-3 standard does not provide a corresponding formal verification method per se, the invention has important significance for improving the safety and reliability of industrial control programs in the key field and has wide application prospect in the PLC programming environment; in addition, the formalized modeling language ICIL provided by the invention is beneficial to unifying PLC programming development languages in the future.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a schematic diagram of a PLC programming language conversion system according to an embodiment of the invention;
FIG. 2 is a flow chart illustrating a method for programming language conversion of a programmable logic controller according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a ladder diagram conforming to the IEC61131-3 programming language specification provided by an embodiment of the present invention;
fig. 4 shows a schematic diagram of an AOV map obtained by conversion according to the ladder diagram provided in fig. 3 according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
It is to be noted that, unless otherwise specified, technical or scientific terms used herein shall have the ordinary meaning as understood by those skilled in the art to which the present invention belongs.
The embodiment of the invention provides a programmable logic controller programming language conversion system and a method thereof. Embodiments of the present invention will be described below with reference to the drawings.
The embodiment of the invention firstly provides an Intermediate Language ICIL (industrial controller Intermediate Language) based on an IEC61131-3 programming Language on the basis of an extended CSP (Communicating Sequential process) Language, wherein extended elements of the Language include module elements, statement elements and periodic channel elements.
The module elements unify the definition of the program organization unit in IEC61131-3, that is, the calling and running of functions, function blocks and programs in the original PLC programming language can be represented by the calling and running of modules. And a module comprises a variable declaration part and a process definition part, wherein the variable declaration part is used for declaring variables used in the module, on one hand, the variable declaration can determine the scope of the variables, and on the other hand, the variables can be conveniently used in the module. The process definition is used to represent the execution behavior of the module by the process.
The statement elements, as events in the source language, can be used to represent assignment operations and module invocation operations, thereby extending the computational functional deficiencies in the original CSP language.
The periodic channel element can be used for periodically transmitting messages on the channel, and can more accurately describe the behavior executed by the PLC program periodic scanning compared with the channel in the original CSP language.
Referring to fig. 1, a schematic diagram of a plc programming language conversion system 10 according to an embodiment of the present invention is shown, where the plc programming language conversion system 10 is used to convert an IEC61131-3 programming language into an ICIL intermediate language, and the plc programming language conversion system 10 includes:
an abstract syntax tree conversion module 101, a ladder diagram conversion module 102, a function block diagram conversion module 103, a sequence function table diagram conversion module 104, a structured text conversion module 105, an instruction table conversion module 106 and an ICIL intermediate structure conversion module 107; wherein,
the abstract syntax tree conversion module 101 is used for converting the text PLC programming language into an abstract syntax tree;
the ladder diagram conversion module 102 is configured to convert a ladder diagram into an ICIL intermediate structure;
the functional block diagram converting module 103 is configured to convert a functional block diagram into an ICIL intermediate structure;
the sequential function table map converting module 104 is configured to convert the sequential function table map into an ICIL intermediate structure;
the structured text conversion module 105 is configured to convert the abstract syntax tree obtained according to the structured text conversion into an ICIL intermediate structure;
the instruction table conversion module 106 is configured to convert the abstract syntax tree obtained through conversion according to the instruction table into an ICIL intermediate structure;
the ICIL intermediate structure conversion module 107 is configured to convert the ICIL intermediate structure into an ICIL program.
In some embodiments, the abstract syntax tree conversion module 101 is specifically configured to take a text-type PLC programming language as an input, and convert the input text-type PLC programming language into an abstract syntax tree through lexical analysis and syntactic analysis;
wherein the text type PLC programming language comprises: a structured text language or an instruction sheet language.
Specifically, the abstract syntax tree conversion module 101 may use syntax files of a structured text language and a command list language as input, and convert PLC programs written in these two languages into an abstract syntax tree through a syntax parsing framework such as ANTLR.
In some embodiments, the ladder conversion module 102 includes: the system comprises a multi-coil decomposition module, a scanning sequence calculation module, a node logic relationship calculation module and an expression priority calculation module; wherein,
the multi-coil decomposition module, the scanning sequence calculation module, the node logic relationship calculation module and the expression priority calculation module are respectively used for decomposition of multi-coil steps, node scanning sequence calculation, node logic relationship calculation and ladder diagram expression priority calculation.
Specifically, in an implementation manner provided by the embodiment of the present invention, the multi-coil decomposition module may be configured to decompose the steps with the number of coils greater than 1;
the scanning sequence calculation module may be configured to convert a node relationship of the ladder diagram into an AOV (Activity OnVertex, a directed graph whose vertex represents an Activity) diagram, and perform topological sorting on nodes based on the AOV diagram, thereby obtaining a scanning sequence of the nodes in the ladder diagram;
the node logical relationship calculation module can be used for formulating a corresponding logical operator calculation rule based on the connection relationship among the nodes so as to calculate the logical relationship among the nodes of the ladder diagram;
the expression priority calculation module may be configured to perform a pruning operation on nodes in the AOV graph whose number of child nodes is greater than 2 through a pruning algorithm, that is, the number of child nodes of each node in the original AOV graph is not greater than 2 by inserting a virtual node to connect the child nodes, calculate an operation priority relationship between different nodes in the pruned graph, and add a priority calculator ("(", ") to the ladder graph expression.
In some embodiments, the functional block diagram conversion module 103 includes: the function block diagram analysis module and the function block diagram conversion rule module;
the function block diagram parsing module is configured to parse a PLCOpen XML file corresponding to a function block diagram program into a first data structure, where the first data structure includes: function block programs, function block networks, function blocks and network input/output connection data;
the functional block diagram conversion rule module is configured with a functional block conversion rule and a network expression input/output rule, and is used for converting the first data structure output by the functional block diagram analysis module into an ICIL intermediate structure according to the functional block conversion rule and the network expression input/output rule.
In some embodiments, the sequential function chart diagram conversion module 104 includes: the sequence function table graph analysis module and the sequence function table graph conversion rule module;
the sequential function table graph parsing module is configured to parse a PLCOpenXML file corresponding to a sequential function table graph program into a second data structure, where the second data structure includes: step, action block, migration, concurrent branch structure, concurrent merge structure, selective branch structure and selective merge structure;
the sequential function table diagram conversion rule module is configured with a step conversion rule and an action block conversion rule (different conversion operations can be formulated according to the 12 types of qualifiers (N, R, S, L, D, P, SD, DS, SL, P1, and P0) commonly used in the sequential function block diagram), and is used for converting the second data structure into the ICIL intermediate structure according to the step conversion rule and the action block conversion rule.
In some embodiments, the structured text conversion module 105 is configured with structured text conversion rules;
the structured text conversion module 105 is specifically configured to convert the abstract syntax tree generated by the abstract syntax tree conversion module 101 according to the structured text language into an ICIL intermediate structure according to the structured text conversion rule.
Specifically, since the sentences in the structured text are similar to the ICIL sentences, the rules in the module are mainly used to convert case sentences and three types of loop sentences in the structured text into conditional selection relations between processes.
In some embodiments, the instruction list conversion module 106 is configured with instruction list conversion rules;
the instruction table conversion module 106 is specifically configured to convert the abstract syntax tree generated by the abstract syntax tree conversion module 101 according to an instruction table language into an ICIL intermediate structure according to the instruction table conversion rule.
Specifically, in the instruction table conversion module 106, a corresponding instruction table conversion rule is mainly defined for each operator, modifier and combination relationship between the operator and the modifier in the instruction table language, wherein the delay calculation modifier needs to be calculated separately.
In some embodiments, the ICIL intermediate structure conversion module 107 is configured to parse the ICIL intermediate structure, and generate a code in the ICIL program according to a result of the parsing. Specifically, the ICIL intermediate structure conversion module 107 completes automatic code generation work in the ICIL program by analyzing the ICIL intermediate structure, where the automatic code generation work includes ICIL language generation and generation of indentation and paragraph management.
In some embodiments, the ICIL is an intermediate language of the industrial controller, which is obtained by performing an extension based on a CSP language, and the extension content of the ICIL includes a module element, a sentence element, and a periodic channel element; wherein,
the module elements are used for unifying the definition of the program organization unit in IEC61131-3 to express the calling and running of functions, function blocks and programs in the original PLC programming language through the calling and running of the module;
the statement element is used for expressing assignment operation and module calling operation;
and the periodic channel element is used for periodically transmitting the messages on the channel.
In some embodiments, the module element comprises: variable declaration and process definition; wherein,
the variable declaration is used for declaring variables used in the module;
the process definition is used to represent the execution behavior of the module by the process.
As described above, for the exemplary illustration of the PLC programming language conversion system 10 provided in the embodiment of the present invention, the PLC programming language conversion system 10 provided in the present invention can implement unified conversion of IEC61131-3 languages, and it is not necessary to write corresponding migration codes for each PLC language in the development and migration processes of PLC products of different manufacturers; in addition, the formalized modeling language ICIL and the conversion system 10 thereof provided by the invention are beneficial to the subsequent formalized modeling, analysis and verification work based on the intermediate language, and since the IEC61131-3 standard does not provide a corresponding formalized verification method per se, the invention has important significance for improving the safety and reliability of industrial control programs in the key field and has wide application prospect in a PLC programming environment; in addition, the formalized modeling language ICIL provided by the invention is beneficial to unifying PLC programming development languages in the future.
Corresponding to the above programmable logic controller programming language conversion system, the present invention further provides a programmable logic controller programming language conversion method, please refer to fig. 2, which shows a schematic flow chart of a programmable logic controller programming language conversion method according to an embodiment of the present invention, where the programmable logic controller programming language conversion method is used to convert an IEC61131-3 programming language into an ICIL intermediate language, and the programmable logic controller programming language conversion method includes:
an abstract syntax tree conversion step S101, converting the text PLC programming language into an abstract syntax tree;
a ladder diagram conversion step S102, converting the ladder diagram into an ICIL intermediate structure;
a functional block diagram conversion step S103, converting the functional block diagram into an ICIL intermediate structure;
a step S104 of converting the sequential function chart into an ICIL intermediate structure;
a structured text conversion step S105, converting the abstract syntax tree obtained by the structured text conversion into an ICIL intermediate structure;
an instruction table conversion step S106, which is to convert the abstract syntax tree obtained by the instruction table conversion into an ICIL intermediate structure;
an ICIL intermediate structure converting step S107, which converts the ICIL intermediate structure into an ICIL program.
In some embodiments, before step S101, step S100 may further be included: acquiring a PLC programming language to be converted, and jumping to a corresponding step according to the type of the PLC programming language, for example, if the PLC programming language is a ladder diagram, jumping from step S101 to step S102; if the PLC programming language is a structured text graph, jumping from the step S101 to the step S101, and then jumping from the step S101 to the step S105; and if the PLC programming language is an instruction list, jumping to the step S101, and then jumping to the step S106 from the step S101.
In some embodiments, the abstract syntax tree converting step S101 is to specifically take a text-type PLC programming language as an input, and convert the input text-type PLC programming language into an abstract syntax tree through lexical analysis and syntactic analysis;
wherein the text type PLC programming language comprises: a structured text language or an instruction sheet language.
Specifically, the abstract syntax tree converting step S101 may convert the PLC program written in the structured text language and the instruction list language into the abstract syntax tree through a syntax parsing framework such as ANTLR, with the syntax files of the two languages as input.
In some embodiments, the ladder diagram conversion step S102 may include: the method comprises the steps of multi-coil decomposition, scanning sequence calculation, node logic relationship calculation and expression priority calculation; wherein,
the multi-coil decomposition step, the scanning sequence calculation step, the node logic relationship calculation step and the expression priority calculation step are respectively used for carrying out multi-coil step decomposition, node scanning sequence calculation, node logic relationship calculation and ladder diagram expression priority calculation.
Specifically, in an implementation manner provided by the embodiment of the present invention, the multi-coil decomposition step may include: decomposing the steps with the number of coils more than 1;
the scan order calculating step may include: converting the node relation of the ladder diagram into an AOV (Activity OnVertex, a vertex represents an active directed graph) diagram, and carrying out topological sequencing on nodes based on the AOV diagram so as to obtain the scanning sequence of the nodes in the ladder diagram;
the node logical relationship calculating step may include: based on the connection relation among the nodes, making a corresponding logic operator calculation rule so as to calculate the logic relation among the nodes of the ladder diagram;
the expression priority calculating step may include: performing pruning operation on nodes with the number of sub-nodes larger than 2 in the AOV by a pruning algorithm, namely enabling the number of the sub-nodes of each node in the original AOV to be not more than 2 by inserting virtual nodes to connect the sub-nodes, calculating the operation priority relation among different nodes in the pruned graph, and adding a priority operator ("(", ")") into the ladder diagram expression formula.
In some embodiments, the function block diagram converting step S103 may include: a function block diagram analyzing step and a function block diagram conversion rule step;
the step of parsing the functional block diagram may include: analyzing a PLCOPen XML file corresponding to a function block diagram program into a first data structure, wherein the first data structure comprises: function block programs, function block networks, function blocks and network input/output connection data;
the function block diagram conversion rule step may include: and converting the first data structure output by the functional block diagram analyzing step into an ICIL intermediate structure according to a functional block conversion rule and a network expression input and output rule.
In some embodiments, the sequential function chart transforming step S104 includes: a step of analyzing a sequential function table diagram and a step of converting the sequential function table diagram into rules;
the step of parsing the sequential function chart diagram may include: analyzing the PLCOPenXML file corresponding to the sequence function table graph program into a second data structure, wherein the second data structure comprises: step, action block, migration, concurrent branch structure, concurrent merge structure, selective branch structure and selective merge structure;
the step of converting the sequential function chart into the rule may include: the second data structure is converted into an ICIL intermediate structure according to step conversion rules and action block conversion rules, which may be formulated according to the 12 types of qualifiers commonly used in sequential function block diagrams (N, R, S, L, D, P, SD, DS, SL, P1, and P0), respectively.
In some embodiments, the step of converting the structured text S105 may include: and according to the structured text conversion rule, converting the abstract syntax tree generated by the abstract syntax tree conversion step S101 according to the structured text language into an ICIL intermediate structure.
Specifically, since the sentences in the structured text are similar to the ICIL sentences, the rules in this step are mainly used to convert case sentences and three types of loop sentences in the structured text into conditional selection relationships between processes.
In some embodiments, the instruction list converting step S106 may include: and according to the instruction list conversion rule, converting the abstract syntax tree generated by the abstract syntax tree conversion step S101 according to an instruction list language into an ICIL intermediate structure.
Specifically, in the instruction table conversion step S106, a corresponding instruction table conversion rule is mainly defined for each operator, modifier and combination relationship between the operator and the modifier in the instruction table language, where delay calculation modifiers need to be calculated separately.
In some embodiments, the ICIL intermediate structure converting step S107 may include: and analyzing the ICIL intermediate structure, and generating a code in the ICIL program according to an analysis result. Specifically, the ICIL intermediate structure converting step S107 completes the automatic code generation work in the ICIL program by analyzing the ICIL intermediate structure, where the automatic code generation work includes ICIL language generation and generation of indentation and paragraph management.
In some embodiments, the ICIL is an intermediate language of the industrial controller, which is obtained by performing an extension based on a CSP language, and the extension content of the ICIL includes a module element, a sentence element, and a periodic channel element; wherein,
the module elements are used for unifying the definition of the program organization unit in IEC61131-3 to express the calling and running of functions, function blocks and programs in the original PLC programming language through the calling and running of the module;
the statement element is used for expressing assignment operation and module calling operation;
and the periodic channel element is used for periodically transmitting the messages on the channel.
In some embodiments, the module element comprises: variable declaration and process definition; wherein,
the variable declaration is used for declaring variables used in the module;
the process definition is used to represent the execution behavior of the module by the process.
An embodiment provided by the embodiment of the present invention is described below with reference to fig. 3 and 4, fig. 3 shows a schematic diagram of a ladder diagram conforming to IEC61131-3 programming language specification provided by the embodiment of the present invention, fig. 4 shows a schematic diagram of an AOV diagram obtained by converting the ladder diagram provided by the embodiment of the present invention according to fig. 3, and a process of converting the ladder diagram by using the plc programming language conversion system 10 provided by the embodiment of the present invention is as follows with reference to the descriptions of the ladder diagram conversion module 102 and the ladder diagram conversion step S102 in the foregoing embodiment:
step S1: and analyzing PLCOPen XML derived from the ladder diagram to obtain a corresponding ladder diagram data structure.
Step S2: according to the relationship between ladder diagram data structures, an AOV diagram as shown in fig. 4 is obtained, and the AOV diagram can be represented as a directed graph G (V, E), where a V node set represents tasks or behavior activities, an E edge set represents a priority relationship between the tasks, a relationship between any one node vi and vj can be represented by a node pair (vi, vj), and a predecessor node of any node V has higher priority than the node V.
Step S3: the sequences obtained by sorting according to a topological sorting algorithm on the basis of the AOV map (fig. 4) are (n1, n2, n5, n6, n7, n10, n11, n8, n12, n13, n15, n14, n3, n9, n 4).
To illustrate the transformation effect of the ladder diagram, the following ladder diagram transformation rules are to be listed, and the final ICIL language expression is generated by sequentially traversing the topology ranking and applying the following rules:
1) if the current node is the first node in the topological ordering, the currently generated operator is null, namely the operator is "";
2) if the current node is in the same row as the previous node, the currently generated operator is "&;
3) if the current node is not located in the same row as the previous node and there is a connection line from the previous node to the current node in the AOV graph, the current operator is "&;
4) if the current node and the previous node are not located in the same row and there is no connecting line from the previous node to the current node in the AOV graph, the current operator is "|".
Step S4: traversing the topology sequence by applying the rule to obtain a final ICIL statement as n4 ═ n1& & n2| | n5& & n6& & n7| | n10& & n11| | n12& & n13| n15& & n14& & n3| | | n 9;
step S5: performing pruning operation on the AOV by using a pruning algorithm, and calculating the calculation priority of the expression in the last step by using a priority calculation algorithm on the basis to obtain the following ICIL sentences:
n4=(n1&&n2||n5&&((n6&&n7||n10&&n11)&&n8||n12&&(n13||n15)&&n14))&&(n3||n9)。
in the above, for the exemplary description of the programming language conversion method for the programmable logic controller provided in the embodiment of the present invention, the programming language conversion method for the programmable logic controller provided in the present invention can implement unified conversion of IEC61131-3 language, and it is not necessary to write corresponding migration codes for each PLC language respectively in the development and migration processes of PLC products of different manufacturers; in addition, the formal modeling language ICIL and the conversion method thereof provided by the invention are beneficial to the subsequent deep development of the formal modeling, analysis and verification work based on the intermediate language, and since the IEC61131-3 standard does not provide a corresponding formal verification method per se, the invention has important significance for improving the safety and reliability of industrial control programs in the key field and has wide application prospect in the PLC programming environment; in addition, the formalized modeling language ICIL provided by the invention is beneficial to unifying PLC programming development languages in the future.
It should be noted that the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; such modifications and substitutions do not depart from the spirit and scope of the present invention, and they should be construed as being included in the following claims and description.

Claims (7)

1. A method for converting a programming language of a Programmable Logic Controller (PLC), comprising:
an abstract syntax tree conversion step, which is to convert the text PLC programming language into an abstract syntax tree;
a ladder diagram conversion step, converting the ladder diagram into an ICIL intermediate structure;
a functional block diagram conversion step, namely converting the functional block diagram into an ICIL intermediate structure;
a sequence function table diagram conversion step, namely converting the sequence function table diagram into an ICIL intermediate structure;
a step of structural text conversion, which is to convert an abstract syntax tree obtained according to the structural text conversion into an ICIL intermediate structure;
an instruction table conversion step, namely converting the abstract syntax tree obtained by conversion according to the instruction table into an ICIL intermediate structure;
an ICIL intermediate structure conversion step of converting the ICIL intermediate structure into an ICIL program, wherein
The abstract syntax tree conversion step is to specifically take a text PLC programming language as input, and convert the input text PLC programming language into an abstract syntax tree through lexical analysis and syntactic analysis; wherein the text type PLC programming language comprises: a structured text language or instruction sheet language;
the step of converting the structured text, which is to convert the abstract syntax tree generated by the step of converting the abstract syntax tree according to the structured text language into an ICIL intermediate structure, specifically according to the structured text conversion rule;
and in the instruction table conversion step, specifically, according to the instruction table conversion rule, converting the abstract syntax tree generated by the abstract syntax tree conversion step according to an instruction table language into an ICIL intermediate structure.
2. The plc programming language conversion method according to claim 1, wherein the ladder diagram conversion step includes: the method comprises the steps of multi-coil decomposition, scanning sequence calculation, node logic relationship calculation and expression priority calculation; wherein,
the multi-coil decomposition step, the scanning sequence calculation step, the node logic relationship calculation step and the expression priority calculation step are respectively used for carrying out multi-coil step decomposition, node scanning sequence calculation, node logic relationship calculation and ladder diagram expression priority calculation.
3. The plc programming language conversion method according to claim 1, wherein the function block diagram conversion step includes: a function block diagram analyzing step and a function block diagram conversion rule step;
the function block diagram parsing step is to parse the PLCOpen XML file corresponding to the function block diagram program into a first data structure, where the first data structure includes: function block programs, function block networks, function blocks and network input/output connection data;
and the step of the functional block diagram conversion rule is used for converting the first data structure output by the step of analyzing the functional block diagram into an ICIL intermediate structure according to the functional block conversion rule and the network expression input and output rule.
4. The plc programming language conversion method according to claim 1, wherein the sequential function chart conversion step includes: a step of analyzing a sequential function table diagram and a step of converting the sequential function table diagram into rules;
analyzing the sequence function table diagram, namely analyzing the PLCOPenXML file corresponding to the sequence function table diagram program into a second data structure, wherein the second data structure comprises: step, action block, migration, concurrent branch structure, concurrent merge structure, selective branch structure and selective merge structure;
and the step of converting the sequential function table diagram into a rule, namely converting the second data structure into an ICIL intermediate structure according to a step conversion rule and an action block conversion rule.
5. The method for converting programming languages of a programmable logic controller according to claim 1, wherein the ICIL intermediate structure converting step specifically includes parsing the ICIL intermediate structure, and generating a code in the ICIL program according to a result of the parsing.
6. The method for converting programming languages of a programmable logic controller according to any one of claims 1 to 5, wherein the ICIL is an intermediate language of the industrial controller that is extended based on a CSP language, and the extension content of the ICIL includes a module element, a statement element, and a periodic channel element; wherein,
the module elements are used for unifying the definition of the program organization unit in IEC61131-3 to express the calling and running of functions, function blocks and programs in the original PLC programming language through the calling and running of the module;
the statement element is used for expressing assignment operation and module calling operation;
and the periodic channel element is used for periodically transmitting the messages on the channel.
7. The plc programming language conversion method according to claim 6, wherein the module element includes: variable declaration and process definition; wherein,
the variable declaration is used for declaring variables used in the module;
the process definition is used to represent the execution behavior of the module by the process.
CN201810609274.9A 2018-06-13 2018-06-13 Programmable logic controller programming language conversion method Active CN109032056B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810609274.9A CN109032056B (en) 2018-06-13 2018-06-13 Programmable logic controller programming language conversion method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810609274.9A CN109032056B (en) 2018-06-13 2018-06-13 Programmable logic controller programming language conversion method

Publications (2)

Publication Number Publication Date
CN109032056A CN109032056A (en) 2018-12-18
CN109032056B true CN109032056B (en) 2020-01-10

Family

ID=64609574

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810609274.9A Active CN109032056B (en) 2018-06-13 2018-06-13 Programmable logic controller programming language conversion method

Country Status (1)

Country Link
CN (1) CN109032056B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3715975B1 (en) * 2019-03-28 2023-03-01 Mitsubishi Electric R&D Centre Europe B.V. Method and apparatus for analysing a ladder program
EP3889703B1 (en) * 2020-03-31 2023-02-01 Mitsubishi Electric R&D Centre Europe B.V. Method and apparatus for expressing and verifying functional specifications of a programmable logic controller program
CN113433885A (en) * 2021-07-22 2021-09-24 上海繁易信息科技股份有限公司 Method for converting ladder diagram of PLC programming system into structured text
CN115291853B (en) * 2022-10-09 2023-02-24 浙江中控研究院有限公司 Method and device for exporting and importing LD (laser diode) language in PLC (programmable logic controller) programming software

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101382783A (en) * 2007-09-03 2009-03-11 台达电子工业股份有限公司 Program mechanical code compiling method for programmable logic controller
CN101957745A (en) * 2009-07-16 2011-01-26 沈阳高精数控技术有限公司 Method for converting ladder diagram language into structure text language
JP2011108070A (en) * 2009-11-19 2011-06-02 Koyo Electronics Ind Co Ltd Scale transformation method of analog data
CN104503816A (en) * 2014-12-30 2015-04-08 西安电子科技大学 System for automatically converting hardware language VHDL (Vhsic Hardware Description Language) into MSVL (Modeling, Simulation and Verification Language)
CN104977892A (en) * 2014-04-10 2015-10-14 株式会社捷太格特 Programming assist device for programmable logic controller program and programming assist method for the program

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8325385B2 (en) * 2009-03-27 2012-12-04 Konica Minolta Laboratory U.S.A., Inc. System and methods for processing color data in converting color data from one color space to another color space

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101382783A (en) * 2007-09-03 2009-03-11 台达电子工业股份有限公司 Program mechanical code compiling method for programmable logic controller
CN101957745A (en) * 2009-07-16 2011-01-26 沈阳高精数控技术有限公司 Method for converting ladder diagram language into structure text language
JP2011108070A (en) * 2009-11-19 2011-06-02 Koyo Electronics Ind Co Ltd Scale transformation method of analog data
CN104977892A (en) * 2014-04-10 2015-10-14 株式会社捷太格特 Programming assist device for programmable logic controller program and programming assist method for the program
CN104503816A (en) * 2014-12-30 2015-04-08 西安电子科技大学 System for automatically converting hardware language VHDL (Vhsic Hardware Description Language) into MSVL (Modeling, Simulation and Verification Language)

Also Published As

Publication number Publication date
CN109032056A (en) 2018-12-18

Similar Documents

Publication Publication Date Title
CN109143952B (en) Programmable logic controller programming language conversion system
CN109032056B (en) Programmable logic controller programming language conversion method
Estévez et al. Automatic generation of PLC automation projects from component-based models
Julius et al. Transformation of GRAFCET to PLC code including hierarchical structures
CN112130993B (en) Electric power edge internet of things proxy edge calculation method and system based on graphical modeling
Soliman et al. Verification and validation of safety applications based on PLCopen safety function blocks
Cengic et al. On formal analysis of IEC 61499 applications, Part A: Modeling
CN108037913B (en) Method for converting xUML4MC model into MSVL (modeling, simulation and verification language) program and computer-readable storage medium
CN110109658B (en) ROS code generator based on formalized model and code generation method
CN111880784B (en) SIMSCRIPT language-oriented discrete event simulation graphical modeling method
Yan et al. Compiling ladder diagram into instruction list to comply with IEC 61131-3
US20210026609A1 (en) Support device and non-transitory computer-readable recording medium
Oppelt et al. Capability-analysis of co-simulation approaches for process industries
CN110825433B (en) Design method of edge control equipment
Schütz et al. MDE of manufacturing automation software—Integrating SysML and standard development tools
Moutinho et al. Ecore representation for extending PNML for Input-Output Place-Transition nets
Asensio et al. Industrial automation programming environment with a new translation algorithm among IEC 61131–3 languages based on the TC6-XML scheme
Bergstra et al. Decision problems for pushdown threads
CN112632293A (en) Industry map construction method and device, electronic equipment and storage medium
Lin et al. A Platform-Independent Code Model for Operation and Information Technologies Convergences in Industrial Edge Applications
Koo et al. Software design specification and analysis technique (SDSAT) for the development of safety-critical systems based on a programmable logic controller (PLC)
Ji et al. Structure preserving transformations for practical model-based systems engineering
CN117422047B (en) Circuit simulation method and automatic simulation method for CPU and GPU heterogeneous platform
CN117648081B (en) Visual software integrated development method, system and storage medium
Van Mierlo et al. The fundamentals of domain-specific simulation language engineering

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20210806

Address after: Room 801, no.6, Lane 600, Yunling West Road, Putuo District, Shanghai 200062

Patentee after: SHANGHAI FORMAL TECH INFORMATION TECHNOLOGY Co.,Ltd.

Address before: 200062 No. 3663, Putuo District, Shanghai, Zhongshan North Road

Patentee before: EAST CHINA NORMAL University

Patentee before: SHANGHAI FORMAL TECH INFORMATION TECHNOLOGY Co.,Ltd.