Application of PLC in flow display and cumulative metering

Application of PLC in flow display and cumulative metering At present, PLC ( Programmable Logic Controller ) has been widely used in various industries such as steel, petroleum, chemical, electric power, building materials, machinery manufacturing, automobile, textile, transportation, environmental protection and culture and entertainment. It has high reliability and resistance. Strong interference, powerful, flexible, easy to learn and use, small size, light weight, low price, also has a wide range of applications in flow metering, and has its own unique programming when used for traffic accumulation, below Detailed analysis and discussion, including examples of programming on the Siemens S7-200 CPU .


The signal output by the flowmeter is generally a pulse signal or a 4-20 mA current signal. Both of these signals output instantaneous flow (also useful as relay output cumulant signal, the principle is the same, no further
description ), our purpose is in the PLC Calculate and display the instantaneous flow value and calculate the cumulative value. When the input signal is a pulse signal, when calculating the instantaneous flow rate, it must be calculated according to a strict time interval to ensure the accuracy of the instantaneous flow. Therefore, when calculating the instantaneous flow rate It must be done with a timed interrupt, and only one interrupt program can be run in the PLC system, no other interrupts are allowed to be generated (even low priority interrupts are not allowed), to prevent interference with the time interval of the timer interrupt. Accuracy, the calculation of instantaneous flow is to convert the cumulative number of pulses in this period into the cumulative flow, and divide by the time is the instantaneous flow, for the 4-20mA input only need to be converted according to its corresponding range, you can directly get the instantaneous flow, Cumulative traffic is the cumulative flow that accumulates in each time period is the cumulative flow. We must pay attention to the following questions in the course of the actual use of PLC programming:

1. Is the input pulse frequency range outside the range received by the PLC;


2. How to ensure the calculation is correct when the PLC high-speed counter reaches the maximum count value;


3. How to ensure that the timed interrupt is not disturbed;


4. How to avoid calculating the error of the accumulated amount;


5. The maximum cumulative number of accumulated amounts;


6. How to reset the cumulative amount;


The following is a detailed description of the most critical 2, 4, and 6 problems. Take the
Siemens S7-200 CPU224 as an example. The CPU 224 of the S7-200 has six single-phase high-speed counters with a maximum of 30 kHz, but the corresponding algorithms are not provided internally by the PLC. Calculate the frequency, therefore, you need to calculate the calculation yourself. This requires the PLC high-speed counter to ensure the correctness of the calculation when the maximum count value is reached. In actual programming, the high-speed counter is continuously counted after it is initialized, and is no longer performed. For any intervention, the initialization procedure for its high-speed counter is as follows:


Note: This section of the program should be executed in the program executed by the PLC during the first scan cycle.


It is necessary to judge whether the high-speed counter reaches the maximum count value. The high-speed counter of the S7-200CPU can be accumulated repeatedly. The highest bit is the sign bit, and the minimum value is 7FFFFFFF. Since the counter is always accumulated, it is impossible to read this time. The count value is smaller than the last count value. Therefore, if the current value of the counter is smaller than the previous count value, it can be judged whether the count reaches the inflection point of the maximum value (7FFFFFFF). If it is reached, special calculation is performed to eliminate the calculation. The error, as shown in the following program, when the current count value is greater than or equal to the last count value, the two count values ​​are poor, and the difference between the counts of the program's two scan intervals is obtained, and the current count value is assigned to the last time. On the count value; when the current count value is less than the last count value, calculate the difference between the last count value and 7FFFFFFF (with subtraction), and the difference between the current count value and 7FFFFFFF (with addition), and then The sum of the two results is the difference between the counts of the two scan intervals of the program, so that the cumulative count value is reached. Correct calculation of points.


Note: This program should be executed in a timed interrupt subroutine.


In fact, in the field application, the timer interrupt subroutine is executed with a 250ms interrupt. When using SMB34 for control, it should be noted that the system must only guarantee that the interrupt is unique and will not be affected by other interrupts. Otherwise, the periodic interrupt may not be on time due to the influence of other interrupts, thus affecting the accuracy.


Through the above calculation, the number of pulses sent by the flowmeter within 250ms is obtained. This value is multiplied by the pulse equivalent is the flow value within 250ms, and the time divided by the instantaneous flow rate. In addition, the cumulative program can be calculated within 250ms. Cumulative flow, in the process of calculating the cumulative flow need to avoid the calculation error of the accumulation process, we know that the flow accumulation is a value that has been accumulated, generally accumulates to 8 digits, and the effective number of floating point numbers inside the PLC It is 6 bits. When the cumulant value is large, it will cause a large number and a decimal number to be added, which will inevitably lead to the loss of the effective number of decimals, resulting in a large cumulative error. Therefore, avoid adding large numbers and decimals. The situation arises. The solution is to use multiple flow accumulators, which only allow the same magnitude of values ​​to be added, thus avoiding the loss of the effective number of bits. In the actual programming, 5 accumulators are used. According to the common flow, the cycle is interrupted. The flow rate flowing within the time interval (250ms) is multiplied by 15 as the upper limit of the first accumulator, after reaching the upper limit of the accumulator , accumulating the value of this accumulator to the second accumulator, and clearing the first accumulator, the same for the third accumulator, and the fourth accumulator for storing the cumulant fractional part, The five accumulators are used to store the value of the cumulant integer part, so that only the integer part and the small tree part can be displayed when the total cumulant is displayed. The whole process fully avoids the addition of large numbers and decimals in the accumulation process. In actual engineering, the number of accumulators to be used is determined according to the size of the flow and the time interval of the periodic interruption, and the integer part of the accumulator is represented by a double integer. The range of the double integer is -2,147,483,648. Up to +2,147,483,647, therefore, the number of integer digits of the accumulator can be made 9 bits, so that the cumulative amount of 9-bit integers and the cumulative amount of fractions of 6 bits can be displayed at the time of displaying the cumulative amount. A total of 15 bits, omitting the accumulator multiplier factor makes reading easier.


The accumulator needs to be reset under certain conditions, accumulate to the maximum value or manually reset, and judge whether the accumulated amount reaches the maximum number of digits in the interrupt program. When the maximum value is exceeded, each accumulator is cleared, and the trigger is cleared. The signal can also be a manual trigger.

Welcome to negotiate 0755-83556423 fax: 0755-83556424-8 88

QQ Email: Chen S 18680319086        Http://

'PLC application in flow display and cumulative metering

Komatsu Engine Parts

Komatsu Engine Parts,Komatsu Engine,Komatsu Engine Spare Parts,Engineering Machine Parts

JINING SHANTE SONGZHENG CONSTRUCTION MACHINERY CO.LTD , https://www.huaxinbrush.com

This entry was posted in on