The present disclosure relates to the technical field of automatic medicine cabinets, and in particular to a method for weighing traditional Chinese medicines in loose and small packages.
Traditional Chinese medicine (hereinafter referred to as TCM), which has a long history in China, is one of the three quintessences in Chinese culture. As a valuable asset of Chinese medicine, TCM has always enjoyed great popularity among patients. With the development of the age and the continuous progress of science and technology, traditional TCM decoction pieces have been transformed into new modem TCM ones, and small packages of TCM decoction pieces have emerged thereby. Small packages of TCM has many advantages, such as unchanged medicine character, accurate dosage, facilitating review, cleanness and hygiene, convenient dispensing, and improving efficiency, which have been widely used in medical institutions in recent decades and received very positive responses, seeing an extremely promising development prospect.
In the prior art, in order to improve the efficiency of TCM prescription filling and dispensing, many kinds of automatic TCM cabinets and automatic prescription filling devices have emerged. For example, an automatic medicine dispensing device with full-coverage chuck array and the control method thereof is provided in the previous application No. 201910614948.9 claimed by the applicant, wherein a full-coverage vacuum suction robot is disclosed, and this method uses this robot to grasp medicine packages and weighs the small packages of TCM by using an electronic weighing device and by controlling a vacuum-chuck air circuit, so as to obtain a specified number of medicine packages.
In the prior art, when vacuum chucks are used to grasp small packages of TCM, it cannot guarantee that each vacuum chuck can successfully grasp the medicine package, so when the vacuum chuck is controlled to release the medicine package, a problem may come out that a number of medicine packages dropped on the electronic weighing device may be inconsistent with the required number of medicine packages, thus affecting the time for prescription filling.
In addition, the electronic weighing device in the prior art will go through an unstable oscillation period if any medicine packages fall on it, during which there would be a large weighing error. In order to prevent the weighing accuracy from being affected by an electronic scale's oscillation caused by dropping medicine packages, usually, the practice in the prior art is to sample and calculate after the electronic scale resumes stability. However, waiting for the electronic scale to stabilize is time consuming and reduces the efficiency of prescription filling.
In order to solve the problem that the electronic scale has to wait until stabilized for weighing in the traditional weighing method, a dynamic weighing method is disclosed in a method for dynamic weighing of TCM in loose small packages with the patent No. 202010706273.3. Based on the traditional least square identification model, this method adopts a recursive algorithm which can reduce computing resources and overheads to a certain degree, thus reducing the weighing time and improving the weighing efficiency. However, it still works with current-time scalar prediction errors of the traditional identification model, which has a defect of low data utilization, so that the coefficient identification efficiency of this weighing model needs further improvement.
In addition, in the traditional identification model, a current-time scalar prediction error is used for recursive iteration every time and fails to effectively use an overall data change trend within the local neighborhood and the vector prediction error information, thus resulting in problems such as slow convergence of weighing model coefficients and large fluctuation of steady-state errors.
For this purpose, the present disclosure aims at providing a method for quick weighing of loose and small packages of traditional Chinese medicine (TCM) in order to solve technical problems, i.e., to further improve the weighing accuracy and reduce the weighing time of loose and small packages of TCM.
According to the present disclosure, the method for quick weighing of loose and small packages of TCM includes:
Wherein, m is the equivalent mass of the medicine receiving tank; M is the mass of medicine packages to be weighed; y(t) is the output signal of the weighing system; g is the gravitational acceleration; c is the equivalent damping coefficient of the weighing system; k is the equivalent elastic coefficient of the weighing system; when loose and small packages of TCM fall on the medicine receiving tank, the medicine packages will vibrate synchronously with the weighing system represented by the medicine receiving tank, which may be regarded as applying a step signal Mgu(t) to the weighing system, wherein u(t) represents the step signal; after Laplace transformation, the output signal is obtained as follows:
Since the sampled signal is a discrete value, Z transformation is performed for Y(s) so as to obtain:
Wherein a1, a2, b1, and b2 are coefficients related to M, m, c, and k; and taking into account a weighing error caused by noise at an input terminal, the formula (3) is expressed by a difference equation as:
y(t)=−a1y(t−1)−a2y(t−2)+b1u(t−1)+b2u(t−2)+e(t) (4)
In view of the formula (3) and according to the final-value theorem of the Z transformation, a system output in a steady state is obtained as follows:
As a result, a calculation formula is obtained for the mass of medicine packages to be weighed M as follows:
Wherein g is the gravitational acceleration, and k is the equivalent elastic coefficient of the weighing system;
e(t)=y(t)−[−â1y(t−1)−â2y(t−2)+{circumflex over (b)}1u(t−1)+{circumflex over (b)}2u(t−2)]=y(t)−φTt{circumflex over (θ)}t−1 (7)
In the formula t>2, wherein:
φt=[−y(t−1),−y(t−2),u(t−1),u(t−2)]T (8)
{circumflex over (θ)}t−1=[â1,â2,{circumflex over (b)}1,{circumflex over (b)}2]T (9)
φt represents an information vector of the system at a time of the tth sample point, {circumflex over (θ)}t−1 represents a coefficient identification result of the system at a time before the tth sample point; y(t) represents a sample output sequence at the tth sample point, y(t−1) represents a sample output sequence at a time before the tth sample point, y(t−2) represents a sample output sequence at two times before the tth sample point; u(t−1) is a sample output sequence at a time before the th sample point, u(t−2) is a sample output sequence at two times before the tth sample point; â1, is an estimated value of the coefficient a1, â2 is an estimated value of the coefficient a2, {circumflex over (b)}1 is an estimated value of the coefficient b1, and {circumflex over (b)}2 is an estimated value of the coefficient b2;
Wherein: pt is a length of time window; Ytp
Etp
It can be known from the formula (13) that the weighing system is based on an identification model of a vector prediction error:
Y
t
p
=ΦtTp
The formula (14) is expressed as the identification model of the vector prediction error:
Wherein ∥Etp
J({circumflex over (θ)}t−1)=(Zt−Ht{circumflex over (θ)}t−1)T(Zt−Ht{circumflex over (θ)}t−1) (18)
A vector differential formula is used to derive J({circumflex over (θ)}t−1) and set the result thereof as 0, so as to calculate {circumflex over (θ)}t−1 that may minimize the criterion function:
So that:
R
t
−1
=R
t−1
−1+Φtp
After the simplification of the above formula by using the matrix inversion theorem, a recursive formula for identifying coefficients based on the identification model of vector prediction error is finally obtained as follows:
Wherein Lt+1 is an algorithm gain vector; the coefficient estimation vector {circumflex over (θ)}t+1 at the time t+1 is the product of the gain vector Lt+1 and the vector prediction error EP, which corrects the coefficient estimation vector {circumflex over (θ)}t at the time t;
Here is the recursion process:
Further, the length of time window pt is determined by the method below:
A length interval of the time window of the tth sample time is defined as follows:
P
t∈[Pmin,Pmax] (25)
Wherein Pmin represents the lower limit value of the length interval, and Pmax represents the upper limit value of the length interval, i.e., the length of the time window pt can slide from Pmin to Pmax according to statistical characteristics of the sampled data;
A standard deviation of a sequence formed by d system sample output values previous to a time t is defined as follows:
Wherein, it can be seen from tests for d that the stability and smoothness of local data can be better reflected when d=5; yi represents a system sample output value at the ith sample time, and
An initial recursive time of the recursive algorithm is set as t0, and a sample standard deviation of d pieces of data previous to the initial time by the formula (26), which is set as St0; and a self-adaptive function of the time window length is used to determine the time window length pt at the sample time t as follows:
Wherein,
represents a maximum integer not more than a real number
Further, in the recursion process, α=107, and the number of iteration times N is 8-10.
The present disclosure is beneficial in:
The present disclosure will be further described with reference to figures and embodiments below.
In this embodiment, a method for quick weighing of loose and small packages of TCM includes:
Wherein, m is the equivalent mass of the medicine receiving tank; M is the mass of medicine packages to be weighed; y(t) is the output signal of the weighing system; g is the gravitational acceleration; c is the equivalent damping coefficient of the weighing system; k is the equivalent elastic coefficient of the weighing system; when loose and small packages of TCM fall on the medicine receiving tank, the medicine packages will vibrate synchronously with the weighing system represented by the medicine receiving tank, which may be regarded as applying a step signal Mgu(t) to the weighing system, wherein u(t) represents the step signal. After Laplace transformation, the formula (1) obtains the output signal as follows:
Since the sampled signal is a discrete value, Z transformation is performed for Y(s) so as to obtain:
Wherein a1, a2, b1, and b2 are coefficients related to M, m, c and k. Taking into account a weighing error caused by noise at an input terminal, the formula (3) is expressed by a difference equation as:
y(t)=−a1y(t−1)−a2y(t−2)+b1u(t−1)+b2u(t−2)+e(t) (4)
In view of the formula (3) and according to the final-value theorem of the Z transformation, a system output in a steady state is obtained as follows:
As a result, a calculation formula is obtained for the mass of medicine packages to be weighed M as follows:
Wherein g is the gravitational acceleration, and k is the equivalent elastic coefficient of the weighing system. k, as a constant related to the weighing system, may be determined by experiment.
It can be known from the formula (6) that the key point of calculating the mass M of medicine packages to be weighed is identification of the weighing system coefficients a1, a2, b1, and b2.
e(t)=y(t)−[−â1y(t−1)−â2y(t−2)+{circumflex over (b)}1u(t−1)+{circumflex over (b)}2u(t−2)]=y(t)−φTt{circumflex over (θ)}t−1 (7)
In the formula t>2, wherein:
φt=[−y(t−1),−y(t−2),u(t−1),u(t−2)]T (8)
{circumflex over (θ)}t−1=[â1,â2,{circumflex over (b)}1,{circumflex over (b)}2]T (9)
φt represents an information vector of the system at a time of the tth sample point, {circumflex over (θ)}t−1 represents a coefficient identification result of the system at a time before the tth sample point; y(t) represents a sample output sequence at the tth sample point, y(t−1) represents a sample output sequence at a time before the tth sample point, y(t−2) represents a sample output sequence at two times before the tth sample point; u(t−1) is a sample output sequence at a time before the th sample point, u(t−2) is a sample output sequence at two times before the tth sample point; â1 is an estimated value of the coefficient a1, â2 is an estimated value of the coefficient a2, {circumflex over (b)}1 is an estimated value of the coefficient b1, and {circumflex over (b)}2 is an estimated value of the coefficient b2.
Wherein: pt is a length of time window; Ytp
Etp
It can be known from the formula (13) that the weighing system is based on an identification model of a vector prediction error:
Y
t
p
=ΦtTp
The formula (14) is expressed as the identification model of the vector prediction error.
Wherein ∥Etp
J({circumflex over (θ)}t−1)=(Zt−Ht{circumflex over (θ)}t−1)T(Zt−Ht{circumflex over (θ)}t−1) (18)
A vector differential formula is used to derive J({circumflex over (θ)}t−1) and set the result thereof as 0, so as to calculate {circumflex over (θ)}t−1 that may minimize the criterion function:
in the above formula will be great in amount, which decreases the identification speed. To solve these problems, the recursive calculation form is further derived for {circumflex over (θ)}t−1. It is set that:
So that:
R
t
−1
=R
t−1
−1+Φtp
After the simplification of the above formula by using the matrix inversion theorem, a recursive formula for identifying coefficients based on the identification model of vector prediction error is finally obtained as follows:
Wherein Lt+1 is an algorithm gain vector; the coefficient estimation vector {circumflex over (θ)}t+1 at the time t+1 is the product of the gain vector Lt+1 and the vector prediction error Et+1p
Here is the recursion process:
The only part of formulas (22) to (24) in the recursive formula that needs to be inverted is: [Ip
Compared with the traditional least square identification algorithm with an identification model y(t)=φTt{circumflex over (θ)}t−1+e(t) and a recursive form {circumflex over (θ)}t+1={circumflex over (θ)}t+Kt+1e(t+1), every recursive process of the identification algorithm based on the identification model of vector prediction error uses multiple times of sampled data within a time window range that has a length of pt and is previous to the time t, which enables higher data utilization, and increases coefficient identification accuracy and weighing efficiency.
The length of time window pt in this embodiment is determined by the method below:
p
t=[Pmin,Pmax] (25)
Wherein Pmin represents the lower limit value of the length interval, and Pmax represents the upper limit value of the length interval, i.e., the length of the time window pt can slide from Pmin to Pmax according to statistical characteristics of the sampled data;
A standard deviation of a sequence formed by d system sample output values previous to a time t is defined as follows:
Wherein, it can be seen from tests for d that the stability and smoothness of local data can be better reflected when d=5; yi represents a system sample output value at the ith sample time, and
An initial recursive time of the recursive algorithm is set as t0, and a sample standard deviation of d pieces of data previous to the initial time by the formula (26), which is set as St0; and a self-adaptive function of the time window length is used to determine the time window length pt at the sample time t as follows:
Wherein,
represents a maximum integer not more than a real number
According to the method for quick weighing of loose and small packages of TCM in this embodiment, the actual weighing is carried out, wherein an AD sample frequency of an electronic weighing signal is 80 HZ, and an AD sample result is as shown in
The identification method based on the identification model of the vector prediction error has been stable since the start of coefficient identification without any large oscillation. When the recursion proceeds to the 10th sample point, the coefficient estimated value has levelled off. By setting the actual mass of the medicine packages as M0, the weighing result obtained by the least square identification method is M1, and the weighing result obtained by the identification model of the vector prediction error is M2. Ten groups of data are respectively taken for analysis and comparison, and the comparison results are shown as follows:
It can be seen by comparison that the identification result based on the identification model of vector prediction error is fast in weighing speed, whereby the error rate is less than 2% at the 10th sample time and the weighing result thereafter is relatively stable; while the weighing result levels off for convergence after the 20th sample time in the traditional least square identification model which takes longer to weigh and results in a lower weighing efficiency than that of the method provided in the present disclosure. It can be seen from the weighing result data that the steady-state error data of the weighing result based on the traditional least square identification method fluctuates greatly, while the steady-state error data of the method provided in the present disclosure fluctuates less.
After the 10th sample time, the maximum error rate of the weighing method provided in the present disclosure is only 1.71%, which means the actual error mass is less than 1 g for a medicine package of a mass specification of 30 g. Since the objective is to obtain an accurate quantity of medicine packages when weighing and counting TCM packages without critical demand of the total mass data of packages, so the weighing method of the present disclosure does not affect the accurate counting of medicine packages, and the weighing accuracy of the method provided in the present disclosure fully satisfies the quick weighing requirement of loose and small TCM packages. The weighing method according to the present disclosure can make good use of the dynamic response characteristics of the system without having to wait for the signal to level off, and make full use of dynamic information of the system without too much consideration about setting the time, which makes it particularly suitable for meeting the requirement of quick TCM prescription filling and dispensing in traditional TCM pharmacies.
In addition, in practical application, since the recursive identification method based on the identification model of vector prediction error does not need to save all the sample values from the sample start time after acquiring new sample values every time, it has the advantages of a high calculation efficiency and a low memory overhead.
Finally, it is noted that the above embodiments are only for the purpose of illustrating the technical scheme of the present disclosure without limiting it, and those of ordinary skills in the art should understand that the modified scheme or equivalent alternative scheme substantially the same as the technical scheme of the present disclosure should also be included in the claim scope of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
202011269239.0 | Nov 2020 | CN | national |