A method and system for adaptively adjusting window width for signal numerical filtering
By dynamically adjusting the width of the filter window, the problem of difficulty in taking into account the stability and fast response of signal numerical filtering in instruments and instruments is solved, especially for the problem of zero flow self-propelled and slow calibration response speed of electromagnetic water meter, which improves the Productivity.
Patent Information
- Application Number
- CN202111591069.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-23
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2041-12-23
AI Technical Summary
The prior art is difficult to achieve the stability and fast response of signal numerical filtering in instruments and instruments at the same time, especially when zero excitation occurs, the problem of zero output auto-propelled and errors caused by slow calibration response speed are prone.
By obtaining the current and previous sampling signals of the instrument, filtering and calculating the deviation value, analyzing the signal stable state based on the comparison of the deviation value and the preset value, dynamically adjusting the filter window width to optimize the filtering algorithm, which is suitable for discrete comparison Large and requires stable and fast response scenarios.
It effectively solves the problems of zero flow self-propelled and slow calibration timing response speed of electromagnetic water meter, improves production efficiency, and achieves both stability and fast response of signal output.
Smart Images

Figure CN114244319B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of numerical filtering algorithms, and in particular relates to a window width adaptive adjustment method and system for signal numerical filtering. Background Art
[0002] After a constant physical quantity excitation passes through the primary and secondary instruments, ADC sampling and other processes, its numerical output has a certain degree of discreteness. Using conventional filtering algorithms, it can only choose one of the output stability and fast response performance. Many instruments require stable output under constant excitation, especially zero output under zero excitation, otherwise there will be a problem of zero excitation self-propelled; at the same time, when calibrating instruments, the start-stop method is used, and calibration errors will be introduced due to slow response speed when the excitation is turned on and off. Therefore, it is particularly urgent to design a filtering algorithm that can meet both performance requirements in the instrumentation industry. Summary of the invention
[0003] The object of the present invention is to provide a method and system for adaptively adjusting the window width for signal numerical filtering, which can solve the problem that stability and rapid responsiveness of the signal cannot be taken into account after passing through instruments.
[0004] The present invention provides a window width adaptive adjustment method for signal numerical filtering, comprising the following steps:
[0005] S1, obtaining a current sampling signal and a previous sampling signal of an instrument, and filtering the previous sampling signal by a filtering algorithm;
[0006] S2, compare the current sampling signal with the filtered signal to obtain a deviation value;
[0007] S3, comparing and analyzing the deviation value with the preset value, and determining the stable state of the sampling signal;
[0008] S4, changing the value of the filter window width of the filter algorithm according to different stable states, and using the updated filter algorithm to filter the current sampling signal.
[0009] Preferably, S2 specifically includes: setting the maximum filter window width of the filtering algorithm according to the discreteness of the sampling signal or the stability of the signal output, and when the discreteness of the sampling signal is greater or the stability of the signal output is higher, the value of the maximum filter window width is increased accordingly.
[0010] Preferably, S1 specifically includes: presetting a value N of the maximum filter window width, selecting N latest sampling signals and storing them in a queue in the order in which they enter in time.
[0011] Preferably, the S3 specifically includes:
[0012] If the deviation value between the current sampling signal and the filtered signal is less than the first constant preset value, and the current filter window width is less than the first preset value A, then the value of the filter window width plus B is used as the new filter window width, indicating that the flow rate flowing through the electromagnetic water meter at this time is a constant flow rate;
[0013] If the deviation value between the current sampling signal and the filtered signal is less than the first constant preset value, and the current filtering window width is not less than the first preset value A, the value of the filtering window width is kept unchanged;
[0014] If the deviation value between the current sampling signal and the filtered signal is between the first constant preset value and the second constant preset value, further determine whether the current filter window width is greater than 0.5A. If it is greater than 0.5A, subtract B from the filter window width as the new filter window width; otherwise, add B to the filter window width as the new filter window width;
[0015] If the deviation between the current sampled signal and the filtered signal is greater than the second constant preset value, the value of the filter window width is set to B as a new filter window width;
[0016] Among them, A and B are both natural numbers.
[0017] Preferably, the constant preset value is a minimum signal fluctuation value or 10% of the amplitude of a previous sampling signal.
[0018] Preferably, the values of A and B are 10 and 1 respectively.
[0019] Preferably, the instrument is an electromagnetic water meter.
[0020] The present invention provides a system for adaptively adjusting the window width of signal numerical filtering, wherein the system implements an adaptively adjusting method for the window width of signal numerical filtering, comprising:
[0021] A signal acquisition module, used to obtain the current sampling signal and the previous sampling signal of the instrument, and filter the previous sampling signal through a filtering algorithm;
[0022] A comparison module, used for comparing the current sampling signal with the filtered signal to obtain a deviation value;
[0023] A state determination module is used to compare and analyze the deviation value with the preset value and determine the stable state of the sampling signal;
[0024] The algorithm updating module is used to change the value of the filter window width of the filter algorithm according to different stable states, and use the updated filter algorithm to filter the current sampling signal.
[0025] The present invention provides an electronic device, comprising a memory and a processor, wherein the processor is used to implement the steps of a window width adaptive adjustment method for signal numerical filtering when executing a computer management program stored in the memory.
[0026] The present invention provides a computer-readable storage medium on which a computer management program is stored. When the computer management program is executed by a processor, the steps of a window width adaptive adjustment method for signal numerical filtering are implemented.
[0027] Compared with the prior art, a method and system for adaptively adjusting the window width for signal numerical filtering according to the present invention includes S1, obtaining the current sampling signal and the previous sampling signal of the instrument, and filtering the previous sampling signal through a filtering algorithm; S2, comparing the current sampling signal with the filtered signal to obtain a deviation value; S3, comparing and analyzing the deviation value with a preset value, and determining the stable state of the sampling signal; S4, changing the value of the filter window width of the filtering algorithm according to different stable states, and filtering the current sampling signal with the updated filtering algorithm. This solution is suitable for scenarios where the discreteness is large and the output is required to be stable, and at the same time, there is a requirement for a fast response to the output when the signal changes rapidly. In particular, the application of this solution can effectively solve the problem of electromagnetic water meters running at zero flow and the problem of long-term running of the meter due to slow response speed when switching valves during calibration, thereby improving production efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 A flow chart of a method for adaptively adjusting window width for signal numerical filtering provided by the present invention;
[0029] Figure 2 A schematic diagram of the hardware structure of a possible electronic device provided by the present invention;
[0030] Figure 3 A schematic diagram of the hardware structure of a possible computer-readable storage medium provided by the present invention;
[0031] Figure 4 A flow chart of a window width adaptive adjustment method for signal numerical filtering provided by the present invention applied to an electromagnetic water meter. DETAILED DESCRIPTION
[0032] The specific implementation modes of the present invention are described in detail below in conjunction with the accompanying drawings, but it should be understood that the protection scope of the present invention is not limited by the specific implementation modes.
[0033] Unless explicitly stated otherwise, throughout the specification and claims, the term “comprise” or variations such as “include” or “comprising”, etc., will be understood to include the stated elements or components but not to exclude other elements or components.
[0034] like Figure 1 As shown, a method for adaptively adjusting the window width for signal numerical filtering according to a preferred embodiment of the present invention includes S1, obtaining the current sampling signal and the previous sampling signal of the instrument, and filtering the previous sampling signal through a filtering algorithm; S2, comparing the current sampling signal with the filtered signal to obtain a deviation value; S3, comparing and analyzing the deviation value with a preset value, and determining the stable state of the sampling signal; S4, changing the value of the filter window width of the filtering algorithm according to different stable states, and filtering the current sampling signal with the updated filtering algorithm. This solution is suitable for scenarios where the discreteness is large and the output is required to be stable, and at the same time, there is a requirement for a fast response to the output when the signal changes rapidly. In particular, the application of this solution can effectively solve the problem of electromagnetic water meters running at zero flow and the problem of long-term running of the meter due to slow response speed when switching valves during calibration, thereby improving production efficiency.
[0035] By applying the method of adaptively adjusting the filter window width to signal numerical filtering, it is suitable for scenarios where the discreteness is large and the output is required to be stable, and at the same time, the output needs to respond quickly when the signal changes rapidly.
[0036] Among them, by comparing the signal after mean filtering calculation with the new sampling signal, the sampling signal is divided into three situations: constant, non-constant small fluctuation and non-constant violent fluctuation. The maximum window width N is adjusted according to the actual situation. The greater the discreteness of the sampling signal or the higher the stability requirement of the output, the larger the value of N can be appropriately adjusted.
[0037] According to the value of the maximum filter window width N, select the N latest sampled signals and queue them in the order of entry. Then perform mean filtering on the amplitude of the sampled signal that enters later. Compare the latest sampled signal with the signal after mean filtering, and divide the signal state into constant, non-constant small fluctuations, and non-constant violent fluctuations according to the step difference deviation after comparison. Then combine the current maximum filter window width to update the new filter window width.
[0038] Constant judgment condition, minimum fluctuation U 波动Adjust according to the discreteness of the sampled signal, especially the discreteness of the signal under zero excitation conditions, so that the signal output is stable and zero output under zero excitation conditions can be guaranteed. For constant judgment conditions and non-constant and severe judgment conditions, the signal deviation a%, b% is adjusted according to the output response speed requirements. If the response speed requirements are high, the values of a%, b% can be appropriately reduced. a and b can be set based on experience.
[0039] The following describes the method in detail by applying it to an electromagnetic water meter. Figure 4 As shown:
[0040] Electromagnetic water meters require stable flow display when the flow is constant, and require rapid response when the flow changes. Through embedded software control hardware forward and reverse excitation, signal conditioning and ADC sampling, the flow signal is converted into a voltage step difference, and the algorithm of the present invention is used to perform numerical filtering on the signal step difference.
[0041] The specific method is:
[0042] The first step is to judge the flow rate. Compare the new step difference with the filtered step difference to get the deviation, and judge whether the constant current is achieved by the deviation.
[0043] If the judgment result is within the normal fluctuation range and the current filter window width is less than 10, the value of the filter window width is increased by 1 as the new filter window width, indicating that the flow rate flowing through the electromagnetic water meter is a constant flow rate, that is, a stable and normal state;
[0044] If the deviation is within the normal fluctuation range and the current filter window width is not less than 10, the filter window width value remains unchanged;
[0045] If the deviation exceeds the normal fluctuation range, the result is judged to be non-constant current or the fluctuation is non-violent fluctuation, then the value of the filter window width is reduced by 1 as the new filter window width;
[0046] If the judgment result is that the current is not constant and fluctuates violently, the filter window width is updated to 1 as the new filter window width, and the maximum filter window width is set to 10;
[0047] If the judgment result is non-constant current and the fluctuation is not severe, then further judge whether the current filter window width is greater than 5. If it is greater than 5, the filter window width is reduced by 1 as the new filter window width, otherwise the filter window width is increased by 1 as the new filter window width.
[0048] The second step is to update the filtering algorithm with the new filtering window width and filter the new traffic signal.
[0049] Among them, the specific method of judging whether the constant current is constant or not by the deviation size is:
[0050] When the deviation between the step difference of the new sampled signal and the step difference of the filtered signal is less than 0.25V or within ±10%, it is judged as constant current;
[0051] When the deviation between the step difference of the new sampled signal and the step difference of the filtered signal is between ±10% and ±20%, it is judged as non-constant current and the fluctuation is not severe;
[0052] If the deviation between the step difference of the newly sampled signal and the step difference of the filtered signal is greater than ±20%, it is judged as non-constant current and the fluctuation is severe.
[0053] The application of this algorithm effectively solves the problem of electromagnetic water meters running at zero flow and the problem of long running times due to slow response speed when opening and closing valves during calibration, thereby improving production efficiency.
[0054] Specifically, the hardware forward and reverse excitation is controlled by embedded software (when the fluid flows in the pipeline, forward and reverse induced voltages are generated on the electrodes installed orthogonal to the direction of the magnetic field), and the flow signal is converted into a voltage step difference (of the electrical signal) by (differential) signal conditioning and ADC sampling (the difference between the mean values of the forward and reverse induced voltages is used as). The algorithm of the present invention is used to perform numerical filtering on the signal step difference, i.e., the voltage step difference. The specific method is that if it is a normal fluctuation of the constant flow, the window width is increased by 1, if it is a non-constant flow fluctuation and non-violent fluctuation, the window width is reduced by 1, if it is a violent fluctuation, the window width is set to 1, and the maximum window width is set to 10. The deviation between the step difference of the newly sampled signal and the step difference of the filtered signal is less than 0.25V or ±10% as a constant current condition, otherwise, the step difference of the newly sampled signal and the step difference after filtering is less than the deviation of ±20% as a judgment of the severity of the non-constant current fluctuation. (The electromagnetic water meter sets the starting flow rate to 50L / h, and the points with a value less than 50L / h are set to 0. The step difference collected in the zero flow condition is discrete, which will produce many sampling points greater than 50L / h, causing the problem of self-propelled flow. Assuming that the sample variance is S, the window width is intelligently set to 10 based on the sample obtained during program operation. According to statistical principles, the discreteness of the result of mean filtering with a window width of 10 is reduced, and the variance is S / 10, which can control all points below 50L / h, effectively solving the problem of zero flow self-propelled flow.) (When the flow changes, the program will intelligently adjust the filter window width according to the flow change, so that the flow measurement can immediately respond to the change in the actual flow.)
[0055] See also Figure 2 Schematic diagram of an electronic device provided by an embodiment of the present invention. Figure 2As shown, an embodiment of the present invention provides an electronic device, including a memory 1310, a processor 1320, and a computer program 1311 stored in the memory 1310 and executable on the processor 1320. When the processor 1320 executes the computer program 1311, the following steps are implemented: S1, obtaining a current sampling signal and a previous sampling signal of an instrument, and filtering the previous sampling signal by a filtering algorithm;
[0056] S2, compare the current sampling signal with the filtered signal to obtain a deviation value;
[0057] S3, comparing and analyzing the deviation value with the preset value, and determining the stable state of the sampling signal;
[0058] S4, changing the value of the filter window width of the filter algorithm according to different stable states, and using the updated filter algorithm to filter the current sampling signal.
[0059] See also Figure 3 Schematic diagram of an embodiment of a computer-readable storage medium provided by the present invention. Figure 3 As shown, this embodiment provides a computer-readable storage medium 1400, on which a computer program 1411 is stored. When the computer program 1411 is executed by a processor, the following steps are implemented: S1, obtaining a current sampling signal and a previous sampling signal of an instrument, and filtering the previous sampling signal by a filtering algorithm;
[0060] S2, compare the current sampling signal with the filtered signal to obtain a deviation value;
[0061] S3, comparing and analyzing the deviation value with the preset value, and determining the stable state of the sampling signal;
[0062] S4, changing the value of the filter window width of the filter algorithm according to different stable states, and using the updated filter algorithm to filter the current sampling signal.
[0063] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0064] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0065] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0066] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0067] The foregoing description of specific exemplary embodiments of the present invention is for the purpose of illustration and demonstration. These descriptions are not intended to limit the present invention to the precise form disclosed, and it is clear that many changes and variations can be made based on the above teachings. The purpose of selecting and describing the exemplary embodiments is to explain the specific principles of the present invention and its practical application, so that those skilled in the art can realize and utilize various different exemplary embodiments of the present invention and various different selections and changes. The scope of the present invention is intended to be limited by the claims and their equivalents.
Claims
1. A method for adaptively adjusting window width for signal numerical filtering, characterized in that: The following steps are involved: S1, obtaining a current sampling signal and a previous sampling signal of an instrument, and filtering the previous sampling signal by a filtering algorithm; S2, compare the current sampling signal with the filtered signal to obtain a deviation value; S3, comparing and analyzing the deviation value with the preset value, and determining the stable state of the sampling signal; S4, changing the value of the filter window width of the filtering algorithm according to different stable states, and using the updated filtering algorithm to filter the current sampling signal; The S3 specifically includes: If the deviation value between the current sampling signal and the filtered signal is less than the first constant preset value, and the current filter window width is less than the first preset value A, then the value of the filter window width plus B is used as the new filter window width, indicating that the flow rate flowing through the electromagnetic water meter at this time is a constant flow rate; If the deviation value between the current sampling signal and the filtered signal is less than the first constant preset value, and the current filtering window width is not less than the first preset value A, the value of the filtering window width is kept unchanged; If the deviation value between the current sampling signal and the filtered signal is between the first constant preset value and the second constant preset value, further determine whether the current filter window width is greater than 0.5A. If it is greater than 0.5A, subtract B from the filter window width as the new filter window width; otherwise, add B to the filter window width as the new filter window width; If the deviation between the current sampled signal and the filtered signal is greater than the second constant preset value, the value of the filter window width is set to B as a new filter window width; The values of A and B are 10 and 1 respectively.
2. The window width adaptive adjustment method for signal numerical filtering according to claim 1, characterized in that: The S2 specifically includes: setting the maximum filter window width of the filtering algorithm according to the discreteness of the sampling signal or the stability of the signal output, and when the discreteness of the sampling signal is greater or the stability of the signal output is higher, the value of the maximum filter window width is increased accordingly.
3. The window width adaptive adjustment method for signal numerical filtering according to claim 1, characterized in that: The S1 specifically includes: presetting a maximum filter window width value N, selecting N latest sampling signals and storing them in a queue in the order in which they enter in time.
4. The method for adaptively adjusting window width for signal numerical filtering according to claim 1, characterized in that: The instrument is an electromagnetic water meter.
5. A system for adaptively adjusting window width for signal numerical filtering, characterized in that: The system implements the window width adaptive adjustment method for signal numerical filtering according to any one of claims 1 to 4, comprising: A signal acquisition module, used to obtain the current sampling signal and the previous sampling signal of the instrument, and filter the previous sampling signal through a filtering algorithm; A comparison module, used for comparing the current sampling signal with the filtered signal to obtain a deviation value; A state determination module is used to compare and analyze the deviation value with the preset value and determine the stable state of the sampling signal; The algorithm updating module is used to change the value of the filter window width of the filter algorithm according to different stable states, and use the updated filter algorithm to filter the current sampling signal.
6. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the processor is used to implement the steps of the window width adaptive adjustment method for signal numerical filtering as described in any one of claims 1 to 4 when executing a computer management program stored in the memory.
7. A computer-readable storage medium, characterized in that: A computer management program is stored thereon, and when the computer management program is executed by a processor, the steps of the window width adaptive adjustment method for signal numerical filtering as described in any one of claims 1 to 4 are implemented.
