Method for calculating flow accumulation program in sections

文档序号:1227723 发布日期:2020-09-08 浏览:29次 中文

阅读说明:本技术 一种分段计算流量累计程序的方法 (Method for calculating flow accumulation program in sections ) 是由 王红彦 王伟兵 李仁华 于 2020-04-26 设计创作,主要内容包括:本发明涉及一种分段计算流量累计程序的方法,属于自动控制技术领域。本发明的技术方案是:在PLC中定时中断调用流量累计功能模块,该模块中设置4个标签:标签1表示1秒钟的流量增量值;标签2表示流量累计值的低字段数值;标签3表示流量累计值的高字段数值;标签4表示流量累计值的实际值。本发明的有益效果是:通过在PLC控制器中利用分段计算流量累计程序的方法编制程序,可以解决流量累计值过大导致累计值不累计的现象发生,为介质计量的准确性提供了技术保证。(The invention relates to a method for calculating a flow accumulation program in a segmented mode, and belongs to the technical field of automatic control. The technical scheme of the invention is as follows: the flow accumulation function module is called in the PLC by the timed interruption, and 4 labels are arranged in the module: label 1 represents a 1 second flow increment value; label 2 represents the low field value of the traffic running total; label 3 represents the high field value of the traffic running total; the label 4 indicates the actual value of the traffic integrated value. The invention has the beneficial effects that: the PLC is programmed by utilizing a method for calculating the flow accumulation program in a segmented mode, so that the problem that the accumulated value is not accumulated due to overlarge flow accumulation value can be solved, and technical guarantee is provided for the accuracy of medium metering.)

1. A method for calculating a flow totalization procedure in stages, comprising the steps of:

step 1: the instantaneous value of the flow is converted, the flow measurement signal accessed by a field measurement element through an analog quantity input template is converted into the instantaneous value of the flow in a program, and the temperature and pressure compensation calculation is carried out on the gas flow needing temperature and pressure compensation;

step 2: calling a flow accumulation function module, compiling the flow accumulation function module, and setting the function module as a timing interruption module;

and step 3: calculating a low field value of the flow cumulative value and a high field value of the flow cumulative value according to a certain method in the flow cumulative function block, and calculating an actual value of the flow cumulative value according to the low field value and the high field value;

and 4, step 4: and executing other logic programs, and continuing to execute other logic programs after the logic of the timed interrupt flow accumulation function block is executed.

2. The method of claim 1, wherein the step of performing a piecewise computation flow totalization procedure comprises: in the step 2, the timer interrupt period of the timer interrupt module is 1 second, and the flow accumulation function module is called at intervals of 1 second to perform flow accumulation calculation for 1 time.

3. The method of claim 1, wherein the step of performing a piecewise computation flow totalization procedure comprises: the step 3 of calculating the actual flow rate accumulated value includes the following steps:

(1) setting a label of a flow accumulation program, and setting four labels in a flow accumulation function block program: label 1 represents a 1 second flow increment value; label 2 represents the low field value of the traffic running total; label 3 represents the high field value of the traffic running total; label 4 represents the actual value of the traffic integrated value;

(2) calculating a flow increment value of 1 second, and if the flow instantaneous value is in hours in the flow accumulation function block program, the flow increment value of 1 second is labeled 1= flow instantaneous value ÷ 3600; if the instantaneous flow value is in minutes, a 1 second flow increment value, label 1= instantaneous flow value ÷ 60;

(3) calculating a low field value of the traffic cumulative value, wherein the label 2= label 1+ label 2;

(4) calculating a high field numerical value of the traffic cumulative value, and if a low field numerical value label 2 of the traffic cumulative value is greater than 10000 in the flow cumulative function block program, the high field numerical value of the traffic cumulative value is label 3= label 3+1, and the low field numerical value of the traffic cumulative value is label 2= label 2-10000;

(5) calculating an actual value of the traffic cumulative value, wherein in the flow cumulative function block program, label 4= high field numerical label 3 × 10000+ low field numerical label 2 of the traffic cumulative value;

(6) in practical application, according to the requirements of the process, the zero clearing trigger condition of the flow integrated value can be that the low field value label 2 of the flow integrated value and the high field value label 3 of the flow integrated value are cleared simultaneously when the zero clearing is carried out according to the time (year, month and day) or the flow integrated value reaching a certain value.

Technical Field

The invention relates to a method for calculating a flow accumulation program in a segmented mode, and belongs to the technical field of automatic control.

Background

The PLC controller is widely applied to various industries such as steel, petroleum, chemical industry, electric power, building materials, mechanical manufacturing, automobiles, light textile, transportation, environmental protection, cultural entertainment and the like, and has the characteristics of high reliability, strong anti-interference capability, powerful functions, flexibility, easiness in learning and use, small volume, light weight and low price.

Various media such as wind, water, electricity, gas and the like are ubiquitous in various industries, and the metering of the medium flow is an important basis for calculating various costs in production and life. Its accuracy is directly related to the economic benefit between the media provider and the user. The PLC system can conveniently realize the functions of instantaneous flow conversion and flow accumulation measurement of various media through flow signal input and data conversion, and provides technical guarantee for the accuracy of the medium measurement. In practical applications, the flow metering accumulation program often has the phenomenon that the flow accumulated value is not accumulated. This phenomenon occurs because the traffic accumulation value is a data type of a floating point number in the PLC system, the significant bit of the floating point number is only 7 significant bits, and if an instantaneous traffic is small, the significant bit between the floating point number and the traffic accumulation value is greater than 7 bits, and they are not accumulated when they are added.

Disclosure of Invention

The invention aims to provide a method for calculating a flow accumulation program in a segmented mode, which can solve the problem that the accumulated value is not accumulated due to overlarge flow accumulated value by programming the flow accumulation program in a PLC (programmable logic controller) by utilizing the method for calculating the flow accumulation program in the segmented mode, provides technical guarantee for the accuracy of medium metering and effectively solves the problems in the background art.

The technical scheme of the invention is as follows: a method for calculating a flow totalization procedure in stages, comprising the steps of: step 1: the instantaneous value of the flow is converted, the flow measurement signal accessed by a field measurement element through an analog quantity input template is converted into the instantaneous value of the flow in a program, and the temperature and pressure compensation calculation is carried out on the gas flow needing temperature and pressure compensation;

step 2: calling a flow accumulation function module, compiling the flow accumulation function module, and setting the function module as a timing interruption module;

and step 3: calculating a low field value of the flow cumulative value and a high field value of the flow cumulative value according to a certain method in the flow cumulative function block, and calculating an actual value of the flow cumulative value according to the low field value and the high field value;

and 4, step 4: and executing other logic programs, and continuing to execute other logic programs after the logic of the timed interrupt flow accumulation function block is executed.

In the step 2, the timer interrupt period of the timer interrupt module is 1 second, and the flow accumulation function module is called at intervals of 1 second to perform flow accumulation calculation for 1 time.

The step 3 of calculating the actual flow rate accumulated value includes the following steps:

(1) setting a label of a flow accumulation program, and setting four labels in a flow accumulation function block program: label 1 represents a 1 second flow increment value; label 2 represents the low field value of the traffic running total; label 3 represents the high field value of the traffic running total; label 4 represents the actual value of the traffic integrated value;

(2) calculating a flow increment value of 1 second, and if the flow instantaneous value is in hours in the flow accumulation function block program, the flow increment value of 1 second is labeled 1= flow instantaneous value ÷ 3600; if the instantaneous flow value is in minutes, a 1 second flow increment value, label 1= instantaneous flow value ÷ 60;

(3) calculating a low field value of the traffic cumulative value, wherein the label 2= label 1+ label 2;

(4) calculating a high field numerical value of the traffic cumulative value, and if a low field numerical value label 2 of the traffic cumulative value is greater than 10000 in the flow cumulative function block program, the high field numerical value of the traffic cumulative value is label 3= label 3+1, and the low field numerical value of the traffic cumulative value is label 2= label 2-10000;

(5) the actual value of the traffic cumulative value is calculated, in the traffic cumulative function block program, label 4= high field value label 3 × 10000 of the traffic cumulative value + low field value label 2 of the traffic cumulative value.

(6) In practical application, according to the requirements of the process, the zero clearing trigger condition of the flow integrated value can be that the low field value label 2 of the flow integrated value and the high field value label 3 of the flow integrated value are cleared simultaneously when the zero clearing is carried out according to the time (year, month and day) or the flow integrated value reaching a certain value.

The invention has the beneficial effects that: the PLC is programmed by utilizing a method for calculating the flow accumulation program in a segmented mode, so that the problem that the accumulated value is not accumulated due to overlarge flow accumulation value can be solved, and technical guarantee is provided for the accuracy of medium metering.

Drawings

FIG. 1 is a flow chart of the present invention;

in the figure: the label 0 represents the instantaneous value of the flow, in this example in hours; label 1 represents a 1 second flow increment value; label 2 represents the low field value of the traffic running total; label 3 represents the high field value of the traffic running total; the label 4 indicates the actual value of the traffic integrated value.

Detailed Description

In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions of the embodiments of the present invention with reference to the drawings of the embodiments, and it is obvious that the described embodiments are a small part of the embodiments of the present invention, rather than all embodiments, and all other embodiments obtained by a person of ordinary skill in the art without creative work based on the embodiments of the present invention belong to the protection scope of the present invention.

A method for calculating a flow totalization procedure in stages, comprising the steps of: step 1: the instantaneous value of the flow is converted, the flow measurement signal accessed by a field measurement element through an analog quantity input template is converted into the instantaneous value of the flow in a program, and the temperature and pressure compensation calculation is carried out on the gas flow needing temperature and pressure compensation;

step 2: calling a flow accumulation function module, compiling the flow accumulation function module, and setting the function module as a timing interruption module;

and step 3: calculating a low field value of the flow cumulative value and a high field value of the flow cumulative value according to a certain method in the flow cumulative function block, and calculating an actual value of the flow cumulative value according to the low field value and the high field value;

and 4, step 4: and executing other logic programs, and continuing to execute other logic programs after the logic of the timed interrupt flow accumulation function block is executed.

In the step 2, the timer interrupt period of the timer interrupt module is 1 second, and the flow accumulation function module is called at intervals of 1 second to perform flow accumulation calculation for 1 time.

The step 3 of calculating the actual flow rate accumulated value includes the following steps:

(1) setting a label of a flow accumulation program, and setting four labels in a flow accumulation function block program: label 1 represents a 1 second flow increment value; label 2 represents the low field value of the traffic running total; label 3 represents the high field value of the traffic running total; label 4 represents the actual value of the traffic integrated value;

(2) calculating a flow increment value of 1 second, and if the flow instantaneous value is in hours in the flow accumulation function block program, the flow increment value of 1 second is labeled 1= flow instantaneous value ÷ 3600; if the instantaneous flow value is in minutes, a 1 second flow increment value, label 1= instantaneous flow value ÷ 60;

(3) calculating a low field value of the traffic cumulative value, wherein the label 2= label 1+ label 2;

(4) calculating a high field numerical value of the traffic cumulative value, and if a low field numerical value label 2 of the traffic cumulative value is greater than 10000 in the flow cumulative function block program, the high field numerical value of the traffic cumulative value is label 3= label 3+1, and the low field numerical value of the traffic cumulative value is label 2= label 2-10000;

(5) the actual value of the traffic cumulative value is calculated, in the traffic cumulative function block program, label 4= high field value label 3 × 10000 of the traffic cumulative value + low field value label 2 of the traffic cumulative value.

(6) In practical application, according to the requirements of the process, the zero clearing trigger condition of the flow integrated value can be that the low field value label 2 of the flow integrated value and the high field value label 3 of the flow integrated value are cleared simultaneously when the zero clearing is carried out according to the time (year, month and day) or the flow integrated value reaching a certain value.

In practical application, as shown in fig. 1, the flow of the segmented calculation flow accumulation program is as follows:

1: and (4) converting the instantaneous flow value. The flow measurement signals of the field measurement element accessed to the PLC system through the analog quantity input template are converted into flow instantaneous values, and temperature and pressure compensation calculation is carried out on the gas flow needing temperature and pressure compensation. The converted value is given to the tag 0.

2: and judging whether the scanning period reaches 1 second. If the time is up to 1 second, calling the flow accumulation function module for 1 time, executing the flow accumulation logic program, and then executing other logic programs, wherein the flow accumulation function module is a timed interruption function module; if the scanning period does not reach 1 second, other logic programs are continuously executed.

3: the label setting of the flow totalizer. Four tags are set in the flow totalization function block program: label 1 represents a 1 second flow increment value; label 2 represents the low field value of the traffic running total; label 3 represents the high field value of the traffic running total; the label 4 indicates the actual value of the traffic integrated value.

4: a 1 second flow increment value was calculated. In fig. 1, the instantaneous flow value is in hours, and the 1-second flow increment value is labeled 1= label 0 ÷ 3600.

5: and calculating a low field value of the traffic cumulative value. The low field value tag 2 of the traffic running total in the traffic running total function block program = tag 1+ tag 2.

6: and calculating a high field value of the traffic cumulative value. If the low field value label 2 of the traffic cumulative value is greater than 10000 in the traffic cumulative function block program, the high field value label 3 of the traffic cumulative value = label 3+1, and the low field value label 2 of the traffic cumulative value = labels 2-10000.

7: and calculating the actual value of the flow accumulated value. The actual value of the traffic running total, label 4= high field value label 3 × 10000+ low field value label 2.

8: and clearing the flow accumulated value. The zero clearing triggering condition of the flow accumulated value is that the accumulated value reaches 1 hundred million. When the label 4 is greater than or equal to 1 hundred million, the low field value label 2 of the flow accumulated value and the high field value label 3 of the flow accumulated value are cleared simultaneously, so that the flow accumulated value is cleared.

9: other logic routines are executed. And after the logic of the timed interruption flow accumulation function block is executed, other logic programs are continuously executed.

6页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种流体计数无磁机电转换装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!