Weighing signal switching and filtering processing method for electronic balance
Technical Field
The invention relates to a weighing signal switching and filtering processing method for an electronic balance, and belongs to the technical field of electronic balance measurement.
Background
As a high-precision mass measuring instrument, the electronic balance is widely applied to daily life, factory production and scientific research. The working principle is that the weight of an object is converted into a measurable electric signal through the weighing sensor, and then the measurable electric signal is converted into a digital signal through an analog number, so that the weight of the object is obtained. The method has the characteristics of reliable weighing accuracy, quick and clear display, good stability and the like.
In the measurement of a high-precision balance, due to the influences of interference diversity, system uncertainty and the like, data obtained from the output of a weighing sensor needs to be filtered to meet the high-precision requirement. The conventional common technology generally adopts a sliding mean filtering method with low complexity and small calculated amount for filtering, and the principle is as follows: taking N measured data as a data queue with fixed length, putting the new sampled data at the tail of the queue every time new sampling is carried out, removing one data at the head of the queue, and then averaging. The algorithm has the advantages of good inhibition effect on periodic interference and high smoothness, and has the defects of low sensitivity, the larger the N value is, the better the filtering effect is, but when the N value is larger, the measurement sensitivity is greatly reduced. In particular, when the weighing object is loaded or unloaded, the reaction is slow, and the quick response and the balance cannot be realized. In addition, various interferences in the weighing process of the balance are difficult to be solved completely by using a filtering method.
Disclosure of Invention
The invention aims to provide a weighing signal switching filtering processing method for an electronic balance, which can be combined with the technologies of mean filtering, sliding mean filtering and variable sampling period, improve the inhibition effect on impulse interference and the sensitivity of balance weighing and achieve quick response and balance.
In order to solve the problems, the technical scheme adopted by the invention is as follows:
a weighing signal switching and filtering processing method for an electronic balance comprises the following steps:
step 1, initializing, defining change value thresholds E1, E2, E3, E1> E2> E3, and defining a sampling period; emptying the sliding data queue, wherein the current value C is 0, E1 indicates that the value of the weighing sensor changes greatly, the weighed object changes, E2 indicates that the value of the weighing sensor changes and tends to converge, and E3 indicates that the weighing is stable when the value of the change is smaller than the value;
step 2, data acquisition, multiple sampling mean filtering to obtain a value X, continuously sampling to obtain M data, removing the maximum value and the minimum value, and then taking a mean value, namely
Step 3, calculating a variation value e ═ abs (X-C);
step 4, if E is larger than E1, emptying the sliding queue, and if C is equal to X, turning to step 2;
step 5, if e>E2, emptying the sliding queue when entering for the first time, adopting a short sliding mean filtering method, assigning the result to C, and turning to step 2, wherein the short sliding mean means that the sampling data is less, the sliding mean filtering means that N measurement data are used as a data queue with a fixed length, each time new sampling is carried out, the new sampling data are placed at the tail of the queue, meanwhile, one data at the head of the queue is removed, and then the average value is obtained, namely
Step 6, if E > is E3, emptying the sliding queue when entering for the first time, assigning the result to C by adopting a long sliding mean filtering method, and turning to step 2, wherein the long sliding mean means that the sampling data is more;
and 7, if E is less than E3, adopting long sliding mean filtering, assigning the result to C, and turning to the step 2.
Further, in step 6, fast sampling is used, and the sampling time is less than a predetermined sampling period.
Further, in step 7, slow sampling is used, and the sampling time is greater than a predetermined sampling period.
The principle of the invention is that the method partitions according to the variation of the acquired value of secondary sampling before and after weighing when the electronic balance weighs, switches and uses different digital filtering technologies according to the data characteristics of different intervals, and adopts mean filtering when the measured value variation is large; for the small change value, the sliding average algorithm of the variable length queue is adopted when the change value tends to be stable, and the step length of the sampling period is variable; in the stable region, a long sliding mean filtering method is adopted, so that the problem of each region is solved.
Compared with the prior art, the invention has the beneficial effects that:
according to the rule that the data of the weighing sensor changes during the weighing of the balance, the multi-stage partition is carried out, different digital filtering methods are adopted for each partition, the inhibition effect on the pulse interference is improved, various noise interferences in the weighing process can be effectively inhibited, the response speed and sensitivity of the weighing data are improved, and the sensitivity and stability of the electronic balance are improved.
Drawings
Fig. 1 is a flow chart of a weighing signal switching filtering processing method for an electronic balance according to the present invention.
Detailed Description
The invention is described in further detail below with reference to the figures and specific examples. The objects, aspects and advantages of the present invention will become more apparent from the following description. It should be understood that the described embodiments are preferred embodiments of the invention, and not all embodiments.
A weighing signal switching and filtering processing method for an electronic balance comprises the following steps:
step 1, initializing, defining change value thresholds E1, E2, E3, E1> E2> E3, and defining a sampling period; the queue length of the short sliding mean is ShortQueueLength which is 3, and the queue length of the long sliding mean is QueueLength which is 9; emptying the sliding data queue; the sliding queue emptying flag clearQueueFlag is 1, and the number DataCount of the effective data of the sliding data queue is 0; the current value weighing data value C is 0;
step 2, data acquisition, multiple sampling mean filtering, continuously obtaining three data X1, X2 and X3 from the weighing sensor, removing the maximum value and the minimum value of the three data, leaving one value, and assigning the value to a variable X;
step 3, calculating a variation value e-abs (X-C);
step 4, if E is larger than E1, emptying the sliding queue, wherein ClearQueueFlag is 1, DataCount is 0, and C is X, and the process goes to step 2;
step 5, if E > E2, the length of the sliding data queue is ShortQueueLength,
(1) if ClearQueueFlag ═ 1, then clear the sliding data queue, ClearQueueFlag ═ 0, DataCount ═ 0,
(2) the variable X value is placed at the tail of the sliding data queue, the data at the head of the queue is removed, DataCount + +, if DataCount > ShortQueueLength the DataCount ═ ShortQueueLength,
(3) calculating C which is the sum/DataCount of the DataCount data, and turning to the step 2;
step 6, if E > -E3, the length of the sliding data queue is QueueLength, the sampling period can be reduced appropriately,
(1) if ClearQueueFlag ═ 1, then clear the sliding data queue, ClearQueueFlag ═ 0, DataCount ═ 0,
(2) putting the variable X value at the tail of the sliding data queue, removing the data at the head of the queue, DataCount + +, if DataCount > QueueLength the n DataCount ═ QueueLength,
(3) calculating C which is the sum/DataCount of the DataCount data, and turning to the step 2;
step 7, if E < E3, the length of the sliding data queue is QueueLength, the sampling period can be increased appropriately,
(1) putting the variable X value at the tail of the sliding data queue, removing the data at the head of the queue, DataCount + +, if DataCount > QueueLength the n DataCount ═ QueueLength,
(2) and C is calculated as the sum/DataCount of the DataCount data, and the step 2 is carried out.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not intended to limit the scope of the present invention, and it is obvious that any person skilled in the art can easily conceive of alternative or modified embodiments based on the above embodiments and these should be covered by the present invention.