Industrial sequence control method and system based on single decoupling equipment unit
By using a method based on decoupled device units, the sequential control logic table is parsed and structured text code is generated, which solves the problems of low development efficiency and poor code reusability in existing technologies, and realizes efficient and safe industrial sequential control program development and maintenance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SUPCON TECH CO LTD
- Filing Date
- 2025-12-30
- Publication Date
- 2026-04-17
AI Technical Summary
Existing technologies for industrial sequential control programs suffer from low development efficiency, poor code reusability, difficult maintenance, weak security, lack of equipment decoupling architecture and hierarchical model, and insufficient flexibility and security.
A method based on single-unit decoupled device is adopted. By obtaining the sequential control logic table and parsing it into operation variables, combined with predefined instruction sets and completeness verification, a control instruction sequence conforming to structured text language is generated. Device instruction conflict and resource contention checks are performed, a bidirectional debugging mapping relationship is established, and automatic code generation and safety verification are realized.
Significantly reduces manual programming workload, improves development efficiency and code security, supports online monitoring and reverse location, enhances debugging efficiency, achieves modularity and easy maintenance, adapts to diverse production needs, and ensures system security and stability.
Smart Images

Figure CN121879294A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electronic digital data processing technology, and in particular to an industrial sequential control method and system based on a single decoupled device unit. Background Technology
[0002] In modern industrial automation control systems, sequential control programs are a core technology for automating complex processes. Traditional sequential control program development typically involves manually writing ST code or using SFC (Sequential Function Chart) graphical programming. Existing solutions using traditional ST code writing require programmers to program each control logic in detail, including equipment operation, status judgment, and exception handling. The main drawbacks are low development efficiency, a large amount of repetitive programming work, poor code reusability, the need to repeatedly write similar control logic, difficult maintenance, the need for extensive code modification for equipment replacement or process adjustment, susceptibility to errors, complex nested logic prone to logical errors, poor readability, and a lack of unified code standards and commenting standards. Using SFC (Sequential Function Chart) for graphical sequential control programming, constructing control logic through graphical elements such as steps and transition conditions, has the following main drawbacks: decreased readability of the graphical interface under complex logic, high coupling between equipment control logic and sequential control process, difficulty in modularization, lack of standardized equipment control templates, large amount of repetitive design work, poor compatibility between SFC tools from different vendors, and difficulty in porting. Template-based code generation generates ST code through predefined code templates and parameter configurations. The main drawbacks are: high degree of template rigidity, insufficient flexibility, inability to adapt to complex equipment combination control needs, lack of equipment-level abstraction and decoupling mechanisms, high template maintenance costs, and the need to redevelop templates for new equipment types.
[0003] For example, Chinese patent CN120994172A discloses a method and system for automatically generating sequential control code for a DCS system, providing the following technical solution: S1: Formulating standardized template rules for sequential control schemes, wherein the standardized template rules specify the preset type of sequential control steps and set the format of mandatory and optional parameters for each step, including the preset type, device tag number, and tag number description; S2: Filling in the sequential control scheme according to the standardized template rules, determining the preset type of each step, the device tag number of the associated device, and the tag number description, and supplementing the control logic parameters required for the preset type of the corresponding step; S3: Parsing the sequential control scheme using a conversion tool, and automatically converting the parsed step information into sequential control code that can be imported into the DCS system based on the code syntax rules of the DCS system. This solves the problems of high learning curve, long time consumption, and easy code errors in writing sequential control code for DCS systems. However, the above-mentioned method and system for automatically generating sequential control code for DCS systems lacks a device decoupling architecture, hierarchical model, complete verification mechanism, and intelligent security check, resulting in insufficient flexibility and security. Summary of the Invention
[0004] This invention solves the problems of low development efficiency, poor code reusability, difficult maintenance, and weak security in the prior art. It proposes an industrial sequential control method and system based on a single decoupled device unit, achieving the goals of efficient development, high reusability, easy maintenance, and strong security.
[0005] Furthermore, this invention aims to improve the development efficiency, code quality, and system security of industrial automation sequential control programs through decoupling of individual devices and automatic code generation technology, thereby achieving modularization, standardization, and intelligence of control logic.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: An industrial sequential control method based on a single decoupled device unit includes: Obtain the sequential control logic table, and based on multiple pre-established, mutually decoupled individual device units, parse the control instructions in the sequential control logic table into operation variables corresponding to each individual device unit; Based on the predefined instruction set and the instruction combination rules that have been verified for completeness, the parsed operation variables are combined into a sequence of control instructions that conforms to the structured text language standard. Perform security verification, including device instruction conflict checking and resource contention checking, on the control command sequence; Based on the control command sequence that has passed security verification, the corresponding industrial equipment is driven to perform sequential control operations, and a bidirectional debugging mapping relationship between the sequential control logic table and the generated control command sequence is established and maintained.
[0007] Device decoupling enables rapid, automated generation of sequential control code, significantly reducing manual programming workload and improving development efficiency. A security verification mechanism ensures code security and reduces human error. A bidirectional debugging mapping relationship supports online monitoring and reverse location, enhancing debugging efficiency.
[0008] An industrial sequential control system based on a single decoupled device unit includes: a business logic processing module, a core engine module, and a data persistence module. The business logic processing module is connected to a user interaction module through an event-driven interface. The core engine module is connected to the data persistence module through a data access interface. The core engine module and the business logic processing module are connected to an output module, which outputs a control command sequence generated by the core engine module and a configuration report generated by the business logic processing module. The business logic processing module is connected to the core engine module through a service call interface.
[0009] Layered architecture design ensures the modularity and scalability of the system, and the modules interact through standardized interfaces, improving the maintainability and integration capabilities of the system.
[0010] Preferably, the individual device unit is predefined as the smallest control entity that independently performs a specific control function, and is associated with a predefined set of individual control variables; the set of individual control variables specifically includes: operation variables that control the device's actions, status variables that feed back the device's real-time status, parameter variables that set the device's operating parameters, alarm variables that indicate abnormal device status, as well as discrete variables and continuous variables.
[0011] Defining independent, standalone device units enables device-level decoupling and modularization, supporting flexible combination and reuse of devices. A predefined set of control variables provides standardized interfaces for easy device management and maintenance.
[0012] Preferably, the discrete variable values are defined using enumeration, including Boolean variable values representing switch states, command variable values representing control commands, and state variable values representing device operating states; the continuous variable values are defined using expressions, including absolute value expressions, relative value expressions, function expressions, and conditional expressions, and are processed by a built-in expression parsing engine; the expression parsing engine is configured to parse other variables referenced in the expression, perform mathematical operations including trigonometric and logarithmic functions, perform logical judgments and comparisons, and perform time-related calculations.
[0013] The hybrid variable value definition system supports complex mathematical operations and conditional judgments, enhancing the system's flexibility and expressiveness. The expression parsing engine provides powerful computational capabilities, adapting to various industrial control scenarios.
[0014] Preferably, the completeness verification includes performing instruction set classification coverage verification to ensure that the instruction set covers basic control instructions, analog control instructions, logic control instructions, and security communication control instructions; performing instruction compatibility verification to check the matching of instructions with target device types, whether instruction parameters are within the allowable range of the device, the timing dependencies of instruction execution, and identifying potential device resource contention issues.
[0015] The instruction set completeness verification mechanism ensures that the instruction set covers all industrial control scenarios, with particular support for analog gradual control and complex control requirements. Compatibility verification reduces equipment conflicts and operational risks, improving system reliability.
[0016] Preferably, the sequential control logic table uses a standardized multi-column table structure to describe the sequential control process. The table structure includes a step ID column that uniquely identifies each step and transition condition and supports hierarchical nesting, a type column that distinguishes the steps performing the action and defines the transition conditions, a transition condition column that defines the Boolean expression on which the step transition depends, a next step column that specifies the target of the process jump, and a control unit column that calls a predefined instruction set within a specific control unit through an instruction number.
[0017] Tabular sequential control logic descriptions provide an intuitive and structured way to represent complex control logic, supporting modes such as nested branches and parallelism, thus improving readability and maintainability.
[0018] Preferably, the process of parsing the control instructions in the sequential control logic table into operation variables corresponding to each individual device unit is executed by a multi-stage compiler. The multi-stage compiler executes the following steps in sequence: a lexical analysis stage, which identifies the basic elements in the sequential control logic table and constructs a symbol table; a syntax analysis stage, which constructs an abstract syntax tree for the sequential control logic and performs semantic analysis and type checking; an intermediate code generation stage, which generates a three-address code intermediate representation and constructs a program control flow graph; a control instruction sequence optimization stage, which performs dead control instruction sequence elimination, constant propagation, and common subexpression elimination; and a target control instruction sequence generation stage, which finally generates a standardized control instruction sequence that conforms to the standard.
[0019] Multi-stage compiler design ensures that the generated ST code is syntactically correct and optimized, improving code quality. Processing at each stage ensures code standardization and efficiency, reducing errors.
[0020] Preferably, the device instruction conflict check in the security verification includes statically checking whether contradictory instructions are issued to the same device within the same step, and checking whether there are timing conflicts that violate process logic between adjacent steps; the resource contention check includes checking whether a device requiring exclusive access is operated by multiple control units at the same time, and checking for access conflicts of shared resources, including communication buses and memory variables.
[0021] Static safety checks effectively prevent equipment conflicts and operational risks, reducing the probability of safety incidents. Resource contention checks ensure the rational allocation of system resources, avoiding deadlocks and performance issues.
[0022] Preferably, the security verification also includes performing security checks based on a configurable security rule engine, using a predefined security rule definition language to describe conflicts and constraints, and automatically applying these rules for verification and risk interception before the control instruction sequence is generated.
[0023] The security rule configuration engine offers flexible security constraint configuration and supports automated security responses. The rule definition language allows users to define custom security rules, enhancing system adaptability and security.
[0024] Preferably, the bidirectional debugging mapping relationship includes: synchronously generating debugging mapping information during the control instruction sequence generation stage; the debugging mapping information includes the mapping relationship between each row in the generated control instruction sequence and the corresponding row in the sequential control logic table, the association relationship with the step ID, the association relationship with the instruction number, and the correspondence relationship between variables in the control instruction sequence and variables in the individual device unit; during the execution of the control instruction sequence, based on the mapping relationship, the corresponding step in the sequential control logic table is located in reverse highlighting from the executing control instruction sequence row, and the current value of the relevant device variable is synchronously displayed in real time in the sequential control logic table interface.
[0025] Two-way debug mapping technology significantly improves online debugging efficiency and quickly locates the source of problems. Real-time status synchronization provides an intuitive debug interface for easy monitoring and diagnosis.
[0026] Compared with the prior art, the beneficial effects of the present invention are as follows.
[0027] 1. This invention decouples complex sequential control programs into independent single-unit devices and establishes a standardized instruction set. The system can automatically generate structured text code, significantly reducing manual programming workload. It not only avoids repetitive coding but also ensures the syntactic correctness and formatting standardization of the generated code through a multi-stage compiler, significantly reducing the human error rate and making the development process more efficient and reliable.
[0028] 2. The bidirectional debugging mapping technology of this invention establishes a real-time correspondence between code and logic tables, supporting online monitoring and reverse problem localization, greatly simplifying the debugging process. Meanwhile, the modular device unit design and hierarchical architecture ensure that local modifications do not affect the overall system; maintenance only requires adjusting the corresponding units or instruction sets, significantly reducing the complexity and cost of system upgrades and daily maintenance.
[0029] 3. The hierarchical equipment model of this invention supports dynamic equipment combination and rapid process adjustment, enabling flexible adaptation to diverse production needs. The built-in static and dynamic safety inspection mechanisms and risk assessment system effectively prevent equipment command conflicts and operational risks, providing comprehensive protection from early warning to automatic safety response, thereby enhancing system adaptability while ensuring a high degree of safety and stability in operation. Attached Figure Description
[0030] Figure 1 This is an overall flowchart of an industrial sequential control method based on a single decoupled device unit according to the present invention.
[0031] Figure 2 This is a detailed structural diagram of a single device unit in an industrial sequential control system based on a single decoupled device unit, according to the present invention.
[0032] Figure 3 This is a detailed flowchart of the code generation process for an industrial sequential control method based on a single decoupled device unit according to the present invention. Detailed Implementation
[0033] See Figures 1-3 As shown, an industrial sequential control method based on a single decoupled device unit includes: Obtain the sequential control logic table, and based on multiple pre-established, mutually decoupled individual device units, parse the control instructions in the sequential control logic table into operation variables corresponding to each individual device unit; Based on the predefined instruction set and the instruction combination rules that have been verified for completeness, the parsed operation variables are combined into a sequence of control instructions that conforms to the structured text language standard. Perform security verification, including device instruction conflict checking and resource contention checking, on the control command sequence; Based on the control command sequence that has passed security verification, the corresponding industrial equipment is driven to perform sequential control operations, and a bidirectional debugging mapping relationship between the sequential control logic table and the generated control command sequence is established and maintained.
[0034] An industrial sequential control system based on a single decoupled device unit includes: a business logic processing module, a core engine module, and a data persistence module. The business logic processing module is connected to a user interaction module through an event-driven interface. The core engine module is connected to the data persistence module through a data access interface. The core engine module and the business logic processing module are connected to an output module, which outputs a control command sequence generated by the core engine module and a configuration report generated by the business logic processing module. The business logic processing module is connected to the core engine module through a service call interface.
[0035] like Figure 1 and Figure 3 In one embodiment shown, Figure 1 This is an overall flowchart of an industrial sequential control method based on a single decoupled device unit according to the present invention. Figure 3 This invention relates to a detailed flowchart of code generation for an industrial sequential control method based on a single decoupled device unit. The method automates the entire process from control logic definition to executable code generation and safe operation through a structured workflow. First, a standardized sequential control logic table defines the sequential control flow. This table includes a step ID column for uniquely identifying steps and transitions and supporting hierarchical nesting, a type column for distinguishing the steps performing actions and defining switching conditions, and a column for specifying the next step to the flow jump target, among other key information. Specific operations within the control flow are invoked through instruction numbers, which are associated with a predefined instruction set.
[0036] This invention is based on a series of pre-established and decoupled individual device units. Each individual device unit is defined as the smallest entity capable of independently performing a specific control function, such as a valve or pump control unit. Each unit is associated with a set of predefined individual control variables, including operational variables for controlling device actions, status variables for feedback of the device's real-time status, parameter variables for setting operating parameters, and alarm variables for indicating abnormal states. The values of these variables are divided into two categories: discrete and continuous. Discrete variable values are defined using enumeration, such as Boolean or command-type variable values; continuous variable values support expression definitions, including absolute value expressions, relative value expressions, etc., and can be processed by a built-in expression parsing engine, which has the capabilities of variable referencing, mathematical and logical operations, and time function calculation.
[0037] Before logic execution, the system performs a completeness verification of the instruction set used. This verification includes instruction set classification coverage verification to ensure coverage of various industrial scenarios such as basic control, analog control, and safety control; at the same time, instruction compatibility verification is performed to check the matching of instructions with target device types, compliance of parameter ranges, timing dependencies, and potential device resource competition issues.
[0038] Based on the aforementioned sequential control logic table and device unit definitions, the system parses the control instructions in the table into operation variables corresponding to each individual device unit. This parsing and conversion process is executed by a multi-stage compiler, which sequentially performs lexical analysis, syntax analysis, intermediate code generation, code optimization, and target code generation, ultimately outputting a standardized sequence of control instructions conforming to the structured text language standard.
[0039] The generation of control command sequences, both during and after generation, includes rigorous safety verification procedures. Specifically, device command conflict checks statically detect contradictory operations on the same device within the same step, as well as timing conflicts between adjacent steps that violate process logic. Resource contention checks ensure that devices requiring exclusive access are not operated by multiple control units simultaneously, and check for access conflicts to shared resources such as communication buses and memory variables. Furthermore, safety verification can be performed based on a configurable safety rule engine. This engine allows the use of a predefined safety rule definition language to describe complex conflicts and constraints, and automatically applies these rules for risk interception and verification before code generation.
[0040] Once the control command sequence passes security verification, it can be used to drive the corresponding industrial equipment to perform sequential control operations. Throughout the process, the method establishes and maintains a bidirectional debugging mapping relationship between the sequential control logic table and the generated control command sequence. Specifically, debugging mapping information is generated synchronously during the code generation phase, recording the correspondence between each line of code and the corresponding row, step ID, command number, and variable in the sequential control logic table. During the execution of the control command sequence, this mapping relationship can be used to reverse locate and highlight the corresponding step in the sequential control logic table from the currently executing line of code, and the current values of relevant device variables are displayed synchronously in the table interface in real time, greatly facilitating online debugging and monitoring.
[0041] like Figure 2 In one embodiment shown, Figure 2 This is a detailed structural diagram of a single device unit in an industrial sequential control system based on a single decoupled device unit, as described in this invention. This invention proposes an automatic generation method for ST sequential control codes based on single device decoupling. This method establishes a hierarchical device model, decomposes complex sequential control programs into reusable minimum control units, and achieves flexible combination of control logic through an instruction set mechanism. Specifically, it refines the control instruction sequence into ST sequential control codes. The technical architecture of this invention adopts a four-layer model design, with data transfer and control flow between layers through standardized interfaces. The first layer of the system is the individual device layer, where the individual device unit is the smallest device control entity in the system. This includes valve control units, pump control units, timer units, temperature control units, and other types. Typical types also include level control units and pressure control units. Valve control units include on / off valves and regulating valves, while pump control units include centrifugal pumps and metering pumps. These individual device units possess four core characteristics: functional independence (able to independently perform specific control functions such as valve on / off operations); standardized interfaces (possessing unified input / output interface specifications covering operational variables and state variables); observable status (device status can be monitored through variables, such as feedback on open / closed states); and controllable operation (device behavior can be adjusted through variables, such as manual / automatic switching and on / off commands).
[0042] Each individual equipment unit is equipped with corresponding individual control variables. These variables are a set of parameters and states related to the equipment, specifically divided into four categories: operational variables, state variables, parameter variables, and alarm variables. Operational variables are command variables that control the actions of the equipment, such as manual / automatic switching, switch commands, and opening settings. State variables are feedback variables that reflect the current state of the equipment, such as feedback on when the equipment is fully open, feedback on when it is fully closed, and the current opening degree. Parameter variables are setting variables for the equipment's operating parameters, such as time parameters like valve opening time and valve closing time. Alarm variables are indicator variables for abnormal states of the equipment, such as fault states like valve opening failure and valve closing failure.
[0043] The specific values of the control variables are defined, and they are divided into two main categories: discrete variable values and continuous variable values. Discrete variable values are defined by enumeration and include three types: Boolean, command, and status. Boolean variable values include ON, OFF, MANUAL, and AUTO. Command variable values include START, STOP, PAUSE, and RESET. Status variable values include NORMAL, FAULT, and MAINTENANCE.
[0044] Continuous variable values are defined using expressions, encompassing absolute value expressions, relative value expressions, function expressions, and conditional expressions. Absolute value expressions are direct numerical settings, such as "50.0" representing a 50% opening. Relative value expressions are increments based on the current value, such as "CurrentValue+10%" representing an increase of 10% from the current value. Function expressions support mathematical function calculations, such as "MIN (SetPoint*1.2,100.0)" representing 1.2 times the set value but not exceeding 100%. Conditional expressions support conditional judgments, such as "IF (Temperature>80,100.0,50.0)". This indicates that different opening degrees can be set according to temperature conditions. At the same time, the system has a built-in expression parsing engine, which can realize five major functions: variable reference, mathematical operation, logical operation, time function, and safety boundary. Among them, variable reference supports referencing the current or historical values of other devices; mathematical operation covers addition, subtraction, multiplication, division, trigonometric functions, logarithmic functions, etc.; logical operation includes condition judgment, comparison operation, and Boolean operation; time function supports time-related calculations and delay processing; and safety boundary can automatically check whether the calculation results are within the allowable range of the device.
[0045] The second layer of the system is the control unit layer. The control unit is a system module that coordinates multiple individual device units. Its core functions are to realize four major functions: logical coordination between devices, device integration, status management, and exception handling. Specifically, it covers four core capabilities: device integration, logical coordination, status management, and exception handling. That is, integrating multiple related individual device units, coordinating the operation sequence between devices, uniformly managing the overall status of the device combination, and handling abnormal situations of the device combination.
[0046] This layer employs a flexible many-to-many relationship design, where one control unit can manage multiple device units. For example, a feed control unit can manage valve V101, pump P101, and timer T101. Simultaneously, a device unit can be referenced by multiple control units, enabling shared utilization of equipment resources. It also supports dynamic device combination configuration, allowing flexible adjustments to the device combination based on process requirements. Hot-swapping and reconfiguration of device units are permitted, effectively improving system maintainability and scalability. The operational logic within the control unit is combined into an instruction set, which is encapsulated through four methods: logic combination, parameter encapsulation, exception handling, and state synchronization. Specifically, it combines multiple device operations into an atomic operation, encapsulates complex parameter configurations into simple instruction calls, handles relevant exceptions within the instruction set, and ensures the consistency of the state of each operation within the instruction set. Based on functional characteristics, the instruction set is divided into four categories: basic operation instruction set, combined operation instruction set, conditional operation instruction set, and cyclic operation instruction set. These respectively implement basic operations of a single device, coordinated operations of multiple devices, execution of different operational logic based on conditions, and implementation of repetitive operation sequences.
[0047] To ensure the instruction set can cover all industrial control scenarios, the system has established a completeness verification mechanism, mainly including instruction set classification coverage verification and instruction compatibility verification. The instruction set classification coverage verification covers basic control instructions, analog control instructions, logic control instructions, safety control instructions, and communication control instructions. Basic control instructions include basic operation instructions such as switch control, start / stop control, and reset control. Analog control instructions include continuous control instructions such as PID control, ramp control, and tracking control. Logic control instructions include logic processing instructions such as condition judgment, loop control, and timing control. Safety control instructions include safety-related instructions such as emergency stop, safety interlock, and fault handling. Communication control instructions include communication function instructions such as data exchange, status synchronization, and remote control. This layer also supports analog gradual control, specifically including gradual instruction definition, gradual parameter configuration, gradual status monitoring, and gradual interrupt handling. Gradual instruction definition supports gradual control instructions in the form of "RAMP_TO (TargetValue,Duration)". Gradual parameter configuration allows configuring the gradual rate and gradual curve type (linear, exponential, S-curve). (e.g., type), gradual change status monitoring can provide real-time status feedback and completion judgment of the gradual change process, and gradual change interruption handling supports operations such as pausing, resuming, and terminating the gradual change process; instruction compatibility verification revolves around device type matching, parameter range checking, timing constraint verification, and resource conflict detection, respectively verifying whether the instruction is applicable to the target device type, whether the instruction parameters are within the device's allowed range, the timing dependency of instruction execution, and identifying possible device resource competition issues.
[0048] In addition, to facilitate understanding and maintenance, the system has also established a naming convention for command numbers, which includes four elements: function prefix, device suffix, combination identifier, and parameter identifier. The function prefix indicates the main function of the command (such as Open, Start, Stop, Ramp), the device suffix indicates the type of equipment involved (such as V for valve, P for pump, T for temperature control), the combination identifier uses underscores to connect multiple functions or devices, and the parameter identifier uses parentheses to indicate the command parameters, such as "RAMP_V (50.0,30s)".
[0049] The third layer of the system is the sequential control logic layer. Its core functionality relies on three main modules: the sequential control logic table, compiler design, and a safety check mechanism. The sequential control logic table is a tabular tool describing the control flow, employing a standard seven-column structure. Key columns include a step ID column, a type column, a transition condition column, a next step column, a control unit column, and a comment column. The step ID column uniquely identifies each step and transition, supporting hierarchical nested structures (e.g., S1, S11, S111). The type column distinguishes between steps and transitions. Steps execute device actions, and transitions define switching conditions. The transition condition column defines Boolean conditions for step switching, supporting complex logical expressions and function calls. The next step column specifies the flow jump target, supporting various jump modes such as single path, parallel branch, and selection branch. The control unit column specifies the instructions executed by each control unit, calling predefined instruction sets via instruction numbers. The comment column provides step descriptions and code comments, automatically serving as comments in the generated code.
[0050] The sequential control logic table supports complex nesting and branching logic. On one hand, it supports complex control logic with multiple levels of nesting, implemented through hierarchy identification, scope management, state inheritance, and exception bubbling. The hierarchy identification uses a step ID hierarchy to represent the nesting relationship, with each nesting level having an independent scope. Child steps can inherit the state information of their parent steps, and exceptions in child steps can propagate upwards. On the other hand, it supports complex branching and merging logic, including four types: conditional branching, parallel branching, branch merging, and exception branching. It can execute different branch paths based on different conditions, supports parallel execution of multiple branches, provides a merging mechanism after branch execution, and handles special branch paths for exceptions. This layer is designed with a dedicated compiler to convert the sequential control logic table into standard ST code. The compiler adopts a multi-stage compilation architecture, consisting of five stages: lexical analysis, syntax analysis, intermediate code generation, code optimization, and target code generation.
[0051] The lexical analysis stage primarily involves table element recognition, syntax checking, symbol table construction, and preprocessing. This includes recognizing basic elements such as step IDs, instruction numbers, and conditional expressions; verifying the correctness and completeness of the table format; establishing symbol tables for variables, instructions, and devices; and handling preprocessing instructions such as macro definitions and conditional compilation. The syntax analysis stage involves syntax tree construction, semantic analysis, type checking, and scope analysis. This involves constructing an abstract syntax tree (AST) of sequential control logic, checking the semantic correctness and device compatibility of instructions, verifying the matching of variable types and operations, and handling the scope and lifetime of variables. The intermediate code generation stage involves three-address code generation, control flow graph construction, data flow analysis, and optimization preparation. This involves decomposing complex expressions into three-address code form, establishing the program's control flow graph (CFG), analyzing the definition and usage relationships of variables, and preparing intermediate representations for subsequent optimization stages. The code optimization stage involves dead code elimination, constant propagation, common subexpression elimination, and loop optimization. This involves removing code segments that will never be executed, propagating constant values to usage points, eliminating redundant expression calculations, and optimizing the execution efficiency of loop structures.
[0052] The target code generation phase implements ST code generation, register allocation, instruction scheduling, and code formatting, namely generating ST code conforming to the IEC 611313 standard, allocating storage space for temporary variables, optimizing instruction execution order, and generating standardized code format. For special logic scenarios, the compiler also provides corresponding compilation strategies. Nested structure compilation employs recursive descent analysis, scope stack management, label generation strategies, and exception propagation mechanisms. Specifically, it uses a recursive descent algorithm to handle nested step structures, maintains the visibility of variables in nested scopes, generates unique jump labels for nested structures, and handles the upward propagation of exceptions in nested structures. Parallel branch compilation implements concurrency control generation, synchronization point identification, resource contention detection, and deadlock prevention. This involves generating control logic for parallel execution, identifying synchronization points in parallel branches, detecting resource contention between parallel branches, and generating synchronization code to avoid deadlock. Expression compilation optimization covers expression evaluation optimization, short-circuit evaluation, type casting, and operator overloading. This optimizes the evaluation order of complex expressions, implements short-circuit evaluation of Boolean expressions, handles automatic conversion between different types, and supports device-specific operator overloading. This layer is also equipped with a security inspection mechanism, including static security checks, dynamic security monitoring, and conflict detection, providing security support for the operation of sequential control logic.
[0053] The fourth layer of the system is the code generation layer, which comprises three core modules: ST code generation, debugging mapping technology, and a safety response system. ST code generation automatically generates structured text code based on configuration, ensuring syntactic correctness and formatting compliance. The debugging mapping technology focuses on establishing a two-way mapping relationship between ST code and sequential control logic tables, supporting online monitoring and reverse location, facilitating subsequent debugging and maintenance. The safety response system covers safety assurance functions such as risk assessment, intelligent early warning, and automatic safety response, comprehensively ensuring the safety and stability of the code generation and operation phases, providing reliable support for the implementation and operation of the entire control system.
[0054] The code generation process comprises six main steps. First, table parsing is performed, analyzing the structure and content of the sequential control logic table while verifying the correctness of the table format. Next, syntax analysis is conducted, analyzing the Boolean expressions of the transformation conditions and constructing a syntax tree structure. Then, instruction parsing is performed, parsing the specific operations corresponding to the instruction numbers and synchronously mapping them to the control variables of the device units. Next, structure construction is performed, building the hierarchical structure and control flow of the code, focusing on handling nested and branching logic. After completion, the code is executed and output, generating formatted ST code, strictly ensuring syntactic correctness and readability. Finally, comments are automatically generated, producing standardized code comments to improve code maintainability.
[0055] The code generation system includes an indentation control algorithm that automatically adjusts code indentation based on the hierarchical relationship of steps. The specific rules are as follows: the main step uses a basic indentation (1 tab), and the indentation increases by 1 tab for each additional nested level. Code blocks for transformation conditions use the same indentation as the corresponding steps, and custom indentation styles are supported, allowing flexible selection of tabs or spaces. In the conditional expression transformation stage, the conditional expressions in the sequential control logic table are accurately converted into ST code, covering multiple transformation types, including Boolean operator transformation (converting AND, OR, and NOT to ST syntax); comparison operator transformation (supporting various numerical and state comparisons); function call transformation (supporting custom function calls); and variable reference transformation (correctly handling variable scope and references). Furthermore, it automatically generates exception handling code, including timeout detection (adding timeout checks for long-running operations); status checks (verifying the legality of device status); error recovery (generating recovery logic for error scenarios); and alarm triggering (triggering corresponding alarms in abnormal situations), comprehensively ensuring code stability.
[0056] During code generation, debug mapping information is generated synchronously to establish a two-way mapping relationship between ST code and sequential control logic table. The core of this mapping includes two main modules: code location mapping table and real-time status mapping. The code location mapping table covers multi-dimensional mapping: line number mapping records the table line number and instruction number corresponding to each line of ST code; variable mapping establishes the correspondence between variables in ST code and device unit variables; instruction mapping records the original instruction set and parameters corresponding to each ST statement; and step mapping establishes the correspondence between ST code blocks and sequential control steps. Real-time status mapping enables full-process tracking, including execution status tracking, real-time tracking of the currently executing step ID and instruction number; variable value synchronization, synchronously displaying the real-time values of device variables in the table interface; execution path recording, recording the program execution path and branch selections; and timestamp marking, adding a precise timestamp to each execution step.
[0057] It also supports online monitoring and reverse mapping. When ST code runs in the PLC, it can perform multi-dimensional reverse mapping operations. In terms of code line to table positioning, it supports setting breakpoints in the table and automatically mapping them to the corresponding ST code lines. It supports single-step debugging according to the table steps and highlights the currently executed table row. The table interface displays the currently executed instruction number and status in real time. When an anomaly occurs, it automatically locates the corresponding table position. In terms of variable monitoring and mapping, it displays the current status of the device and variable values in the table in real time, provides historical change curves of variables and associates them with the executed instruction sequence, maps PLC alarm information back to the corresponding table instructions and devices, and monitors instruction execution time to accurately identify performance bottlenecks.
[0058] To ensure the integrity and efficient access of mapping information, a dedicated storage format for debugging mapping information was designed. The mapping data structure is clearly defined as follows: debugging mapping information includes code line number (integer), table line number (integer), step ID (string), instruction number (string), device list (device ID list), variable mapping (ST variable name corresponding to device variable path), source code fragment (string), and comment information (string). A comprehensive index optimization scheme is also included. Fast lookup is achieved by building a hash index based on code line number and step ID. A bidirectional index supports fast mapping from code line to table row and from table row to code line. Frequently used mapping information is cached to improve query efficiency. Incremental updates of mapping information are supported to avoid full reconstruction, ensuring efficient and convenient mapping queries.
[0059] To prevent highly abstract programming methods from hiding potential risks, the system has established comprehensive static inspection rules covering multiple dimensions of inspection. First, there is equipment command conflict checking, including synchronization conflict detection (checking whether contradictory commands are issued to the same device within the same step, such as issuing valve open and valve close commands simultaneously); timing conflict detection (checking for logical conflicts between adjacent steps, such as checking the valve open feedback immediately after closing it); parameter conflict detection (checking for conflicts between different parameter settings of the same device, such as setting values exceeding physical limits); and interlock conflict detection (verifying safe interlock relationships between devices to prevent dangerous combinations of device operations).
[0060] Secondly, there is a resource contention check, which includes device exclusivity checks to ensure that devices requiring exclusive access are operated by only one control unit at a time; communication resource checks to check for access conflicts of communication bus and network resources; memory resource checks to verify thread safety and memory consistency of variable access; and time resource checks to check the reasonable allocation of timers and time-related resources.
[0061] Finally, there is safety constraint verification, which includes physical limitation checks to verify that all operating parameters are within the physical limits of the equipment; process safety checks to check the rationality of the operating sequence according to process safety specifications; environmental constraint checks to consider the impact of environmental factors such as temperature and pressure on the operation; and regulatory compliance checks to verify that the operation complies with relevant safety regulations and standards. During code execution, the system also provides real-time safety monitoring. The runtime conflict detection stage continuously monitors the equipment status, promptly detects anomalies, detects potential deadlocks in concurrent operations, identifies the risk of the system entering a livelock state, monitors system performance indicators, and identifies abnormal execution patterns. The automatic safety response stage automatically triggers an emergency shutdown procedure when a serious safety risk is detected, automatically switches to a safe degraded operation mode in the case of non-fatal errors, automatically escalates alarm levels and notification scope according to the risk level, and provides automatic or semi-automatic system recovery strategies.
[0062] Furthermore, the system provides a flexible safety rule configuration mechanism and features a dedicated safety rule definition language that supports complex safety constraint expressions. It includes typical safety rule examples such as valve mutual exclusion operations and temperature safety limits. The rule classification management is clear and explicit, divided into system-level rules (basic rules affecting the safety of the entire system, which cannot be modified), industry-level rules (professional safety rules for specific industries such as chemical and pharmaceutical), enterprise-level rules (safety rules customized according to the specific circumstances of an enterprise), and project-level rules (temporary safety rules for specific projects). A comprehensive rule execution engine is also included, which compiles rule definitions into efficient executable code, schedules rule execution based on priority and triggering conditions, handles conflicts and priority issues between multiple rules, optimizes rule execution performance, and reduces the impact on the system.
[0063] The system has established a comprehensive risk assessment framework with clear and distinct risk level classifications: catastrophic risks (risks that may lead to personal injury or major equipment damage), severe risks (risks that may lead to production interruptions or critical equipment failures), moderate risks (risks that may affect product quality or normal equipment operation), and minor risks (risks that have a potential impact on system operation but will not cause direct losses). It is also equipped with a robust early warning mechanism, including early warnings based on trend analysis to identify potential risks in advance; real-time warnings to issue immediate alerts when risks are about to occur; cascading warnings to consider the cascading effects of risks and provide chain risk warnings; and intelligent warnings based on machine learning algorithms to provide intelligent risk predictions and comprehensively mitigate various risks in advance.
[0064] This invention adopts a five-layer hierarchical architecture design to ensure the modularity and scalability of the system, with clear functions and smooth connections between each layer.
[0065] The first layer is the user interaction layer. The core functional modules include a sequential control logic table editor, which provides an intuitive table editing interface and supports visual configuration of steps, conversion conditions, and instruction numbers; a device unit configurator, which manages the definition and configuration of individual device units and supports the setting and modification of device parameters; an instruction set manager, which provides functions for creating, editing, and managing instruction sets and supports the allocation and mapping of instruction numbers; and a code previewer, which previews the generated ST code in real time and supports syntax highlighting and error prompts.
[0066] The second layer is the business logic layer. The core modules include a table validator, which verifies the format and content correctness of the sequential control logic table to ensure data integrity; a device unit manager, which manages the lifecycle of device units and supports device registration, deregistration, and status monitoring; a control unit manager, which coordinates the relationship between control units and device units and manages the allocation and execution of instruction sets; an instruction set parser, which parses the specific operations corresponding to instruction numbers and builds a mapping relationship between instructions and device variables; and a code generation controller, which controls the entire code generation process and coordinates the workflow of various components.
[0067] The third layer is the core engine layer, which includes a syntax analysis engine that analyzes the conditional expressions in the sequential control logic table and constructs an abstract syntax tree; a structure building engine that constructs the program's control flow structure based on the step relationships and handles nested and branching logic; a code generation engine that generates ST code based on the structure information to ensure syntactic correctness and code standardization; and an optimization processing engine that optimizes the generated code, including formatting and comment generation.
[0068] The fourth layer is the data persistence layer. The core storage module includes a device unit library, which stores predefined device unit templates and configuration information; a control unit library, which manages the definition and configuration data of control units; an instruction set library, which stores the definition and mapping relationship of instruction sets; a template library, which manages user-defined code templates and extended functions; and configuration files, which store system configuration and user preference settings.
[0069] The fifth layer is the output layer. Its core output includes ST code files, generating structured text code files conforming to the IEC 611313 standard; configuration reports, generating detailed system configuration reports for easy document management; and verification logs, recording the verification process and error information to support problem diagnosis and debugging. Each layer interacts through standardized interfaces. Specifically, the user interaction layer communicates with the business logic layer via an event-driven mechanism; the business logic layer calls the core engine layer's functions through service interfaces; the core engine layer interacts with the data persistence layer through data access interfaces; and all processing results are uniformly managed and published through the output layer, ensuring efficient collaborative operation across all layers.
[0070] The system also provides a flexible user-defined template mechanism. Core features include template syntax, defining the template's markup language and syntax rules, supporting variable substitution and conditional judgments; parameterization support, allowing for the definition and replacement of template parameters, enabling parameterized template configuration; conditional logic, supporting conditional judgments and loop structures within templates to adapt to complex code generation needs; and template inheritance, supporting template inheritance and overriding mechanisms to improve template reusability and extensibility. It also predefines commonly used code templates for easy user invocation, specifically: PID control templates (standard PID controller code templates, including parameter settings and control logic); alarm handling templates (unified alarm handling logic templates, supporting multi-level alarms and alarm recovery); data acquisition templates (code templates for data acquisition and processing, supporting multiple data types and acquisition methods); and communication protocol templates (interface templates for various communication protocols, such as Modbus and PROFIBUS industrial protocols), further improving code generation efficiency and standardization.
[0071] All data collection and extraction in this invention are carried out under compliant and legal conditions.
Claims
1. An industrial sequential control method based on a single decoupled device unit, characterized in that, include: Obtain the sequential control logic table, and based on multiple pre-established, mutually decoupled individual device units, parse the control instructions in the sequential control logic table into operation variables corresponding to each individual device unit; Based on the predefined instruction set and the instruction combination rules that have been verified for completeness, the parsed operation variables are combined into a sequence of control instructions that conforms to the structured text language standard. Perform security verification, including device instruction conflict checking and resource contention checking, on the control command sequence; Based on the control command sequence that has passed security verification, the corresponding industrial equipment is driven to perform sequential control operations, and a bidirectional debugging mapping relationship between the sequential control logic table and the generated control command sequence is established and maintained.
2. The industrial sequential control method based on a single decoupled device unit according to claim 1, characterized in that, The individual device unit is predefined as the smallest control entity that independently performs a specific control function, and is associated with a predefined set of individual control variables; The specific set of individual control variables includes: operation variables for controlling the actions of the equipment, status variables for feeding back the real-time status of the equipment, parameter variables for setting the operating parameters of the equipment, alarm variables for indicating abnormal status of the equipment, as well as discrete and continuous variables.
3. The industrial sequential control method based on a single decoupled device unit according to claim 2, characterized in that, The discrete variables are defined using enumeration, including Boolean variable values representing switch states, command variable values representing control commands, and state variable values representing equipment operating states. The continuous variables are defined by expressions, including absolute value expressions, relative value expressions, function expressions, and conditional expressions, and are processed by the built-in expression parsing engine. The expression parsing engine is configured to parse other variables referenced in the expression, perform mathematical operations including trigonometric and logarithmic functions, perform logical judgments and comparisons, and perform time-related calculations.
4. The industrial sequential control method based on a single decoupled device unit according to claim 3, characterized in that, The completeness verification includes performing instruction set classification and coverage verification to ensure that the instruction set covers basic control instructions, analog control instructions, logic control instructions, and security communication control instructions; verifying instruction compatibility to check the matching of instructions with target device types, whether instruction parameters are within the allowable range of the device, the timing dependencies of instruction execution, and identifying potential device resource contention issues.
5. The industrial sequential control method based on a single decoupled device unit according to claim 4, characterized in that, The sequential control logic table uses a standardized multi-column table structure to describe the sequential control process. The table structure includes a step ID column that uniquely identifies each step and transition condition and supports hierarchical nesting, a type column that distinguishes the steps performing the action and defines the transition conditions, a transition condition column that defines the Boolean expression on which the step transition depends, a next step column that specifies the target of the process jump, and a control unit column that calls a predefined instruction set within a specific control unit through an instruction number.
6. An industrial sequential control method based on a single decoupled device unit according to claim 3 or 4, characterized in that, The process of parsing the control instructions in the sequential control logic table into operation variables corresponding to each individual device unit is executed by a multi-stage compiler, which executes the following sequentially: In the lexical analysis stage, the basic elements in the sequential control logic table are identified and a symbol table is constructed; During the syntax analysis phase, an abstract syntax tree of sequential control logic is constructed, and semantic analysis and type checking are performed. In the intermediate code generation stage, a three-address intermediate representation is generated and the program control flow graph is constructed; in the control instruction sequence optimization stage, dead control instruction sequences are eliminated, constants are propagated, and common subexpressions are eliminated; in the target control instruction sequence generation stage, a standard-compliant normalized control instruction sequence is finally generated.
7. The industrial sequential control method based on a single decoupled device unit according to claim 6, characterized in that, The device instruction conflict check in the security verification includes static checking whether contradictory instructions are issued to the same device within the same step, and checking whether there are timing conflicts that violate process logic between adjacent steps. The resource contention check includes checking whether a device requiring exclusive access is operated by multiple control units at the same time, and checking for access conflicts to shared resources, including communication buses and memory variables.
8. The industrial sequential control method based on a single decoupled device unit according to claim 7, characterized in that, The security verification also includes performing security checks based on a configurable security rule engine, using a predefined security rule definition language to describe conflicts and constraints, and automatically applying these rules for verification and risk interception before the control instruction sequence is generated.
9. The industrial sequential control method based on a single decoupled device unit according to claim 8, characterized in that, The bidirectional debugging mapping relationship includes: synchronously generating debugging mapping information during the control instruction sequence generation stage. The debugging mapping information includes the mapping relationship between each row in the generated control instruction sequence and the corresponding row in the sequential control logic table, the association relationship with the step ID, the association relationship with the instruction number, and the correspondence between variables in the control instruction sequence and variables in the individual device unit. When the control instruction sequence is running, based on the mapping relationship, the corresponding step in the sequential control logic table is located in reverse from the executing control instruction sequence row, and the current value of the relevant device variable is displayed synchronously in real time in the sequential control logic table interface.
10. An industrial sequential control system based on a single decoupled device unit, employing the industrial sequential control method based on a single decoupled device unit as described in any one of claims 1-9, characterized in that, include: The system includes a business logic processing module, a core engine module, and a data persistence module. The business logic processing module is connected to the user interaction module via an event-driven interface. The core engine module is connected to the data persistence module via a data access interface. The core engine module and the business logic processing module are connected to an output module, which outputs the control command sequence generated by the core engine module and the configuration report generated by the business logic processing module. The business logic processing module is connected to the core engine module via a service call interface.
Citation Information
Patent Citations
Method and system for automatically generating sequential control code of DCS (Distributed Control System)
CN120994172A