Disclosure of Invention
The invention innovatively provides a direct-reading method of a photoelectric direct-reading counter based on low-order character wheel carry counting, which can greatly improve the reliability of a traditional gas flowmeter and avoid urban gas metering trade disputes; the power consumption is effectively reduced, the maintenance workload of the flowmeter is reduced, and the application scene of products is widened.
In order to solve the problems in the prior art, the invention provides a direct reading method of a photoelectric direct reading counter based on low-order character wheel carry counting, which comprises the following steps,
Step 1, powering up and initializing, and reading direct-reading values of all character wheel indication values of a counter, and synchronizing the direct-reading values as initial values into the direct-reading values of a mechanical counter and the count values of an electronic counter;
step2, selecting a low-order character wheel with a bit sequence of n as a reference-bit character wheel, and configuring a reading period T of an indication value of the reference-bit character wheel; and judging whether the time reaches the reading period T: if yes, executing the step 3; if not, entering into dormancy to wait for the next reading;
Step 3, the direct reading value of the mechanical counter is calculated as an original direct reading value M 0 and stored, and the counting value of the electronic counter is calculated as an original counting value C 0 and stored;
Step 4, reading indication values of the reference bit character wheel and all low bit character wheels, and updating and obtaining a new direct reading value M according to the original direct reading value M 0;
step 5, when the reference bit character wheel carries, counting according to the increment of the count value determined by the bit sequence of the reference bit character wheel, and calculating a new count value C of the electronic counter according to the indication values of the reference bit character wheel and all the low bit character wheels;
step 6, diagnosing and correcting the new direct reading value M and the new counting value C;
And 7, outputting the diagnosis information or the corrected direct-reading value and the count value, and then entering a dormant state to wait for the next reading.
Further, in the direct reading method of the photoelectric direct reading counter based on low-order character wheel carry counting, in the step 2, when the low-order reference character wheel is configured as a ten-bit character wheel, the bit sequence n=1;
when the bit sequence n of the low-order reference character wheel is one bit lower than the ten-bit character wheel, the value of the bit sequence n is gradually reduced by 1;
when the bit sequence n of the low-order reference character wheel is higher than the ten-bit character wheel by one bit, the value of the bit sequence n is gradually increased by 1;
According to the bit sequence of the reference character wheel, the reading period T is adjusted, and the value range of the reading period T is as follows: t is more than or equal to 2 and less than or equal to 16.
Furthermore, the invention discloses a direct reading method of a photoelectric direct reading counter based on low-order character wheel carry counting, wherein after the step 3, the method further comprises the step of judging whether a reference-order character wheel is faulty: if yes, selecting a high one-bit character wheel as a reference character wheel, and returning to the step 3; if not, step 4 is performed.
In step 4, when the read indication value of the reference character wheel is normal and no carry occurs, a new direct reading value M is obtained according to the read indication values of the reference character wheel and all the low character wheels and the original direct reading value M 0;
When the reference bit character wheel carries, reading the indication value of the character wheel one bit higher than the reference bit character wheel, and updating with the read indication values of the reference bit character wheel and all the low bit character wheels to obtain a new direct reading value M;
When the reference bit character wheel carries, and other high bit character wheels carry at the same time, reading the read indication value of the highest bit character wheel with the carry higher than the one bit character wheel and all the bit character wheels after the highest bit character wheel with the carry, and updating to obtain a new direct reading value M.
In step 5, the reference bit word wheel with the bit sequence of n carries, the electronic counter value increment of each carry is 10 n-1, then the values of all the low bit word wheels in the count value C 0 corresponding to the reference bit word wheel and the reference bit word wheel are cleared, and then the values are added with the reference bit word wheel and the indication values of all the low bit word wheels to obtain a new count value C;
And replaces the new count value C, which is not updated, into the original count value C 0 before updating the new count value C.
Further, in the direct reading method of the photoelectric direct reading counter based on low-order character wheel carry counting, in the step 6, an original direct reading value M 0 is compared with a new direct reading value M, and the difference value of the original direct reading value M and the new direct reading value M is calculated as delta 1=M-M0;
comparing the original count value C 0 with the new count value C, and calculating the difference between the two to be delta 2=C-C0;
Comparing the new count value C with the new direct-reading value M, and calculating the absolute value of the difference between the new count value C and the new direct-reading value M as Δ 3 =abs (M-C);
The increment for the next read cycle is counted as Δ V;
If delta 1≤ΔV、Δ2≤ΔV, and delta 3≤10n-2; then, it is determined that the new direct reading value M and the new count value C are both correct, let c=m, and then step 7 is executed.
Furthermore, the invention relates to a direct reading method of a photoelectric direct reading counter based on low-order character wheel carry counting, wherein
If Δ 1≤ΔV, but Δ 2>ΔV, and Δ 3≤10n-2, it is determined that the new direct reading value M is normal and the new count value C is abnormal, let c=m perform calibration, and then step 7 is performed.
Furthermore, the invention relates to a direct reading method of a photoelectric direct reading counter based on low-order word-wheel carry counting, wherein if delta 2≤ΔV, delta 1>ΔV and delta 3≤10n-2 are determined to be normal for a new count value C and abnormal for a new direct reading value M, M=C is calibrated, and then step 7 is executed.
Furthermore, the invention relates to a direct reading method of a photoelectric direct reading counter based on low-order character wheel carry counting, wherein if delta 1≤ΔV、Δ2≤ΔV and delta 3>10n-2 are adopted, the deviation between a new direct reading value M and a new counting value C is judged to be increased, for example, ABS (delta 1)<ABS(Δ2), and C=M is calibrated; like ABS (Δ 2)<ABS(Δ1), let m=c calibrate, then step 7 is performed.
Further, the invention relates to a direct reading method of a photoelectric direct reading counter based on low-order character wheel carry counting, wherein if delta 1>ΔV,Δ2>ΔV or delta 3>10n-2 is determined, a reading fault is judged, and the step 3 is returned; if the fault is read three times continuously, the fault is judged and the reading is stopped, and then the step 7 is executed.
Compared with the prior art, the direct reading method of the photoelectric direct reading counter based on low-order character wheel carry counting has the following advantages: the reference bit word wheel carry is adopted as a signal source of the electronic counter to count, so that the basis for diagnosing and calibrating the direct-reading value is obtained, and compared with the traditional direct-reading counter and the direct-reading mechanical counter adopting the pulse signal counter as the diagnosis and calibration, the digital counter has higher reliability; secondly, a method for reading the indication value of the higher character wheel based on the reference bit character wheel when the character wheel is carried is adopted, and compared with a traditional direct-reading counter for reading all the character wheels, the power consumption is effectively reduced; in addition, the reference bit character wheel can select the high one-bit character wheel as the reference bit character wheel when in fault, so that the accuracy of all bit data except the original fault reference bit character wheel bit number can be effectively ensured, and trade disputes can be effectively reduced.
The invention relates to a direct reading method of a photoelectric direct reading counter based on low-order character wheel carry counting, which is further described in detail below with reference to the specific embodiments shown in the drawings:
Detailed Description
It should be noted that the terms of up, down, front, back, left, right and the like in the present invention are merely described according to the drawings, so as to facilitate understanding, and are not limited to the technical solution of the present invention and the scope of protection claimed.
As shown in fig. 1, the embodiment of the direct reading method of the photoelectric direct reading counter based on low-order character wheel carry counting of the invention comprises the following steps,
Step 1, powering up and initializing, and reading direct-reading values of all character wheel indication values of a counter, and synchronizing the direct-reading values as initial values into the direct-reading values of a mechanical counter and the count values of an electronic counter;
The direct-reading value of the mechanical counter comprises an original direct-reading value M 0 and a new direct-reading value M, and the new direct-reading value M replaces a value stored before the original direct-reading value M 0 before updating; the count value of the electronic counter includes an original count value C 0 and a new count value C, and the new count value C replaces the value stored before the original count value C 0 before updating. In order to prevent data loss, the original direct-reading value M 0 and the new direct-reading value M can be stored in a mechanical counter direct-reading value storage unit, the original count value C 0 and the new count value C are stored in an electronic counter count value storage unit, and the mechanical counter direct-reading value storage unit and the electronic counter count value storage unit can adopt nonvolatile memories. After initialization, m=c=c 0=M0, and C 0=M0 is consistent with the initial value of the counter wheel code wheel.
Step2, selecting a low-order character wheel with a bit sequence of n as a reference-bit character wheel, and configuring a reading period T of an indication value of the reference-bit character wheel; and judging whether the time reaches the reading period T: if yes, executing the step 3; if not, entering into dormancy to wait for the next reading;
in step 2, when the low-order reference character wheel is configured as a ten-bit character wheel, the bit order n=1;
when the bit sequence n of the low-order reference character wheel is one bit lower than the ten-bit character wheel, the value of the bit sequence n is gradually reduced by 1;
When the bit sequence n of the low-order reference character wheel is higher than the ten-bit character wheel by one bit, the value of the bit sequence n is sequentially added with 1.
In general, a ten-bit character wheel is preferably used as the reference character wheel, but when the ten-bit character wheel fails or the reading period is shorter than 2s due to the fast rotation speed, a single bit or a ten-bit character wheel can be selected as the reference character wheel, and the increment of the count value of the electronic counter is 10 n when the number of bits is carried.
In step 2, the reading period T is adjusted according to the bit sequence of the reference character wheel, and the value range of the reading period T is as follows: 2.ltoreq.T.ltoreq.16 to ensure that the reference bit word-wheel carries at most once in one read cycle.
Step 3, the direct reading value of the mechanical counter is calculated as an original direct reading value M 0 and stored, and the counting value of the electronic counter is calculated as an original counting value C 0 and stored;
after step 3, the method further comprises the step of judging whether the reference bit character wheel is faulty: if yes, selecting a high one-bit character wheel as a reference character wheel, and returning to the step 3; if not, step 4 is performed.
The faults in the step are faults of the reference bit character wheel or the faults are shorter than a reading period due to the fact that the rotating speed is high, the high-order bit character wheel is selected as the reference character wheel when the faults occur, and the accuracy of data of all bits except the original fault reference bit character wheel can be effectively guaranteed.
Step 4, reading indication values of the reference bit character wheel and all low bit character wheels, and updating and obtaining a new direct reading value M according to the original direct reading value M 0;
in step 4, when the read indication value of the reference bit word wheel is normal and no carry occurs, a new direct-reading value M is obtained according to the read indication values of the reference bit word wheel and all the low bit word wheels and the original direct-reading value M 0;
When the reference bit character wheel carries, reading the indication value of the character wheel one bit higher than the reference bit character wheel, and updating with the read indication values of the reference bit character wheel and all the low bit character wheels to obtain a new direct reading value M;
When the reference bit character wheel carries, and other high bit character wheels carry at the same time, reading the read indication value of the highest bit character wheel with the carry higher than the one bit character wheel and all the bit character wheels after the highest bit character wheel with the carry, and updating to obtain a new direct reading value M.
For ease of understanding, a counter is an integer number of 2 bits, e.g., 8. The direct-reading value of the counter and the count value of the electronic counter are 10-bit BCD codes, and the value stored in the storage unit of the original direct-reading value and the electronic count value is set as M0=C0=A1A2A3A4A5A6A7A8.A9A10;
If the reference bit word wheel is the nth bit (i.e., n=1 is the tenth bit, n=2 is the bit, n=3 is the percentile, and so on), the reference bit word wheel and the indication values of all other low bit word wheels are read after the reading period, if no carry occurs, the direct reading value of the reference bit word wheel and the indication values of the low bit word wheel are set to be a 10-n...a10, and then the updated counter direct reading value M is: m=a 1A2...A9-n+a10-n...a10*10-2;
If the reference bit character wheel carries, reading the indication value a 9-n of the character wheel higher than the reference bit character wheel, and updating the direct-reading value with the direct-reading value of the reference bit character wheel and all the low bit character wheel indication values to obtain the new M value :M=A1A2...A8-n*10n+a9- na10-n...a10*10-2;
If the reference bit character wheel carries, the first several bits carry at the same time, i.e. the first bit (set as the mth bit, where 1.ltoreq.m.ltoreq.7, m.ltoreq.1 is the highest bit A 1) of the highest bit character wheel and the indication values of all the following bit character wheels need to be read, the direct reading value of the indication value is a m...a8a9a10, the new direct reading value M of the counter is :M=A1...Am-1*109-m+amam+ 1...a8a9a10*10-2.
Step 5, when the reference bit character wheel carries, counting according to the increment of the count value determined by the bit sequence of the reference bit character wheel, and calculating a new count value C of the electronic counter according to the indication values of the reference bit character wheel and all the low bit character wheels;
In step 5, the reference bit word wheel with the bit sequence of n carries out carry, the electronic counter value increment of each carry is 10 n-1, then the values of the corresponding bit word wheel and all the low bit word wheels after the reference bit word wheel in the count value C 0 are cleared, and then the values are added with the indication values of the reference bit word wheel and all the low bit word wheels to obtain a new count value C;
For example: the reference bit word wheel with the bit sequence of n carries out carry, and the increment of the electronic counter value of each carry is 10 n -1; after the carry is set, the direct-reading coding value of the reference bit character wheel and all the low bit character wheels is a 10-n...a10, and then the new value C of the electronic counter is as follows: c=a 1A2...A9-n+a10-n...a10*10-2+10n-1.
And replaces the new count value C, which is not updated, into the original count value C 0 before updating the new count value C.
Step 6, diagnosing and correcting the new direct reading value M and the new counting value C;
Specifically, as shown in fig. 2, in step 6, the original direct-reading value M 0 is compared with the new direct-reading value M, and the difference between the two values is calculated as Δ 1=M-M0;
comparing the original count value C 0 with the new count value C, and calculating the difference between the two to be delta 2=C-C0;
Comparing the new count value C with the new direct-reading value M, and calculating the absolute value of the difference between the new count value C and the new direct-reading value M as Δ 3 =abs (M-C);
The increment for the next read cycle is counted as Δ V;
If delta 1≤ΔV、Δ2≤ΔV, and delta 3≤10n-2; then, it is determined that the new direct reading value M and the new count value C are both correct, let c=m, and then step 7 is executed.
If Δ 1≤ΔV, but Δ 2>ΔV, and Δ 3≤10n-2, it is determined that the new direct reading value M is normal and the new count value C is abnormal, let c=m perform calibration, and then step 7 is performed.
If Δ 2≤ΔV, but Δ 1>ΔV, and Δ 3≤10n-2, it is determined that the new count value C is normal and the new direct reading value M is abnormal, let m=c to calibrate, and then step 7 is performed.
If Δ 1≤ΔV、Δ2≤ΔV and Δ 3>10n-2, it is determined that the deviation between the new direct-reading value M and the new count value C increases, and if ABS (Δ 1)<ABS(Δ2) is used, c=m is calibrated; otherwise, if ABS (Δ 2)<ABS(Δ1), let m=c calibrate, then step 7 is performed.
If delta 1>ΔV,Δ2>ΔV or delta 3>10n-2, judging that the reading is faulty, and returning to the step 3; if the fault is read three times continuously, the fault is judged and the reading is stopped, and then the step 7 is executed.
And 7, outputting the diagnosis information or the corrected direct-reading value and the count value, and then entering a dormant state to wait for the next reading.
In summary, the invention obtains the basis for diagnosing and calibrating the direct-reading value by counting by using the reference bit word wheel carry as the signal source of the electronic counter, and has higher reliability compared with the traditional direct-reading counter and the direct-reading mechanical counter using the pulse signal counter as the diagnosis and calibration; secondly, a method for reading the indication value of the higher character wheel based on the reference bit character wheel when the character wheel is carried is adopted, and compared with a traditional direct-reading counter for reading all the character wheels, the power consumption is effectively reduced; in addition, the reference bit character wheel can select the high one-bit character wheel as the reference bit character wheel when in fault, so that the accuracy of all bit data except the original fault reference bit character wheel bit number can be effectively ensured, and trade disputes can be effectively reduced.
As shown in fig. 3, the invention further provides a direct-reading mechanical counter, which comprises an optoelectronic direct-reading processing module 1, an output communication interface 2, a counter housing 3, a character wheel set 4, a light receiving component 6, a light emitting component 7 and a transmission mechanism 8, wherein the optoelectronic direct-reading processing module 1, the output communication interface 2, the character wheel set 4, the light receiving component 6, the light emitting component 7 and the transmission mechanism 8 are arranged in the counter housing 3. Wherein the character wheel group 4 is composed of a plurality of character wheels, as shown in fig. 3, wherein a lower character wheel 5 is selected as a reference character wheel (which can be selected according to actual requirements). The character wheel set 4 rotates through the transmission mechanism 8, and the photoelectric direct reading processing module 1 reads the coding value of the character wheel according to the requirement. Taking the reference bit character wheel 5 as an example, the code value reading method is as follows: the character wheel is provided with a light passing hole, one side of the character wheel is provided with a light emitting component 7, and the other side is provided with a light receiving component 6. The light emitted by the light-emitting component 7 irradiates the light-receiving component 6 through the light hole when the character wheel passes through, and the code value of the character wheel is obtained through photoelectric conversion and decoding reading of the photoelectric direct-reading processing module 1, namely the indication number "9" of the character wheel. The microprocessor in the photoelectric direct-reading processing module 1 reads the coding values of the reference bit character wheel 5 and the low bit character wheel according to the set reading period and the method steps of the invention, and obtains a direct-reading value '01234598' through processing. When the code value read by the "reference bit word wheel" is changed from "9" to "0" or from large to small, it is indicated that the "reference bit word wheel" 5 carries out carry, and the electronic counter in the photoelectric direct-reading processing module 1 should count correctly based on the number of bits of the "reference bit word wheel" 5 (the reference bit word wheel 5 is ten bits in this schematic diagram, n=1, and then carry should be added with 1). The direct reading and the counter are then subjected to diagnostic and correction processing according to the method steps of the invention, the result and the alarm information being transmitted via the output communication interface 2. By using the invention, the reference bit character wheel carry is used as a signal source of the electronic counter to count, so that the basis for diagnosing and calibrating the direct-reading value of the counter is obtained, whether the mechanical counter is abnormal or not can be diagnosed on line, and reliable and accurate metering value and information can be output; and secondly, a method for reading the code value of the higher character wheel based on the reference bit character wheel when the reference bit character wheel carries is adopted, so that the power consumption is effectively reduced.
It should be noted that the present invention may be applied to a gas flow meter, so that the gas flow meter has functions of diagnosis and correction, and is connected to a base meter of the gas flow meter through magnetic coupling. In the operation process, the photoelectric direct reading processing module processes and outputs according to the reading flow and the chart diagnosis and correction flow in FIG. 1. According to the method, the reference bit word wheel carry is used as the increment of the electronic counter to count, so that the basis for diagnosing and calibrating the direct-reading value is obtained, whether the mechanical counter is different or not can be diagnosed online, reliable metering values and diagnosis information can be output, and the method has higher reliability compared with other direct-reading mechanical counters; secondly, the character wheel with the higher one bit is read only when the character wheel based on the reference bit carries, so that the power consumption is effectively reduced; in addition, because the high-order character wheel can be selected as the reference-order character wheel when the reference-order character wheel fails, the accuracy of all the data except the original failure reference-order character wheel digits can be effectively ensured, and trade disputes can be effectively reduced.
The above embodiments are merely illustrative of the preferred embodiments of the present invention and are not intended to limit the scope of the claimed invention, and various modifications made by those skilled in the art according to the technical solution of the present invention should fall within the scope of the present invention as defined in the claims.