A measurement method based on pulse time difference method in low power consumption mechanical watch

By using the pulse time difference method of the Hall sensor in the mechanical meter and utilizing the timing difference between the two Hall elements H1 and H2 to judge the forward and reverse rotation, the problems of magnetic interference and water backflow mismeasurement in the mechanical meter are solved, achieving more accurate measurement results.

CN114485817BActive Publication Date: 2025-10-03CHENGDU SOUNDLEADER TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210100366.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-27
Publication Date
2025-10-03
Estimated Expiration
2042-01-27

AI Technical Summary

Technical Problem

Existing mechanical meter measurement methods have problems with mismeasurement and omissions caused by magnetic interference. Especially in the Hall sensor measurement method, the measurement inaccuracy caused by external magnetic field interference and water backflow is difficult to solve.

Method used

The pulse time difference method based on Hall sensor is adopted. By installing two Hall elements H1 and H2, the timing characteristics of the Hall elements are used to determine the forward and reverse rotation of the mechanical watch, and the rotation direction is determined by the timing difference. The timer and the microcontroller processor are combined for measurement to correct mismeasurement and omission.

Benefits of technology

The actual measurement data of the mechanical meter is basically consistent with the dial indication, which reduces the problem of mismeasurement caused by magnetic interference and water backflow and improves the accuracy and reliability of measurement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114485817B_ABST
    Figure CN114485817B_ABST
Patent Text Reader

Abstract

The present invention discloses a measurement method based on the pulse time difference method in a low-power mechanical meter, comprising the following steps: S1. Assuming a mechanical meter mounted on a pipe fixture and performing measurement using a Hall element, defining the forward and reverse rotation of the mechanical meter based on the measurement characteristics of the Hall element; S2. Determining the conditions for determining when the mechanical meter stops rotating; S3. Defining relevant parameters of the meter fixture operating based on the Hall pulse time difference method; and S4. Measuring based on the Hall pulse time difference method. The present invention addresses the magnetic interference of the Hall sensor and the shortcomings of forward and reverse miscounting and omission, achieving substantial consistency between actual meter data and dial readings. Automatic calculations can also be used to mitigate magnetic interference and meter miscounting during water backflow.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to mechanical meter measurement, and in particular to a measurement method based on a pulse time difference method in a low-power mechanical meter. Background Art

[0002] In recent years, automatic meter reading technology has been widely promoted and applied. To keep pace with social development, many companies have developed two-in-one mechanical remote meters based on traditional mechanical meters. To meet the needs of mechanical remote meters that require digitally capturing the accumulated value on the meter's physical gear plate, most adopt the following methods.

[0003] 1. Photoelectric direct reading, this method is the simplest. Generally divided into two types of meters, dry and wet, and the photoelectric structure is divided into three structures: reflective photoelectric direct reading wheel structure, transmissive photoelectric direct reading wheel structure, and wet dry-installed transmissive photoelectric direct reading wheel structure. The three structures of photoelectric direct reading wet water meters have the following in common: the circuit of the photoelectric direct reading wet water meter (photoelectric sensor and main circuit) and the M-bus communication line connected to the circuit. Because the communication line needs to be led to the outside world, the circuit and the outside air are at the same atmospheric pressure. The wheel of the water meter is located in the water and is at the same pressure as the water in the pipe. According to the chemical properties of plastics, with the passage of time, the alternation of cold and hot seasons, temperature changes, and the environment under water pressure, transparent plastics will slowly age and become brittle; and after long-term use, there are also problems with poor reading accuracy and high failure rate.

[0004] 2. Magnetic steel sheet type: This method uses the attraction of magnets and reed switches to generate pulses to calculate the accumulation.

[0005] (1) It is sensitive to external magnetic interference, which may cause false triggering of pulses or no triggering of pulses.

[0006] (2) The induction strength of the magnet is inconsistent. The magnetic strength of the magnets produced will be inconsistent from the factory. With the use time getting longer and the interference of the external environment, the magnetic force will be severely attenuated, which may cause the pulse signal to fail to be triggered.

[0007] (3) The product quality of reed switches is not uniform, and it is difficult to achieve consistency in large quantities. This will lead to unstable triggering of the reed switches when the magnetic force is attenuated, resulting in inaccurate measurement.

[0008] 3. Hall effect sensors: This method utilizes the Hall effect, generating pulses when a magnet passes through a Hall element to calculate the accumulated value. Compared to the previous two methods, this method offers advantages such as simplicity, compactness, wide frequency response, large dynamic range, long life, and non-contact performance. It can also overcome water hammer and vibration during data collection. However, it does have a disadvantage: external magnetic fields reaching a certain strength can interfere with the Hall effect sensor, causing it to erroneously generate pulses.

[0009] Regardless of whether direct reading or pulse counting is used, the structure of the mechanical watch determines that the gears will rotate in both directions. If the forward rotation is caused by excessive air, it may lead to mismeasurement, or if the reverse rotation is caused by the backflow of water, it may result in undermeasurement, causing the number of pulses to be inconsistent with the dial data. Summary of the Invention

[0010] The purpose of the present invention is to overcome the shortcomings of the existing technology and provide a measurement method based on the pulse time difference method in a low-power mechanical watch. The method processes the magnetic interference and forward and reverse miscounting and omission shortcomings of the Hall sensor, so that the actual measurement data and the dial reading are basically consistent. The method can automatically reduce the magnetic interference and miscounting problems caused by water backflow through calculation.

[0011] The object of the present invention is achieved through the following technical solution: a measurement method based on the pulse time difference method in a low-power mechanical watch, comprising the following steps:

[0012] S1. Assume that a mechanical meter installed on a pipe uses a Hall element for measurement. Define the forward and reverse rotation of the mechanical meter based on the measurement characteristics of the Hall element.

[0013] S2. Determine the rotation stop condition of the mechanical watch;

[0014] S3. Define the relevant parameters of the meter based on the Hall pulse time difference method

[0015] S4. Measurement based on the Hall pulse time difference method.

[0016] Wherein, the step S1 includes:

[0017] Assume that there are two Hall elements installed in the mechanical meter, namely H1 and H2. Assume that the pointer of the mechanical meter made of magnetic material passes through H1 first and then passes through H2, which is a positive rotation measurement.

[0018] According to the measurement characteristics of the Hall element, a pulse interrupt will be triggered when passing through the Hall element. The Hall elements H1 and H2 are connected to the microcontroller in the mechanical watch, and the internal clock of the microcontroller is used to build a timer for timing. The method of judging the forward and reverse rotation of the mechanical watch based on the timing is as follows:

[0019] When it is determined that H1 or H2 has passed for the first time, the number of times H1 or H2 has passed is counted and timing is started: the time from the H1 trigger pulse to the H2 trigger pulse is recorded as H1_Time; the time from the H2 trigger pulse to the H1 trigger pulse is recorded as H2_Time. If H1_Time>=H2_Time, it is forward rotation, otherwise it is reverse rotation.

[0020] The angle traveled by the pointer from H1 to H2 is greater than the angle traveled from H2 to H1.

[0021] Wherein, in step S2, the condition for judging whether the mechanical watch stops rotating is:

[0022] According to the meter pipe diameter and the actuating flow rate, the maximum time DN_Time required for the meter to rotate one circle is pre-set; if H1_Time or H2_Time is greater than DN_Time, it means that the entire meter has stopped rotating.

[0023] Wherein, the step S3 includes:

[0024] If H1_Time or H2_Time > DN_Time, H1_Time and H2_Time are considered to have timed out and are set to true, recorded as H1H2TimeOutFlag = true, and recorded in the FRAM connected to the microprocessor to prevent power failure and loss of measurement status_H1H2TimeOutFlag, and set the H1 and H2 measurement initialization status flags to true, recorded as H1H2INITFlag = true, set the H1 / H2 timer timing flag to false, recorded as H1H2TimerFlag = false, and clear the rotor rotation flag to false, recorded as H1H2RUN_CountFlag = false, and record it in the FRAM to prevent power failure and loss of measurement status;

[0025] If H1H2INITFlag == true and H1H2TimerFlag == false, all measurement flags and measurement times will be initialized, including

[0026] H1H2TimeOutFlag = false, H1 interrupt flag H1InterruptFlag = false, H2 interrupt flag H2InterruptFlag = false, H1H2TimerFlag = true, H1_Time = 0, H2_Time = 0, interrupt counter IntNum = 0, number of saved data Num = 0, temporary metering channel H1H2Arr = 0, time metering channel H1H2_Time_Buf = 0, number of time records H1H2_TimeNum = 0, time record location H1H2_TimeLocal = 0.

[0027] Wherein, the step S4 includes the following sub-steps:

[0028] S401. If H1H2TimerFlag == true, the timer is determined to be ready to start timing and measurement is started;

[0029] S402. If: the program reset flag is true, ie, ResFlag == true, and the rotor rotation flag is true, ie, H1H2RUN_CountFlag == true;

[0030] It is determined that the program measurement has timed out and continues the previous measurement state measurement, and clears ResFlag = false, H1H2TimeOutFlag = false and the status flags in FRAM;

[0031] If not satisfied, clear the program reset flag ResFlag = false and the status flag in FRAM;

[0032] S403. Perform measurement processing when H1 interrupt is triggered;

[0033] If the H1 interrupt is triggered, it is recorded as H1InterruptFlag = true, H2InterruptFlag = false, and H1H2INITFlag = false;

[0034] Then determine whether it has timed out, that is, determine the status of _H1H2TimeOutFlag:

[0035] If it has not timed out, that is, _H1H2TimeOutFlag = false, it is determined whether IntNum is greater than or equal to 1. If it is greater than or equal to 1, H2_Time is written to H1H2Arr and saved in FRAM INF_H1H2Arr to prevent loss during power failure. Then H2_Time = 0, Num++ is cleared. Then H1 flag H1 is written to H1H2Arr and saved in FRAM INF_H1H2Arr to prevent loss during power failure.

[0036] Then, the measurement data processing is performed. First, IntNum is checked. If it is less than or equal to 1, it means that there are less than two data in the data pipeline and no processing is performed.

[0037] Secondly, determine whether the data in the data pipeline is normal:

[0038] If the alternating state is H1H2H1 or H2H1H2, the data in the data pipeline is considered normal and can be judged as normal;

[0039] If the data has two consecutive rotation signs such as H1H1H2 or H2H2H1, it is necessary to determine the forward and reverse rotation state, and then process this set of data according to the subsequent data;

[0040] If the continuous trigger data such as H1H1H1 or H2H2H2 are all in the same interrupt form, then it is temporarily determined to be hardware damaged, the hardware damage flag is recorded, and the timing is started. If the rotor stops rotating and the next startup is still in this state, then it is confirmed to be hardware damaged and the damage information is reported. If the state is restored the next time, the accumulated data will be judged and entered into the measurement;

[0041] (1) When the current interrupt is H1H2H1 / H2H1H2, if H2InterruptFlag == true and H1InterruptFlag == false, then the trigger mode must be H2H1H2. Continue to judge whether the time in the pipeline data is H1_Time>=H2_Time. If so, it is temporarily judged as forward rotation, and the positive accumulation is temporarily written, and the error data recovery and correction judgment is set; otherwise, it is judged as reverse rotation, and the reverse accumulation is temporarily written, and the error data recovery and correction judgment is set;

[0042] If the current interrupt is judged as H1InterruptFlag == true and H2InterruptFlag == false, then the trigger mode must be H1H2H1. Continue to judge whether the time in the pipeline data is H1_Time>=H2_Time. If so, it is temporarily judged as forward rotation, and the positive cumulative amount is temporarily written, and the error data recovery and error correction judgment is set; otherwise, it is judged as reverse rotation, and the reverse cumulative amount is temporarily written, and the error data recovery and error correction judgment is set;

[0043] Then, the data pipeline is shifted, and IntNum--, Num-= 2 are set; IntNum-- ​​means that IntNum is updated, and the updated IntNum is equal to the IntNum before the update minus one; Num-= 2 means that Num is updated, and the updated Num is equal to the Num before the update minus two;

[0044] And save the latest data in INF_H1H2Arr to ensure that each time data is saved in the data pipeline, the latest data is saved;

[0045] (2) When H2H2H1 / H1H1H2, first distinguish between forward and reverse rotation. If the reversing flag is not false, that is, ReversingRotation_flag == true, and the current interrupt flag is consistent with the previous interrupt flag stored in FRAM, that is, _H1InterruptFlag == H1InterruptFlag, it is considered to be reverse rotation. Otherwise, it is forward rotation, and the forward and reverse rotation flag ReversingRotation_flag is set and the temporary forward and reverse cumulative amount is written; this flag is true by default, that is, forward rotation ReversingRotation_flag == true;

[0046] Then shift the data pipeline and save the latest data in INF_H1H2Arr, then set IntNum--, Num -= 2;

[0047] (3) When H1H1H1 / H2H2H2, first write the Hall element damage flag INF_H1H2Destroy == true, then clear H1H2INITFlag = false, H1H2TimerFlag = false, and wait for the data pipeline to be reset for the next measurement;

[0048] (4) Error correction and interpretation: First, the current state (the current state is the currently recorded state, that is, the temporary forward and reverse directions judged during measurement) is judged to be forward or reverse. If it is forward but ReversingRotation_flag == false, then the reverse rotation number rotationNum is judged. If it is less than two turns, no processing is performed and the current number of turns is accumulated. If rotationNum >= 2, rotationNum = 0 is cleared first, and then the reverse rotation flag ReversingRotation_flag = false is cleared, and two turns of measurement are reduced by two turns in the forward direction to compensate for the two turns.

[0049] Reverse compensation: In extreme cases, it will cause reverse measurement, so reverse compensation is not required under normal use;

[0050] S404. Save IntNum++, Num++ in FRAM, then save H1InterruptFlag, H2InterruptFlag and set the rotor run flag H1H2RUN_CountFlag = true, and save all of these in FRAM;

[0051] S405. If the H2 interrupt is triggered, the same process as H1 is followed;

[0052] S406. If the H1 interrupt is triggered during the timeout judgment, it is recorded as H1InterruptFlag = true, H2InterruptFlag = false, H1H2INITFlag = false; then determine whether it has timed out, that is, the status _H1H2TimeOutFlag. If it has timed out, the timeout recovery data is executed: first, the temporary metering pipeline data H1H2Arr = INF_H1H2Ar is restored from INF_H1H2Arr, and then the timeout time is written. Then, the number of saved data Num = _H1H2TimeNum is restored, the number of interrupts IntNum = _H1H2IntNum is restored, and then the timeout time is saved and Num++ is saved;

[0053] After the data is restored, it is necessary to immediately determine the number of interrupt executions. If _H1H2IntNum >= 2, it is considered that one rotation has been made, and it is necessary to determine the positive and negative cumulative amount, and execute (2) in step S403; then the data pipeline is shifted and the latest data is saved in INF_H1H2Arr, and then IntNum--, Num-= 2; then clear the flag and count H1_Time = 0, H2_Time = 0, H1H2TimeOutFlag = false, and save it in FRAM _H1H2TimeOutFlag = false;

[0054] S407. Execute the judgment to distinguish true and false positive and negative cumulative amounts: first obtain the sum of the temporary positive and reverse cumulative amounts, then determine whether the current cumulative amount is equal to 2. If it is equal to 2, it means that it has rotated one circle. Then determine the positive and negative rotation flags. If it is forward, the incorrectly recorded reverse cumulative amount will be added to the forward cumulative amount; otherwise, the incorrectly recorded forward cumulative amount will be added to the reverse cumulative amount; then clear the temporary cumulative counter; each interrupt pulse will eliminate most of the interference data after the above processing to obtain the correct cumulative amount.

[0055] The beneficial effects of the present invention are as follows: the present invention processes the magnetic interference and forward and reverse miscounting and omission shortcomings of the Hall sensor, so as to achieve basic consistency between actual measurement data and dial indications, and can automatically reduce magnetic interference and miscounting problems caused by water backflow through calculation. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 is a flow chart of the method of the present invention;

[0057] Figure 2 This is a working diagram of the single chip microcomputer in the embodiment;

[0058] Figure 3 Schematic diagram of the metering process. DETAILED DESCRIPTION

[0059] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings, but the protection scope of the present invention is not limited to the following.

[0060] like Figure 1 As shown, the following steps are included:

[0061] S1. Assume that a mechanical meter installed on a pipe uses a Hall element for measurement. Define the forward and reverse rotation of the mechanical meter based on the measurement characteristics of the Hall element.

[0062] S2. Determine the rotation stop condition of the mechanical watch;

[0063] S3. Define the relevant parameters of the meter based on the Hall pulse time difference method

[0064] S4. Measurement based on the Hall pulse time difference method.

[0065] In the embodiments of the present application, Figure 2 As shown in the figure, after the microcontroller is initialized, all required interrupts are turned on, and then it is checked whether there are any interrupt events that need to be processed. If not, it enters low power consumption; if there is an interrupt triggered by a Hall pulse, it enters the interrupt processing function, and uses the time difference method to measure and the flow rate algorithm to process the generated pulse interrupt signal. After the processing is completed, it is determined whether there are any interrupt events that need to be processed. If not, it enters low power consumption state.

[0066] like Figure 3 As shown in the figure, the Hall element triggers two Hall pulse interrupts, which we denote as H1 and H2. The time generated by H1 is recorded as H1Time, and the time generated by H2 is recorded as H2Time. The interrupt flag triggered by H1 is recorded as H1Flag, and the interrupt flag triggered by H2 is recorded as H2Flag.

[0067] If H1 or H2 times out, it is recorded as H1H2Timeout.

[0068] Metering time determination algorithm:

[0069] This algorithm determines the time when the Hall element triggers the pulse each time it passes a circle based on the time when the Hall pulse is triggered, so as to record the time taken by the Hall element to trigger the pulse each time. When the time is exceeded, the current time will be recorded and saved to trigger the timeout flag, and this time will be used to determine whether the meter is in a dynamic water or static water state.

[0070] This algorithm determines the time obtained by the algorithm based on the metering time to judge the time difference. If the time difference is within the range we designed, it is forward rotation. If the time difference is less than, it is reverse rotation. Then it is judged whether the error measurement is restored. If it is currently forward rotation and the reverse rotation is caused by the interference error trigger pulse, it is necessary to correct the error through continuous rotation pulse error to determine whether the current cumulative amount needs to be corrected and the current reverse flag is cleared. If the forward and reverse rotation sequence is reversed due to the interference error trigger pulse, it is necessary to use the forward and reverse differentiation algorithm to correct whether it is really reverse or forward rotation, so as to determine whether this is positive or reverse cumulative measurement.

[0071] In the specific implementation process, step S1 includes:

[0072] Assume that there are two Hall elements installed in the mechanical meter, namely H1 and H2. Assume that the pointer of the mechanical meter made of magnetic material passes through H1 first and then passes through H2, which is a positive rotation measurement.

[0073] According to the measurement characteristics of the Hall element, a pulse interrupt will be triggered when passing through the Hall element. The Hall elements H1 and H2 are connected to the microcontroller in the mechanical watch, and the internal clock of the microcontroller is used to build a timer for timing. The method of judging the forward and reverse rotation of the mechanical watch based on the timing is as follows:

[0074] When it is determined that H1 or H2 has passed for the first time, the number of times H1 or H2 has passed is counted and timing is started: the time from the H1 trigger pulse to the H2 trigger pulse is recorded as H1_Time; the time from the H2 trigger pulse to the H1 trigger pulse is recorded as H2_Time. If H1_Time>=H2_Time, it is forward rotation, otherwise it is reverse rotation.

[0075] The angle traveled by the pointer from H1 to H2 is greater than the angle traveled from H2 to H1.

[0076] In the embodiment of this application, the proposed H1_Time>=H2_Time is considered the temporary (initial) forward direction, and vice versa, the temporary (initial) reverse direction. This direction will be corrected based on the subsequent error correction judgment: if the first rotation is recorded as forward and the next three rotations are all forward, then the first rotation direction is forward. Conversely, if the first rotation is recorded as forward and the next three rotations are all reverse, then the first rotation direction is reverse and the cumulative amount compensation is performed.

[0077] Wherein, in step S2, the condition for judging whether the mechanical watch stops rotating is:

[0078] According to the meter pipe diameter and the actuating flow rate, the maximum time DN_Time required for the meter to rotate one circle is pre-set; if H1_Time or H2_Time is greater than DN_Time, it means that the entire meter has stopped rotating.

[0079] Wherein, the step S3 includes:

[0080] If H1_Time or H2_Time > DN_Time, H1_Time and H2_Time are considered to have timed out and are set to true, recorded as H1H2TimeOutFlag = true, and recorded in the FRAM connected to the microprocessor to prevent power failure and loss of measurement status_H1H2TimeOutFlag, and set the H1 and H2 measurement initialization status flags to true, recorded as H1H2INITFlag = true, set the H1 / H2 timer timing flag to false, recorded as H1H2TimerFlag = false, and clear the rotor rotation flag to false, recorded as H1H2RUN_CountFlag = false, and record it in the FRAM to prevent power failure and loss of measurement status;

[0081] If H1H2INITFlag == true and H1H2TimerFlag == false, all measurement flags and measurement times will be initialized, including

[0082] H1H2TimeOutFlag = false, H1 interrupt flag H1InterruptFlag = false, H2 interrupt flag H2InterruptFlag = false, H1H2TimerFlag = true, H1_Time = 0, H2_Time = 0, interrupt counter IntNum = 0, number of saved data Num = 0, temporary metering channel H1H2Arr = 0, time metering channel H1H2_Time_Buf = 0, number of time records H1H2_TimeNum = 0, time record location H1H2_TimeLocal = 0.

[0083] Wherein, the step S4 includes the following sub-steps:

[0084] S401. If H1H2TimerFlag == true, the timer is determined to be ready to start timing and measurement is started;

[0085] S402. If: the program reset flag is true, ie, ResFlag == true, and the rotor rotation flag is true, ie, H1H2RUN_CountFlag == true;

[0086] It is determined that the program measurement has timed out and continues the previous measurement state measurement, and clears ResFlag = false, H1H2TimeOutFlag = false and the status flags in FRAM;

[0087] If not satisfied, clear the program reset flag ResFlag = false and the status flag in FRAM;

[0088] S403. Perform measurement processing when H1 interrupt is triggered;

[0089] If the H1 interrupt is triggered, it is recorded as H1InterruptFlag = true, H2InterruptFlag = false, and H1H2INITFlag = false;

[0090] Then determine whether it has timed out, that is, determine the status of _H1H2TimeOutFlag:

[0091] If it has not timed out, that is, _H1H2TimeOutFlag = false, it is determined whether IntNum is greater than or equal to 1. If it is greater than or equal to 1, H2_Time is written to H1H2Arr and saved in FRAM INF_H1H2Arr to prevent loss during power failure. Then H2_Time = 0, Num++ is cleared. Then H1 flag H1 is written to H1H2Arr and saved in FRAM INF_H1H2Arr to prevent loss during power failure.

[0092] Then, the measurement data processing is performed. First, IntNum is checked. If it is less than or equal to 1, it means that there are less than two data in the data pipeline and no processing is performed.

[0093] Secondly, determine whether the data in the data pipeline is normal:

[0094] If the alternating state is H1H2H1 or H2H1H2, the data in the data pipeline is considered normal and can be judged as normal;

[0095] If the data has two consecutive rotation signs such as H1H1H2 or H2H2H1, it is necessary to determine the forward and reverse rotation state, and then process this set of data according to the subsequent data;

[0096] If the continuous trigger data such as H1H1H1 or H2H2H2 are all in the same interrupt form, then it is temporarily determined to be hardware damaged, the hardware damage flag is recorded, and the timing is started. If the rotor stops rotating and the next startup is still in this state, then it is confirmed to be hardware damaged and the damage information is reported. If the state is restored the next time, the accumulated data will be judged and entered into the measurement;

[0097] (1) When the current interrupt is H1H2H1 / H2H1H2, if H2InterruptFlag == true and H1InterruptFlag == false, then the trigger mode must be H2H1H2. Continue to judge whether the time in the pipeline data is H1_Time>=H2_Time. If so, it is temporarily judged as forward rotation, and the positive accumulation is temporarily written, and the error data recovery and correction judgment is set; otherwise, it is judged as reverse rotation, and the reverse accumulation is temporarily written, and the error data recovery and correction judgment is set;

[0098] If the current interrupt is judged as H1InterruptFlag == true and H2InterruptFlag == false, then the trigger mode must be H1H2H1. Continue to judge whether the time in the pipeline data is H1_Time>=H2_Time. If so, it is temporarily judged as forward rotation, and the positive cumulative amount is temporarily written, and the error data recovery and error correction judgment is set; otherwise, it is judged as reverse rotation, and the reverse cumulative amount is temporarily written, and the error data recovery and error correction judgment is set;

[0099] Then, the data pipeline is shifted, and IntNum--, Num-= 2 are set; IntNum-- ​​means that IntNum is updated, and the updated IntNum is equal to the IntNum before the update minus one; Num-= 2 means that Num is updated, and the updated Num is equal to the Num before the update minus two;

[0100] And save the latest data in INF_H1H2Arr to ensure that each time data is saved in the data pipeline, the latest data is saved;

[0101] (2) When H2H2H1 / H1H1H2, first distinguish between forward and reverse rotation. If the reversing flag is not false, that is, ReversingRotation_flag == true, and the current interrupt flag is consistent with the previous interrupt flag stored in FRAM, that is, _H1InterruptFlag == H1InterruptFlag, it is considered to be reverse rotation. Otherwise, it is forward rotation, and the forward and reverse rotation flag ReversingRotation_flag is set and the temporary forward and reverse cumulative amount is written. This flag is true by default, that is, forward rotation ReversingRotation_flag == true;

[0102] Then shift the data pipeline and save the latest data in INF_H1H2Arr, then set IntNum--, Num -= 2;

[0103] (3) When H1H1H1 / H2H2H2, first write the Hall element damage flag INF_H1H2Destroy == true, then clear H1H2INITFlag = false, H1H2TimerFlag = false, and wait for the data pipeline to be reset for the next measurement;

[0104] (4) Error correction and interpretation: First, the current state (the current state is the currently recorded state, that is, the temporary forward and reverse directions judged during measurement) is judged to be forward or reverse. If it is forward but ReversingRotation_flag == false, then the reverse rotation number rotationNum is judged. If it is less than two turns, no processing is performed and the current number of turns is accumulated. If rotationNum >= 2, rotationNum = 0 is cleared first, and then the reverse rotation flag ReversingRotation_flag = false is cleared, and two turns of measurement are reduced by two turns in the forward direction to compensate for the two turns.

[0105] Reverse compensation: In extreme cases, it will cause reverse measurement, so reverse compensation is not required under normal use;

[0106] S404. Save IntNum++, Num++ in FRAM, then save H1InterruptFlag, H2InterruptFlag and set the rotor run flag H1H2RUN_CountFlag = true, and save all of these in FRAM;

[0107] S405. If interrupt H2 is triggered, the processing flow is the same as H1;

[0108] S406. If the H1 interrupt is triggered during the timeout judgment, it is recorded as H1InterruptFlag = true, H2InterruptFlag = false, H1H2INITFlag = false; then determine whether it has timed out, that is, the status _H1H2TimeOutFlag. If it has timed out, the timeout recovery data is executed: first, the temporary metering pipeline data H1H2Arr = INF_H1H2Ar is restored from INF_H1H2Arr, and then the timeout time is written. Then, the number of saved data Num = _H1H2TimeNum is restored, the number of interrupts IntNum = _H1H2IntNum is restored, and then the timeout time is saved and Num++ is saved;

[0109] After the data is restored, it is necessary to immediately determine the number of interrupt executions. If _H1H2IntNum >= 2, it is considered that one rotation has been made, and it is necessary to determine the positive and negative cumulative amount, and execute (2) in step S403; then the data pipeline is shifted and the latest data is saved in INF_H1H2Arr, and then IntNum--, Num-= 2; then clear the flag and count H1_Time = 0, H2_Time = 0, H1H2TimeOutFlag = false, and save it in FRAM _H1H2TimeOutFlag = false;

[0110] S407. Execute the judgment to distinguish true and false positive and negative cumulative amounts: first obtain the sum of the temporary positive and reverse cumulative amounts, then determine whether the current cumulative amount is equal to 2. If it is equal to 2, it means that it has rotated one circle. Then determine the positive and negative rotation flags. If it is forward, the incorrectly recorded reverse cumulative amount will be added to the forward cumulative amount; otherwise, the incorrectly recorded forward cumulative amount will be added to the reverse cumulative amount; then clear the temporary cumulative counter; each interrupt pulse will eliminate most of the interference data after the above processing to obtain the correct cumulative amount.

[0111] In the embodiments of the present application, there are no special requirements for the installation position and angle of the Hall element. It only needs to have a certain angle (this angle will cause a time difference of more than 10ms between H1_Time and H2_Time when operating at an overload flow (Q4)). Even if the measurement is always reversed at the beginning, the problem of reverse measurement caused by setting H1_Time>=H2_Time can be corrected by changing the forward and reverse outputs (this is self-explanatory; it is simply changing the forward output to the reverse direction or the reverse output to the forward direction, which does not affect the algorithm).

[0112] Therefore, this application only requires that the Hall element have an included angle, and this included angle will inevitably exist when the Hall element is installed.

[0113] For example: DN20 Q4 = 5000L / H. One revolution of the rotor represents 10L.

[0114] So the flow rate per second is about 5000 / 3600 = 1.39L / S, so it takes about 10 / 1.39 = 7.19S to rotate 10L

[0115] A 10ms time difference only requires the angle between H1 and H2 to be greater than 0.5°, and a 20ms time difference only requires the angle between H1 and H2 to be greater than 1°. This angle is negligible compared to installation errors. Therefore, this application is highly applicable to all mechanical watches that trigger pulses twice per rotation.

[0116] The foregoing description shows and describes a preferred embodiment of the present invention. However, as previously stated, it should be understood that the present invention is not limited to the form disclosed herein and should not be construed as excluding other embodiments. Instead, the present invention is applicable to various other combinations, modifications, and environments and is capable of modification within the scope of the inventive concept described herein, through the teachings above, or through techniques or knowledge in the relevant art. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention are intended to be within the scope of the appended claims.

Claims

1. A measurement method based on the pulse time difference method in a low-power mechanical watch, characterized by: The following steps are involved: S1. Assume that a mechanical meter installed on a pipe uses a Hall element for measurement. Define the forward and reverse rotation of the mechanical meter based on the measurement characteristics of the Hall element. The step S1 comprises: Assume that there are two Hall elements installed in the mechanical meter, namely H1 and H2. Assume that the pointer of the mechanical meter made of magnetic material passes through H1 first and then passes through H2, which is a positive rotation measurement. According to the measurement characteristics of the Hall element, a pulse interrupt will be triggered when passing through the Hall element. The Hall elements H1 and H2 are connected to the microcontroller in the mechanical watch, and the internal clock of the microcontroller is used to build a timer for timing. The method of judging the forward and reverse rotation of the mechanical watch based on the timing is as follows: When it is determined that H1 or H2 has passed for the first time, the number of times H1 or H2 has passed is counted and timing is started: the time from the H1 trigger pulse to the H2 trigger pulse is recorded as H1_Time; the time from the H2 trigger pulse to the H1 trigger pulse is recorded as H2_Time. If H1_Time>=H2_Time, it is forward rotation, otherwise it is reverse rotation. Among them, the angle that the pointer travels from H1 to H2 is greater than the angle that the pointer travels from H2 to H1; S2. Determine the rotation stop condition of the mechanical watch; In step S2, the condition for determining whether the mechanical watch stops rotating is: According to the meter pipe diameter and the actuating flow rate, the maximum time DN_Time required for the meter to rotate one circle is pre-set; if H1_Time or H2_Time is greater than DN_Time, it means that the entire meter has stopped rotating; S3. Define the parameters of the meter based on the Hall pulse time difference method; The step S3 comprises: If H1_Time or H2_Time > DN_Time, H1_Time and H2_Time are considered to have timed out and are set to true, recorded as H1H2TimeOutFlag = true, and recorded in the FRAM connected to the microprocessor to prevent power failure and loss of measurement status_H1H2TimeOutFlag, and set the H1 and H2 measurement initialization status flags to true, recorded as H1H2INITFlag = true, set the H1 / H2 timer timing flag to false, recorded as H1H2TimerFlag = false, and clear the rotor rotation flag to false, recorded as H1H2RUN_CountFlag = false, and record it in the FRAM to prevent power failure and loss of measurement status; If H1H2INITFlag == true and H1H2TimerFlag == false, all measurement flags and measurement times will be initialized, including H1H2TimeOutFlag = false, H1 interrupt flag H1InterruptFlag = false, H2 interrupt flag H2InterruptFlag = false, H1H2TimerFlag = true, H1_Time = 0, H2_Time = 0, interrupt counter IntNum = 0, number of saved data Num = 0, temporary metering channel H1H2Arr = 0, time metering channel H1H2_Time_Buf = 0, number of time records H1H2_TimeNum = 0, time record location H1H2_TimeLocal = 0; S4. Measurement based on Hall pulse time difference method: The step S4 includes the following sub-steps: S401. If H1H2TimerFlag == true, the timer is determined to be ready to start timing and measurement is started; S402. If: the program reset flag is true, ie, ResFlag == true, and the rotor rotation flag is true, ie, H1H2RUN_CountFlag == true; It is determined that the program measurement has timed out and continues the previous measurement state measurement, and clears ResFlag = false, H1H2TimeOutFlag = false and the status flags in FRAM; If not satisfied, clear the program reset flag ResFlag = false and the status flag in FRAM; S403. Perform measurement processing when H1 interrupt is triggered; If the H1 interrupt is triggered, it is recorded as H1InterruptFlag = true, H2InterruptFlag = false, H1H2INITFlag = false; Then determine whether it has timed out, that is, determine the status of _H1H2TimeOutFlag: If it has not timed out, that is, _H1H2TimeOutFlag = false, it is determined whether IntNum is greater than or equal to 1. If it is greater than or equal to 1, H2_Time is written to H1H2Arr and saved in FRAM INF_H1H2Arr to prevent loss during power failure. Then H2_Time = 0, Num++ is cleared. Then H1 flag H1 is written to H1H2Arr and saved in FRAM INF_H1H2Arr to prevent loss during power failure. Then, the measurement data processing is performed. First, IntNum is checked. If it is less than or equal to 1, it means that there are less than two data in the data pipeline and no processing is performed. Secondly, determine whether the data in the data pipeline is normal: If the alternating state is H1H2H1 or H2H1H2, the data in the data pipeline is considered normal and can be judged as normal; If the data has two consecutive rotation signs such as H1H1H2 or H2H2H1, it is necessary to determine the forward and reverse rotation state, and then process this set of data according to the subsequent data; If the continuous trigger data such as H1H1H1 or H2H2H2 are all in the same interrupt form, then it is temporarily determined to be hardware damaged, the hardware damage flag is recorded, and the timing is started. If the rotor stops rotating and the next startup is still in this state, then it is confirmed to be hardware damaged and the damage information is reported. If the state is restored the next time, the accumulated data will be judged and entered into the measurement; (1) When the current interrupt is H1H2H1 / H2H1H2, if H2InterruptFlag == true and H1InterruptFlag == false, then the trigger mode must be H2H1H2. Continue to judge whether the time in the pipeline data is H1_Time>=H2_Time. If so, it is temporarily judged as forward rotation, and the positive accumulation is temporarily written, and the error data recovery and correction judgment is set; otherwise, it is judged as reverse rotation, and the reverse accumulation is temporarily written, and the error data recovery and correction judgment is set; If the current interrupt is judged as H1InterruptFlag == true and H2InterruptFlag == false, then the trigger mode must be H1H2H1. Continue to judge whether the time in the pipeline data is H1_Time>=H2_Time. If so, it is temporarily judged as forward rotation, and the positive cumulative amount is temporarily written, and the error data recovery and error correction judgment is set; otherwise, it is judged as reverse rotation, and the reverse cumulative amount is temporarily written, and the error data recovery and error correction judgment is set; Then, the data pipeline is shifted, and IntNum--, Num-= 2 are set; IntNum-- ​​means that IntNum is updated, and the updated IntNum is equal to the IntNum before the update minus one; Num-= 2 means that Num is updated, and the updated Num is equal to the Num before the update minus two; And save the latest data in INF_H1H2Arr to ensure that each time data is saved in the data pipeline, the latest data is saved; (2) When H2H2H1 / H1H1H2, first distinguish between forward and reverse rotation. If the reversing flag is not false, that is, ReversingRotation_flag == true, and the current interrupt flag is consistent with the previous interrupt flag stored in FRAM, that is, _H1InterruptFlag == H1InterruptFlag, it is considered to be reverse rotation. Otherwise, it is forward rotation, and the forward and reverse rotation flag ReversingRotation_flag is set and the temporary forward and reverse cumulative amount is written; this flag is true by default, that is, forward rotation ReversingRotation_flag == true; Then shift the data pipeline and save the latest data in INF_H1H2Arr, then set IntNum--, Num -= 2; (3) When H1H1H1 / H2H2H2, first write the Hall element damage flag INF_H1H2Destroy == true, then clear H1H2INITFlag = false, H1H2TimerFlag = false, and wait for the data pipeline to be reset for the next measurement; (4) Error correction judgment: First, judge whether the current state is forward or reverse. If it is forward but ReversingRotation_flag == false, then judge the reverse rotation number rotationNum. If it is less than two turns, do not process it and accumulate the current number of turns. If rotationNum >= 2, first clear rotationNum = 0, then clear the reverse rotation flag ReversingRotation_flag = false, and reduce the measurement by two turns in the forward direction. Among them, the current state is the currently recorded state, that is, the temporary forward and reverse directions judged during measurement. S404. Save IntNum++, Num++ in FRAM, then save H1InterruptFlag, H2InterruptFlag and set the rotor run flag H1H2RUN_CountFlag = true, and save all of these in FRAM; S405. If the H2 interrupt is triggered, the measurement process is performed in the same manner as H1; S406. If the H1 interrupt is triggered during the timeout judgment, it is recorded as H1InterruptFlag = true, H2InterruptFlag = false, H1H2INITFlag = false; then determine whether it has timed out, that is, the status _H1H2TimeOutFlag. If it has timed out, the timeout recovery data is executed: first, the temporary metering pipeline data H1H2Arr = INF_H1H2Ar is restored from INF_H1H2Arr, and then the timeout time is written. Then, the number of saved data Num = _H1H2TimeNum is restored, the number of interruptions IntNum = _H1H2IntNum is restored, and then the timeout time is saved and Num++ is saved; After the data is restored, it is necessary to immediately determine the number of interrupt executions. If _H1H2IntNum >= 2, it is considered that one rotation has been made, and it is necessary to determine the positive and negative cumulative amount, and execute (2) in step S403; then the data pipeline is shifted and the latest data is saved in INF_H1H2Arr, and then IntNum--, Num-= 2; then clear the flag and count H1_Time = 0, H2_Time = 0, H1H2TimeOutFlag = false, and save it in FRAM _H1H2TimeOutFlag = false; S407. Execute the judgment to distinguish true and false positive and negative cumulative amounts: first obtain the sum of the temporary positive and reverse cumulative amounts, then determine whether the current cumulative amount is equal to 2. If it is equal to 2, it means that it has rotated one circle. Then determine the positive and negative rotation flags. If it is forward, the incorrectly recorded reverse cumulative amount will be added to the forward cumulative amount; otherwise, the incorrectly recorded forward cumulative amount will be added to the reverse cumulative amount; then clear the temporary cumulative counter; each interrupt pulse will eliminate most of the interference data after the above processing to obtain the correct cumulative amount.

Citation Information

Patent Citations

  • Device and method for detecting number of turns of rotation, storage medium and water meter

    CN111366209A