Method and system for automatically generating sequential control code of DCS (Distributed Control System)
By automatically generating sequential control code for DCS systems, the problems of high difficulty and high error rate in writing sequential control code for DCS systems are solved. This method achieves code standardization, rapid generation, and improved security, making it suitable for industrial control needs in multiple scenarios.
Patent Information
- Application Number
- CN202511106516.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-08
- Publication Date
- 2025-11-21
AI Technical Summary
The existing DCS system sequential control code is difficult to learn, time-consuming, prone to errors, and poses security risks.
The method of automatically generating sequential control code for DCS systems is adopted. By formulating standardized template rules and conversion tools, the sequential control scheme is automatically converted into executable code for DCS systems, including the standardized processing of equipment operation, condition judgment and process control steps.
It improves the standardization and normalization of sequential control code, shortens project cycle, reduces labor costs and error rate, enhances system maintainability and security, and adapts to multiple scenario expansion needs.
Smart Images

Figure CN120994172A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of automatic generation of sequential control code, and particularly relates to a method and system for automatically generating sequential control code of a DCS system. BACKGROUND
[0002] In modern industrial production, a distributed control system (DCS, also known as a distributed control system in the domestic self- industry) as a core platform for realizing the automation control of production processes, undertakes the tasks of monitoring, adjusting and managing complex industrial processes. Among them, the sequence control (referred to as "sequential control") is the key link to ensure the orderly progress of the production process in the DCS system - it precisely manages the operation of valves, pumps, motors, PID regulators and other types of production equipment through pre-set logical rules and step sequences, ensures that the equipment completes the actions of starting, switching, stopping or state adjustment in turn according to the process requirements, and finally realizes the automation and standardization of the entire process. Whether it is in the fields of chemical reaction, energy supply or intelligent manufacturing, the stability and efficiency of the sequential control function are directly related to production efficiency, product quality and even production safety.
[0003] However, in the current industrial practice, there are still significant technical limitations in the implementation of the sequential control function of the DCS system. At present, the industry generally relies on engineers to manually write sequential control code or manually modify and adapt based on similar templates in previous projects. The disadvantages of this mode are particularly prominent: Firstly, the threshold is high. Sequential control logic often involves multiple device linkages, complex condition judgments (such as analog quantity threshold judgments, switch quantity state detections), branch processes (such as different execution paths for "true / false conditions") and loop controls, etc. Manual coding requires engineers to master the programming language of the DCS system, process logic details and device characteristics at the same time, which requires extremely high professional ability. New entrants usually need long-term training to independently complete code writing, which seriously hinders the efficiency of project advancement.
[0004] Secondly, the cost of human resources is high. Even experienced engineers need to spend a lot of time to write a set of moderately complex sequential control code, and need to repeatedly check the completeness and accuracy of the logic; for large projects involving hundreds of sequential control processes, the workload of manual coding grows exponentially, and multiple people often need to collaborate to complete it, significantly increasing the human resource investment of the project.
[0005] Thirdly, the error rate is high and the risk is great. In the process of manual coding, code errors are easily caused by human factors such as logic omissions, parameter miswriting and device number confusion. These errors not only may cause abnormal execution of the sequential control process (such as device misstart, step jump disorder), but also may cause production interruption, raw material waste and even equipment damage, etc. serious consequences, bringing safety hazards and economic losses to industrial production.
[0006] After comprehensive search and industry research, at present, there is no technical method or tool capable of automatically converting standardized sequence control scheme into DCS system sequence control code at home and abroad, the inherent pain points of traditional handwritten code mode have not been effectively solved, and become an important bottleneck restricting efficient and safe implementation of DCS system sequence control function, and a new technical scheme is urgently needed to break through. SUMMARY
[0007] In view of the above problems, the purpose of the present application is to provide a method and system for automatically generating DCS system sequence control code, to solve the problems of high difficulty, long time consumption and code error in writing sequence control of DCS system.
[0008] The above invention purpose of the present application is realized by the following technical scheme: A method for automatically generating DCS system sequence control code, comprising the following steps: S1: Formulate standard template rules of sequence control scheme, the standard template rules clearly define the preset type of sequence control step, set the format of mandatory parameters and optional parameters of each step including the preset type, device bit number and bit number description; S2: Fill in the sequence control scheme according to the standard template rules, determine the preset type of each step, the device bit number of the associated device and the bit number description, and supplement the control logic parameters required for the preset type of the corresponding step; S3: Analyze the sequence control scheme through a conversion tool, and automatically convert the analyzed step information into sequence control code that can be imported into the DCS system based on the code syntax rules of the DCS system.
[0009] Further, in step S1, the standard template rules of sequence control scheme are formulated, the standard template rules clearly define the preset type of sequence control step, set the format of mandatory parameters and optional parameters of each step including the preset type, device bit number and bit number description, specifically: The preset type includes: Device operation type: open valve, close valve, open pump, close pump, open PID, close PID, PID automatic adjustment, open other, close other; Condition judgment type: higher than set value, lower than set value, increase set value, decrease set value, cumulative clear, cumulative reach, on-off value judgment; Flow control type: delay, cycle to, cycle number clear, jump to, blank; The format of the mandatory parameters needs to meet the requirements that the device bit number meets the naming specification of the DCS system, and the bit number description needs to clearly define the device function; The optional parameters include a one-for-one backup parameter of setting a valve, an else jump step in condition judgment, and a note information for increasing the readability of the scheme.
[0010] Further, in the step S1 of setting the format of the mandatory parameters and the optional parameters, the following is further included: When the preset type of the sequence control step is delay, a time parameter including seconds, minutes, and hours for measuring time is filled in the position of the equipment bit number, and a process description is filled in the position of the bit number description; When the preset type of the sequence control step is count cycle to or jump to, the number of the jump target step is filled in the position of the equipment bit number; When the preset type of the sequence control step is empty, only the preset type is marked, and no other parameter is filled, and an interface for manually supplementing the code later is reserved; When the equipment corresponding to the preset type of the sequence control step is one-for-one backup equipment, one-for-one backup needs to be marked in the optional parameters, and the corresponding backup equipment bit number is associated; When the preset type of the sequence control step corresponds to a branch structure, the condition judgment step needs to fill in the else jump step in the optional parameters, and the branch end needs to be pointed to a unified subsequent step through the jump to, so as to form a closed logic.
[0011] Further, in the step S3, the sequence control scheme is parsed through a conversion tool, specifically as follows: The sequence control scheme stored in the form of an Excel table is read, and data analysis is performed to identify the parameters in the column fields in the table, including the step number, the preset type of the step, the equipment bit number, and the bit number description; The result of the data analysis and identification is converted into structured data, and the parameter key-value pairs of each step are stored in the form of a dictionary; Logical verification is performed on the structured data, the matching of the equipment bit number and the preset type of the step, the existence of the jump target step, and the integrity of the branch structure are verified, and if there is an error, prompt information including the error position and the reason is output.
[0012] Further, in the step S3, based on the code syntax rules of the DCS system, the parsed step information is automatically converted into sequence control code that can be imported into the DCS system, specifically as follows: Basic parameter generation is performed, the basic parameters required for the sequence control logic operation are automatically defined according to the requirements of the parsed sequence control scheme, including the start signal, the current step identifier, the timer variable, the time output, the process set value, the pause / resume related variable, and the type, initial value, and logical action of each parameter are defined; Alias variable generation is performed, and alias variables are automatically created according to device bit numbers in the sequence control scheme to map operation instructions and state feedback of the device, including valve opening / closing instructions, pump opening / closing instructions, and device state feedback, the alias variables are one-to-one bound with actual device bit numbers, and the expression of device operation in the code is simplified; Code integration is performed, a code template library compatible with the DCS system is built in, corresponding code segments are matched based on the parsed step types, the generated basic parameters and alias variables are substituted into the template, complete sequence control codes containing device operation instructions, conditional judgment statements, and flow jump logic are automatically generated, and it is ensured that the codes can be directly imported into the DCS system for execution.
[0013] Further, code integration is performed, a code template library compatible with the DCS system is built in, corresponding code segments are matched based on the parsed step types, the generated basic parameters and alias variables are substituted into the template, complete sequence control codes containing device operation instructions, conditional judgment statements, and flow jump logic are automatically generated, and it is ensured that the codes can be directly imported into the DCS system for execution, specifically: According to the logical framework of step triggering conditions, device operation instructions, state judgments, and step jumps, corresponding code templates are called according to the parsed step number sequence; the generated basic parameters and alias variables are substituted into the code templates to realize the binding of parameters and logic; for branch structures, IF-THEN-ELSE statement blocks are automatically generated, wherein the IF branch corresponds to the jump target when the condition is true, and the ELSE branch is associated with the else jump step parameter to ensure the completeness of the branch logic; for loop structures, the basic parameter loop counter COUNT records the number of loops, and the IF COUNT >= set number THEN statement is combined to realize loop termination judgment and associate the jump target step to complete the loop logic; all step code segments are integrated, variable declaration areas defining the types and initial values of basic parameters and alias variables are automatically added, and annotation areas marking the corresponding device bit numbers, operation types, and process descriptions of each step are added to form complete sequence control code files that can be directly imported into the DCS system.
[0014] Further, in step S3, the conversion tool also generates an Excel file compatible with the configuration software format of the DCS system, and the generation and content of the Excel file include: File structure definition: adopt the module parameter table format preset by the DCS system software, including fixed columns of parameter name, pin type, parameter type, associated device bit number, initial value, redundancy configuration, pin display name, parameter description, data range, unit, update period, and remarks; Pin parameter information generation rule: Parameter name: Strictly same name as the pin parameter in the sequence control code, wherein the basic parameter directly uses the code variable name, and the alias variable is generated according to the device function prefix + bit number abbreviation rule; Pin type: Automatically labeled according to the parameter function, the input signal is labeled as IN, the output signal is labeled as OUT, and the state monitoring signal is labeled as VIEW; Parameter type: One-to-one correspondence with the code variable type, the switch signal is labeled as BOOL, the integer type parameter is labeled as UINT, and the analog parameter is labeled as REAL; Associated device bit number: Directly reference the device bit number in the sequence control scheme, and the main and standby bit numbers of the one-use-one-backup device need to be associated; Initial value: Defaulted according to the parameter type, BOOL type is 0 by default, UINT type is 0, REAL type is 0, and the process set value is filled in according to the value in the sequence control scheme; Redundancy configuration: Only the parameters of the one-use-one-backup device are labeled as redundant, and the single device parameters are not labeled; Format compatibility is ensured: The table column order, parameter naming rule and data type identification strictly follow the module import specification of the DCS system software, so that the physical binding of variables and device signals, the automatic configuration of module parameters including data refresh period and alarm threshold association can be automatically completed without manual adjustment after file import, replacing the manual copy and paste operation of sequence control code and parameters, and realizing the full-process automation from code generation to system configuration.
[0015] A system for automatically generating DCS system sequence control code for performing the method as described above, comprising: A template rule defining module for formulating standardized template rules of the sequence control scheme, the standardized template rules specifying preset types of sequence control steps, setting formats of mandatory parameters and optional parameters of each step including the preset types, device bit numbers and bit number descriptions; a sequence control scheme filling module for filling the sequence control scheme according to the standardized template rules, determining the preset types of each step, the device bit numbers and the bit number descriptions of the associated devices, and supplementing the control logic parameters required for the preset types of the corresponding steps; a code automatic generation module for parsing the sequence control scheme through a conversion tool, and automatically converting the parsed step information into sequence control code that can be imported into the DCS system based on the code syntax rules of the DCS system.
[0016] A computer device comprising a memory and one or more processors, the memory storing computer code, the computer code being executed by the one or more processors to cause the one or more processors to perform the method as described above.
[0017] A computer-readable storage medium storing computer code that, when executed, performs the method described above.
[0018] Compared with the prior art, the present application includes at least one of the following beneficial effects: (1) Strengthen the standardization and specification of the process: through the preset standardized template rule, unify the filling format and parameter definition of the sequence control scheme (such as device bit number naming, step type classification), avoid the process confusion caused by the difference of manual writing habits, make the sequence control logic of different projects and different engineers consistent and standard, and improve the standardization level of industrial control process.
[0019] (2) Accelerate the project landing period: the functions of automatic code generation and configuration Excel file greatly shorten the time from sequence control scheme design to DCS system deployment: without manual line-by-line code writing and manual configuration of variable and device binding relationship, the sequence control process with medium complexity can realize "code generation and import within 1 hour after the scheme is finalized", which significantly improves the project promotion efficiency.
[0020] (3) Enhance system maintainability and traceability: the sequence control code automatically embeds the corresponding comments (including step type, device bit number and description) of the scheme, and the code is associated with the template scheme one by one, when the production process is adjusted or troubleshooting is performed, the engineer can quickly locate the corresponding scheme content through the code comment, without re-combing the logic, which reduces the later maintenance cost; at the same time, the template modification record and the code version are updated synchronously, which is convenient for tracing the historical changes.
[0021] (4) Adapt to the expansion needs of multiple scenes: the code template library supports custom extension (such as adding special process step type), and the Excel file format is compatible with mainstream DCS systems (such as China Control ECS-700, Siemens PCS7, etc.), which not only meets the complex sequence control needs of a single project, but also quickly adapts to the control logic of different industrial scenes (chemical industry, energy, intelligent manufacturing, etc.), improves the universality and expandability of the technical scheme.
[0022] (5) Reduce enterprise labor cost and training investment: new employees do not need to learn DCS system programming language for a long time to design complex sequence control schemes through templates, which reduces the professional training time and cost; at the same time, it reduces the energy input of experienced engineers in repeated coding, so that they can focus on process logic optimization, and realize efficient allocation of human resources.
[0023] (6) Improve the safety of industrial production: reduce production abnormalities caused by manual coding errors (such as jump target errors, device instruction confusion), combined with template verification functions (such as jump target validity checks), reduce safety risks such as device damage and production interruptions caused by sequential control logic vulnerabilities from the source, and ensure the stable operation of industrial production. BRIEF DESCRIPTION OF DRAWINGS
[0024] Figure 1 The overall flowchart of the method for automatically generating DCS system sequential control code of the present application; Figure 2 The preset type diagram of the step of the present application; Figure 3 The device bit number and bit number description filling diagram of the present application; Figure 4 The delay, count cycle to, step to and blank filling diagram of the present application; Figure 5 The one standby one use device filling diagram of the present application; Figure 6 The branch structure filling diagram of the present application; Figure 7 The sequential control logic diagram of the present application for the quantitative feeding of a reaction kettle; Figure 8 The basic parameter generation diagram of the present application; Figure 9 The alias variable generation diagram of the present application; Figure 10 The first code generation diagram of the present application; Figure 11 The second code generation diagram of the present application; Figure 12 The third code generation diagram of the present application; Figure 13 The fourth code generation diagram of the present application; Figure 14 The Excel file generation diagram of the present application; Figure 15 The code diagram of the Excel file of the present application after conversion on the MCGS platform and import into VF software; Figure 16 The instantiation effect diagram of the present application; Figure 17 The overall structure diagram of the system for automatically generating DCS system sequential control code of the present application. DETAILED DESCRIPTION
[0025] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0026] Those skilled in the art can understand that the singular forms "a", "an" and "the" used herein include plural forms, unless specifically stated otherwise. It should be further understood that the use of the phrase "comprises" in the specification of the present application means that the features, integers, steps, operations, elements and / or components exist, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0027] The terms involved in the present application are explained as follows: DCS: Distributed Control System, also known as Distributed Control System in the domestic self industry. As a new type of computer control system, it is developed and evolved on the basis of centralized control system, and realizes efficient management and control of industrial process through decentralized control and centralized management.
[0028] Sequential control: full name is sequential control, which refers to the sequential management and control of equipment in industrial production process through pre-defined logic rules and operation steps. The core is to ensure that various equipment (such as valves, pumps, motors, etc.) can complete the start, switching, stop and other operations in turn according to the process requirements, so as to realize the automatic execution of the whole process.
[0029] Code: is the source file written by programmers using the specific programming language supported by the development tool, which is composed of characters, symbols or signal elements, transmits information in discrete form, and follows a set of clear and standardized rules, and is a set of instructions that can be recognized and executed by computer.
[0030] ECS-700: is a distributed control system (DCS) launched by SUPCON, which is widely used in industrial automation field, and has functions of data acquisition, process control, monitoring and management, etc., which can meet the control requirements of complex industrial scenes.
[0031] VF: is the abbreviation of VisualField, the configuration software of ECS-700 system, which is used to realize the configuration of DCS system, including process flow drawing, control logic programming, parameter setting, etc., and is the core tool for building and maintaining ECS-700 control system.
[0032] The technical solution of the present invention will be described below through specific embodiments: First Embodiment like Figure 1 As shown, this embodiment provides a method for automatically generating sequential control codes for a DCS system, including the following steps: S1: Develop standardized template rules for sequential control schemes. The standardized template rules specify the preset types of sequential control steps and set the format of required and optional parameters for each step, including the preset type, device tag number, and tag number description.
[0033] Writing sequential control code in DCS systems is generally very repetitive. Therefore, it's possible to summarize a pattern and create tools using high-level programming languages like Python, Java, and C / C++ to automatically convert sequential control schemes into code. However, since everyone's methods and formats for writing sequential control schemes differ, converting any scheme written by anyone into code is extremely difficult. Therefore, a fixed format for writing schemes is needed, hereinafter referred to as a template, and the rules of this template will be described.
[0034] Each step in the sequential control process can be summarized into different preset step types. Once the tool recognizes these step types, it knows what needs to be done in that step. For example... Figure 2 The steps are illustrated in the preset type diagram, which includes: Equipment operation categories: valve open, valve close, pump open, pump close, PID control open, PID control closed, PID automatic adjustment, other functions open, other functions closed; Conditional judgments: higher than set value, lower than set value, increase set value, decrease set value, cumulative reset, cumulative reached, and switch quantity judgment; Process control functions: delay, loop count to zero, loop count to zero, skip step, gap.
[0035] The meanings of the above preset types are defined as follows: Open valve: Open the switch valve; Close valve: Close the on / off valve; Start the pump: Turn on the motors of equipment such as pumps, mixers, and belt conveyors; Turn off the pump: shut down the motors of pumps, agitators, belt conveyors, and other similar equipment; Enable PID: Used to manually output the set value of the PID module for regulating valves or frequency converters; PID Off: Used to manually output 0 from the PID module, for regulating valves or frequency converters; PID automatic control: PID automatic control is used for regulating valves or frequency converters; Open other: used for controlling single DO non-feedback devices such as pulse valves, or controlling interlocking switching, starting other sequential control, prompting, alarming and other soft points ON; Close other: used for controlling single DO non-feedback devices such as pulse valves, or controlling interlocking switching, starting other sequential control, prompting, alarming and other soft points OFF; Delay: delay setting time; Higher than the set value: judge whether the analog quantity such as liquid level, temperature, pressure and flow is greater than or equal to the set value; Lower than the set value: judge whether the analog quantity such as liquid level, temperature, pressure and flow is less than or equal to the set value; Rise by the set value: judge whether the analog quantity such as liquid level, temperature and pressure rises by the set value; Lower by the set value: judge whether the analog quantity such as liquid level, temperature and pressure decreases by the set value; Cumulative clear: flow accumulation clear; Cumulative to reach: flow accumulation reaches the set value; Switch quantity judgment: judge whether the switch quantity condition such as liquid level switch, pressure switch, manual confirmation button and external logic result meets the condition; Cycle to: program jumps to the specified step, used for cycle counting, if greater than the cycle number, go down; Cycle number clear: cycle number clear; Jump to: jump to the corresponding step; Empty: empty the step, manually write code after code generation, used for some special sequential control steps that cannot automatically generate code.
[0036] After the preset type of the step is set, the bit number controlled or judged by the step needs to be filled in, and the bit number description is what, such as Figure 3 The device bit number and bit number description are shown in the filling diagram.
[0037] In addition, the format of the mandatory parameters needs to meet the requirements, the device bit number meets the naming specification of the DCS system, and the bit number description needs to clearly describe the device function; the optional parameters include one primary and one backup parameter of the valve, branch else jump step in condition judgment, and note information for increasing the readability of the scheme.
[0038] Further, when setting the format of the mandatory parameters and the optional parameters in step S1, it further includes: For example Figure 4 The delay, cycle to, jump to and empty filling diagram is shown, when the preset type of the sequential control step is delay, the time parameter for measuring time including seconds, minutes and hours is filled in the position of the device bit number, and the process description is filled in the position of the bit number description; When the preset type of the sequential control step is cycle to or jump to, the number of the jump target step is filled in the position of the device bit number; When the preset type of the sequential control step is empty, only the preset type is marked, and no other parameters are filled in, reserving the interface for later manual code supplement; As Figure 5 When the preset type of the sequential control step corresponds to a one-use-one-backup device, the one-use-one-backup device needs to be marked in the optional parameters, and the corresponding backup device bit number needs to be associated, as shown in the one-use-one-backup device filling diagram. As Figure 6 When the preset type of the sequential control step corresponds to a branch structure, the condition judgment step needs to fill in the else jump step in the optional parameters, and the branch end needs to jump to the unified subsequent step through the jump to, forming a closed logic. Since the judgment condition often has a branch structure, both true and false need to execute the corresponding steps. At this time, the step that needs to be jumped to when false is filled in when the condition is judged, and the jump to is used to jump to the corresponding step at the end of the branch.
[0039] After the above rules are defined, it is clear what each step in the template needs to do, and it is very convenient to develop a tool to automatically convert this template into the sequential control code required by the DCS system. S2: Fill in the sequential control scheme according to the standard template rules, determine the preset type of each step, associate the device bit number of the device and the bit number description, and supplement the control logic parameters required by the preset type of the corresponding step.
[0040] In this embodiment, the VF software of the central control ECS-700 control system is taken as an example to demonstrate the code automatic generation process. According to the rules defined in the template, a tool is developed using Python to parse this template, and the sequential control code used by the central control ECS-700 control system VF software is converted according to the specific content written.
[0041] For example, the reaction kettle needs to realize quantitative feeding. It can be selected whether to feed water or sulfuric acid. When water is selected, first open the water valve XV1001, then open the water pump P1001AB (one-use-one-backup), close the water pump P1001AB (one-use-one-backup) after the water flow accumulates to the set value, and then close the water valve XV1001. When sulfuric acid is selected, first open the sulfuric acid valve XV1002, then open the sulfuric acid pump P1002, close the sulfuric acid pump P1002 after the sulfuric acid flow accumulates to the set value, and then close the sulfuric acid valve XV1002. Forced step and pause functions are required. When pausing, first close the pump and then close the valve. After canceling the pause, it is restored to the state before the pause. Fill in the template according to the requirements Figure 7 The reaction kettle process template filling diagram is shown.
[0042] AsFigure 7 The reaction kettle quantitative feeding sequence control logic is described, which corresponds to Figure 7 The actual application scenario of the template can be explained as: (1) The process selection logic is determined by "on-off judgment" (step 1) by the operator or the upper system to select the feeding type of the reaction kettle (water feeding / sulfuric acid feeding), which triggers the corresponding branch process (branch 1 for water feeding, branch 2 for sulfuric acid feeding). Figure 7 Step 1), the feeding type of the reaction kettle (water feeding / sulfuric acid feeding) is selected by the operator or the upper system, which triggers the corresponding branch process (branch 1 for water feeding, branch 2 for sulfuric acid feeding).
[0043] (2) Water feeding branch execution steps (branch 1) Valve opening: Step 3 triggers the opening of water feeding valve XV1001 to establish the feeding path; Pump starting: Step 4 starts water feeding pump P1001AB (one active and one standby mode, which can automatically switch between active and standby pumps); Flow accumulation and pump stopping: Step 5 monitors the water feeding flow accumulation value, and after reaching the set value, step 6 closes the water feeding pump P1001AB; Valve closing: Step 8 closes the water feeding valve XV1001, completing the water feeding process.
[0044] (3) Sulfuric acid feeding branch execution steps (branch 2) Valve opening: Step 11 triggers the opening of sulfuric acid feeding valve XV1002; Pump starting: Step 12 starts sulfuric acid feeding pump P1002; Flow accumulation and pump stopping: Step 13 monitors the sulfuric acid feeding flow accumulation value, and after reaching the set value, step 14 closes the sulfuric acid feeding pump P1002; Valve closing: Step 16 closes the sulfuric acid feeding valve XV1002, completing the sulfuric acid feeding process.
[0045] (4) Special function adaptation Forced step: Supports manual intervention in the process, which can skip the automatic execution logic and trigger a certain step as needed (such as early valve closing, manual pause); Pause / resume: When paused, stop the equipment in the order of "first pump closing → then valve closing" to avoid pipe pressure buildup and material leakage, and when resumed, automatically return to the process node before pausing (such as continuing to accumulate flow, restarting the unfinished pump and valve actions) to ensure production continuity.
[0046] In short, Figure 7The template is to fill in the logic of "select material → open valve → open pump → cumulative flow → close pump → close valve" with a standardized table to clearly show "who executes, what is executed, and how to associate" so that complex sequential control processes can be automatically converted into DCS code, and new people can easily design an automatic control scheme for the quantitative feeding of a reaction kettle.
[0047] In step S3, the sequential control scheme is parsed by the conversion tool, specifically: The sequential control scheme stored in an Excel table is read, and data analysis is performed to identify the parameters in the table fields, including step number, preset type of step, device bit number, and bit number description. The results of data analysis and identification are converted into structured data, and the parameter key-value pairs of each step are stored in the form of a dictionary. The structured data is logically checked for the matching of the device bit number and the preset type of the step, the existence of the target step, and the integrity of the branch structure. If there is an error, a prompt message containing the error location and reason is output.
[0048] In addition, in step S3, based on the code syntax rules of the DCS system, the parsed step information is automatically converted into sequential control code that can be imported into the DCS system, specifically: As Figure 8 As shown in the basic parameter generation diagram, basic parameter generation is performed. According to the requirements of the parsed sequential control scheme, the basic parameters required for the sequential control logic operation are automatically defined, including start signal, current step identifier, timer variable, time output, process set value, and pause / resume related variables. The types, initial values, and logical actions of each parameter are also specified.
[0049] The "basic parameters" module of the sequential control auxiliary tool automatically generates the basic parameters required for operation based on the parsed sequential control scheme. For example, as shown in the figure, the input parameters include start conditions (such as M0.0 material selection switch), pump selection (such as PO.AE P1001AB water pump selection), and time setting (such as TS0 protection pump time); the output parameters include current step (STEP parameter) and time output (TIME); there are also counters for monitoring (such as step counter) and device state records (such as POA.RE P1001AB water pump switch record). These parameters cover start signal, step identifier, timing variable, process set value, and pause / resume related variables. The tool automatically defines their types, initial values, and roles in the sequential control logic, allowing the sequential control program to run in an orderly manner based on these parameters to achieve functions such as material selection, valve opening, pump opening, cumulative flow, and pause / resume in the quantitative feeding process of a reaction kettle.
[0050] As Figure 9 Alias variable generation is performed as shown in the alias variable generation schematic diagram, and alias variables are automatically created to map the operation instructions and state feedback of the devices according to the device bit numbers in the sequence control scheme, including valve opening / closing instructions, pump opening / closing instructions, and device state feedback. The alias variables are one-to-one bound with the actual device bit numbers, and the expression of device operation in the code is simplified.
[0051] The sequence control auxiliary tool automatically generates alias variables according to the device bit numbers in the sequence control scheme. For example, for the water inlet valve XV101, the sulfuric acid inlet valve XV1002, the water inlet pump P1001AB, the sulfuric acid inlet pump P1002, and other devices, alias variables such as “KVO_AXV1001, water inlet on-off valve open” and “KV1_K XV1002, sulfuric acid on-off valve open” are created. These alias variables cover valve opening / closing instructions, pump opening / closing instructions, and device state feedback (such as “KVO_STA XV1001, water inlet on-off valve state”), and are one-to-one bound with the actual device bit numbers. In subsequent sequence control code writing, a simple alias (such as KVO_A) can represent the corresponding device operation, without repeatedly writing lengthy device bit numbers, simplifying code expression, and making logic clearer. Figure 9 As
[0052] Code integration is performed as shown in the generated code schematic diagram. A code template library compatible with the DCS system is built in, corresponding code snippets are matched based on the parsed step types, the generated basic parameters and alias variables are substituted into the template, complete sequence control code containing device operation instructions, condition judgment statements, and flow jump logic is automatically generated, and it is ensured that the code can be directly imported into the DCS system for execution. Specifically, the following steps can be included: Figures 10-13 According to the logical framework of step trigger conditions, device operation instructions, state judgments, and step jumps, corresponding code templates are called; the generated basic parameters and alias variables are substituted into the code templates to realize the binding of parameters and logic; for branch structures, IF-THEN-ELSE statement blocks are automatically generated, where the IF branch corresponds to the jump target when the condition is true, and the ELSE branch is associated with the else jump step parameter to ensure the completeness of the branch logic; for loop structures, the basic parameter loop counter COUNT records the number of loops, and the IF COUNT >= set number THEN statement is combined to realize loop termination judgment and associate the jump target step to complete the loop logic; all step code snippets are integrated, variable declaration areas defining the types and initial values of the basic parameters and alias variables are automatically added, and annotation areas marking the corresponding device bit numbers, operation types, and process descriptions of each step are added to form complete sequence control code files that can be directly imported into the DCS system.
[0053] After the code is generated, simply copy the pin parameters, including basic parameters and alias variables, and the code into the DCS system.
[0054] In addition, step S3 also includes a conversion tool that simultaneously generates an Excel file compatible with the DCS system configuration software format. The generated Excel file and its content include: File structure definition: The module parameter table format preset by DCS system software is adopted, which includes fixed columns such as parameter name, pin type, parameter type, associated device tag number, initial value, redundancy configuration, pin display name, parameter description, data range, unit, update cycle, and remarks. Pin parameter information generation rules: Parameter names: The pin parameters must be exactly the same as those in the sequential control code. The basic parameters directly use the code variable names, and the alias variables are generated according to the device function prefix + tag number abbreviation rule. Pin type: Automatically labeled according to parameter function, input signals are labeled IN, output signals are labeled OUT, and status monitoring signals are labeled VIEW; Parameter type: Corresponds one-to-one with the code variable type. Switch signals are labeled BOOL, integer parameters are labeled UINT, and analog parameters are labeled REAL. Associated device tag number: Directly reference the device tag number in the sequential control scheme. One device in use and one device in standby need to be associated with both the primary and standby tag numbers. Initial values: Preset according to parameter type. BOOL type defaults to 0 (off), UINT type defaults to 0, REAL type defaults to 0. Process setting values should be filled in according to the values in the sequential control scheme. Redundancy configuration: Only the parameters of one-use-one-standby devices are marked as redundant; parameters of a single device are not marked as redundant. Ensure format compatibility: The table column order, parameter naming rules, and data type identification strictly follow the module import specifications of the DCS system software, ensuring that the process can be completed automatically without manual adjustment after the file is imported. This enables the physical binding of variables and device signals, and the automatic configuration of module parameters, including data refresh cycles and alarm threshold associations. It replaces the manual copy and paste operation of sequential control code and parameters, realizing full automation from code generation to system configuration.
[0055] like Figure 14 The generated Excel file is shown in the diagram, using the ZKTeco ECS-700 control system VF software as an example. Since the ZKTeco ECS-700 control system VF software has a method to convert Excel spreadsheets into modules, this tool can automatically generate an Excel file in VF software format, which can be directly imported into the VF software, eliminating the need for copying and pasting code and pin parameters. The automatically generated Excel file looks like this... Figure 14After converting this Excel file on the central control platform and importing it into VF software, it will look like this: Figure 15 As shown. The instantiation result is as follows. Figure 16 As shown, filling in the corresponding bit number according to the description makes it very convenient to complete the sequential control programming.
[0056] Second Embodiment like Figure 17 As shown, this embodiment provides a system for automatically generating DCS system control codes for executing the method for automatically generating DCS system control codes as described in the first embodiment, comprising: Template rule definition module 1 is used to formulate standardized template rules for sequential control schemes. The standardized template rules specify the preset types 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. Sequential control scheme filling module 2 is used to fill in the sequential control scheme according to the standardized template rules, determine the preset type of each step, the device tag number of the associated device, and the tag number description, and supplement the control logic parameters required for the preset type of the corresponding step. Code automatic generation module 3 is used to parse the sequential control scheme through a conversion tool and automatically convert 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.
[0057] A computer-readable storage medium stores computer code that, when executed, performs the methods described above. Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. This program can be stored in a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), a magnetic disk, or an optical disk, etc.
[0058] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should also be considered within the scope of protection of the present invention.
[0059] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0060] It should be noted that the above embodiments can be freely combined as needed. The above description is only a preferred embodiment of the present invention. It should be pointed out that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for automatically generating sequential control codes for a DCS system, characterized in that, Includes the following steps: S1: Develop standardized template rules for the sequential control scheme. The standardized template rules specify the preset types of the sequential control steps and set the format of required and optional parameters for each step, including the preset type, device tag number, and tag number description. S2: Fill in the sequential control scheme according to the standardized template rules, determine the preset type of each step, the device tag number of the associated device, and the tag number description, and supplement the control logic parameters required for the preset type of the corresponding step. S3: Parse the sequential control scheme using a conversion tool. Based on the code syntax rules of the DCS system, automatically convert the parsed step information into sequential control code that can be imported into the DCS system.
2. The method for automatically generating DCS system sequential control codes according to claim 1, characterized in that, In step S1, a standardized template rule for the sequential control scheme is established. This standardized template rule clarifies the preset types of the sequential control steps and sets the format of mandatory and optional parameters for each step, including the preset type, device tag number, and tag number description. Specifically: The preset types include: Equipment operation categories: valve open, valve close, pump open, pump close, PID control open, PID control closed, PID automatic adjustment, other functions open, other functions closed; Conditional judgments: higher than set value, lower than set value, increase set value, decrease set value, cumulative reset, cumulative reached, and switch quantity judgment; Process control functions: delay, loop count to zero, loop count to zero, skip step, gap; The required parameters must meet the following format requirements: the device tag number must conform to the DCS system naming convention; and the tag number description must clearly define the device function. The optional parameters include setting one-use and one-standby parameters for the valve, the branch else jump step during condition judgment, and setting notes to increase the readability of the solution.
3. The method for automatically generating DCS system sequential control codes according to claim 1, characterized in that, When setting the format of the required parameters and the optional parameters in step S1, the method further includes: When the preset type of the sequential control step is delay, time parameters including seconds, minutes, and hours for measuring time are filled in the position of the device tag number, and process description is filled in the position of the tag number description. When the preset type of the sequential control step is counted cycle to or jump to, the number of the target step to jump to is filled in the position of the device tag number; When the preset type of the sequential control step is empty, only the preset type is marked, and no other parameters are filled in, leaving an interface for manual code addition later; When the device corresponding to the preset type in the sequential control step is a one-use-one-standby device, it is necessary to mark one-use-one-standby in the optional parameters and associate the corresponding standby device tag number. When the preset type of the sequential control step corresponds to a branch structure, the condition judgment step needs to fill in the else jump step in the optional parameters. At the end of the branch, a jump step is needed to point to the unified subsequent step to form closed logic.
4. The method for automatically generating DCS system sequential control codes according to claim 1, characterized in that, In step S3, the sequential control scheme is parsed using a conversion tool, specifically as follows: Read the sequential control scheme stored in the form of an Excel spreadsheet, and perform data parsing to identify the parameters corresponding to the column fields in the table, including the step number, the preset type of the step, the device tag number, and the tag number description; The results of data parsing and identification are converted into structured data, and the parameter key-value pairs of each step are stored in the form of a dictionary; The structured data is logically validated to check the matching of the device tag number with the preset type of the step, the existence of the target step, and the integrity of the branch structure. If an error is found, a prompt message containing the error location and reason is output.
5. The method for automatically generating DCS system sequential control codes according to claim 1, characterized in that, In step S3, based on the code syntax rules of the DCS system, the parsed step information is automatically converted into sequential control code that can be imported into the DCS system, specifically as follows: Generate basic parameters. Based on the requirements of the parsed sequential control scheme, automatically define the basic parameters required for the operation of the sequential control logic, including start signal, current step identifier, timer variable, time output, process set value, pause / resume related variables, and clarify the type, initial value and logical function of each parameter. Alias variables are generated automatically based on the device tag number in the sequential control scheme to map the device's operation commands and status feedback, including valve open / close commands, pump open / close commands, and device status feedback. The alias variables are bound one-to-one with the actual device tag number, simplifying the description of device operations in the code. Code integration is performed, and a built-in code template library compatible with the DCS system is used. Based on the parsed step type, the corresponding code snippets are matched, and the generated basic parameters and alias variables are substituted into the template to automatically generate complete sequential control code containing equipment operation instructions, conditional judgment statements, and process jump logic, ensuring that the code can be directly imported into the DCS system for execution.
6. The method for automatically generating DCS system sequential control codes according to claim 5, characterized in that, Code integration is performed, and a built-in code template library compatible with the DCS system is incorporated. Based on the parsed step types, corresponding code snippets are matched, and the generated basic parameters and alias variables are substituted into the templates to automatically generate complete sequential control code containing equipment operation instructions, conditional statements, and process jump logic. This ensures that the code can be directly imported into the DCS system for execution. Specifically: Based on the parsed step numbering order, the corresponding code template is called according to the logical framework of step triggering condition → device operation instruction → status judgment → step jump; the generated basic parameters and alias variables are substituted into the code template to realize the binding of parameters and logic; For branching structures, IF-THEN-ELSE statement blocks are automatically generated, where the IF branch corresponds to the jump target when the condition is true, and the ELSE branch is associated with the else jump step parameter to ensure the integrity of the branching logic; For loop structures, the loop count is recorded by the basic parameter loop counter COUNT, and the loop termination judgment is realized by combining the IF COUNT >= THEN statement to set the number of times, and the loop logic is linked to jump to the target step to complete the loop. All step code snippets are integrated, and variable declaration areas that define the types and initial values of basic parameters and alias variables are automatically added, as well as comment areas that mark the corresponding equipment tag number, operation type and process description for each step, forming a complete sequential control code file that can be directly imported into the DCS system.
7. The method for automatically generating DCS system sequential control codes according to claim 5, characterized in that, Step S3 also includes a conversion tool that simultaneously generates an Excel file compatible with the DCS system configuration software format. The generated Excel file and its content include: File structure definition: The module parameter table format preset by DCS system software is adopted, which includes fixed columns such as parameter name, pin type, parameter type, associated device tag number, initial value, redundancy configuration, pin display name, parameter description, data range, unit, update cycle, and remarks. Pin parameter information generation rules: Parameter names: The pin parameters must be exactly the same as those in the sequential control code. The basic parameters directly use the code variable names, and the alias variables are generated according to the device function prefix + tag number abbreviation rule. Pin type: Automatically labeled according to parameter function, input signals are labeled IN, output signals are labeled OUT, and status monitoring signals are labeled VIEW; Parameter type: Corresponds one-to-one with the code variable type. Switch signals are labeled BOOL, integer parameters are labeled UINT, and analog parameters are labeled REAL. Associated device tag number: Directly reference the device tag number in the sequential control scheme. One device in use and one device in standby need to be associated with both the primary and standby tag numbers. Initial values: Preset according to parameter type. BOOL type defaults to 0 (off), UINT type defaults to 0, REAL type defaults to 0. Process setting values should be filled in according to the values in the sequential control scheme. Redundancy configuration: Only the parameters of one-use-one-standby devices are marked as redundant; parameters of a single device are not marked as redundant. Ensure format compatibility: The table column order, parameter naming rules, and data type identification strictly follow the module import specifications of the DCS system software, ensuring that the process can be completed automatically without manual adjustment after the file is imported. This enables the physical binding of variables and device signals, and the automatic configuration of module parameters, including data refresh cycles and alarm threshold associations. It replaces the manual copy and paste operation of sequential control code and parameters, realizing full automation from code generation to system configuration.
8. A system for automatically generating DCS system sequential control codes for executing the method for automatically generating DCS system sequential control codes as described in any one of claims 1-7, characterized in that, include: The template rule definition module is used to formulate standardized template rules for sequential control schemes. The standardized template rules specify the preset types 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. The sequential control scheme filling module is used to fill in the sequential control scheme according to the standardized template rules, determine the preset type of each step, the device tag number of the associated device, and the tag number description, and supplement the control logic parameters required for the preset type of the corresponding step. The code automatic generation module is used to parse the sequential control scheme through a conversion tool and automatically convert 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.
9. A computer device comprising a memory and one or more processors, the memory storing computer code that, when executed by the one or more processors, causes the one or more processors to perform the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing computer code, wherein when the computer code is executed, the method of any one of claims 1 to 7 is performed.
Citation Information
Cited By
Industrial sequence control method and system based on single decoupling equipment unit
CN121879294A