Method for detecting and correcting infrared communication carrier frequency of electric energy meter
Through the handheld detection terminal, the carrier frequency of the infrared communication of the power meter is measured and corrected regularly, the failure of meter reading and short communication distance caused by carrier frequency offset is solved, and the stability and efficiency of infrared communication is improved.
Patent Information
- Application Number
- CN202411372965.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2024-12-27
AI Technical Summary
The infrared communication carrier frequency of the power meter is easily deviated due to changes in temperature and humidity after long-term operation, resulting in meter reading failure and short communication distance.
The handheld detection terminal performs regular measurement and correction of the square wave frequency output by the power meter, adjusts the PWM frequency division coefficient to maintain the infrared carrier frequency at 38KHz, uses the MCU's PWM register and communication interface to perform frequency correction, and stores the corrected value In FLASH.
It improves the stability and success rate of infrared communication, extends the communication distance, ensures that power operation and maintenance personnel can copy and read the power meter data normally, and improves management efficiency.
Smart Images

Figure CN119211777A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of infrared communication of electric energy meters, and in particular to a method for detecting and correcting the carrier frequency of infrared communication of electric energy meters. Background Art
[0002] The infrared communication technology of the electric energy meter plays a vital role in the power system. The meter reading equipment can read back the data information of the electric parameters such as electricity, power, voltage, current, etc. on the electric energy meter through infrared communication technology. By using infrared communication, the management personnel can configure and adjust the parameters of the electric energy meter through the meter reading equipment, such as setting electricity prices, time periods, etc., to adapt to different electricity demand and management requirements.
[0003] The carrier frequency of infrared communication of electric energy meters is the cornerstone of data transmission, and its standards are usually formulated by relevant organizations in the international or domestic power industry. At present, the widely used carrier frequency is 38kHz, which is determined based on the good penetration and anti-interference of this frequency in the infrared band.
[0004] There are generally two solutions for generating infrared carrier waves of electric energy meters. One is to use pure hardware circuit design to generate a 38KHz square wave, which is combined with the MCU's serial port to send data to complete the infrared carrier data transmission. The other is a pure software method, which uses the MCU's internal resource PWM pulse width modulation method to generate a 38KHz square wave, and then combines the MCU's serial port to send data to complete the infrared carrier data transmission.
[0005] Among them, the pure hardware circuit solution, after a long period of operation, is affected by the external temperature and humidity, and the resistance and capacitance values of the matching square wave have changed, which causes the frequency of the 38KHz square wave involved in the calculation to be too large or too small, causing the carrier frequency during infrared transmission to deviate from the center frequency of 38KHz, which in turn causes the infrared receiver to fail to receive data or reduce the communication distance. Another square wave generated by the pure software method, because the generated PWM frequency is mainly derived from the frequency division of the MCU's crystal oscillator clock main frequency, and after the MCU's crystal oscillator has been running for a long time, it is affected by the external temperature and humidity, and the frequency generated by the crystal oscillator will also be offset, causing the PWM frequency division to change with the change of the main frequency, which will also cause the infrared carrier frequency to deviate from the center frequency of 38KHz when transmitting.
[0006] Since both of the above two infrared carrier frequencies have a 38KHz offset phenomenon, the meter reading terminal will fail to read the electric energy meter data and the infrared communication distance will be short. Therefore, a method for detecting and correcting the infrared communication carrier frequency of the electric energy meter is proposed. Summary of the invention
[0007] The purpose of the present invention is to provide a method for detecting and correcting the infrared communication carrier frequency of an electric energy meter to solve the problems raised in the above-mentioned background technology.
[0008] To achieve the above object, the present invention provides the following technical solution: a method for detecting and correcting the infrared communication carrier frequency of an electric energy meter, the detection and correction method comprising the following steps:
[0009] S1, first the energy meter is initialized after being powered on;
[0010] S2, configure the PWM clock frequency through the MCU of the energy meter, and define the PWM frequency division coefficient K as a variable in the program. Write the default value of the frequency division coefficient K at the factory, store it in the FLASH synchronously and save it when the power is off;
[0011] S3, register setting is performed, and each time the electric energy meter is initialized, the frequency division coefficient K in the FLASH is read, and the PWM frequency division coefficient K is called to write into the set register;
[0012] S4, start the electric energy meter to output PWM square wave;
[0013] S5, the handheld detection terminal performs frequency sampling detection on the square wave output by the electric energy meter;
[0014] S6, calculating the measured square wave frequency value, obtaining an actual square wave frequency measurement value and setting it as fc, and the unit is KHz;
[0015] S7, correcting the frequency division coefficient K value of the actual square wave frequency measurement value in combination with the square wave frequency standard value, wherein the square wave PWM frequency standard value is set to fb, and the value is 38KHz;
[0016] S8, communicating the corrected frequency division coefficient k value with the MCU inside the electric energy meter through the data communication interface of the handheld detection terminal;
[0017] S9, after receiving the corrected frequency division coefficient k value, the MCU inside the energy meter rewrites it into the PWM configuration register. After configuration, the square wave frequency of PWM is maintained at 38KHz, and then introduced into the infrared transmitting part to cooperate with the universal asynchronous receiver and transmitter to send infrared data.
[0018] Preferably, the standard value of the square wave frequency 38KHz is obtained by setting the frequency division coefficient K of the crystal oscillator clock inside the MCU.
[0019] Preferably, the default value calculation formula of the frequency division coefficient K is:
[0020] K = 16MHz / 38KHz≈421 (1);
[0021] Among them, 16 MHz is the main frequency provided to the MCU after the crystal oscillator starts up, and 38 KHz is the standard value of the square wave PWM frequency. Therefore, after writing the K = 421 frequency division coefficient into the relevant PWM register of the MCU through software, a 38 KHz square wave can be generated.
[0022] Preferably, a modification interface for the frequency division coefficient K is added during the setting process of the S3 register, and it is allowed to be modified through communication with the interface protocol of the handheld detection terminal.
[0023] Preferably, when the handheld detection terminal performs frequency detection and correction, the frequency division coefficient K is adjusted according to the correction parameters transmitted by the handheld detection terminal, and the corrected frequency division coefficient K is synchronously updated to the FLASH, so that the electric energy meter can use the latest corrected frequency division coefficient K every time it calls the PWM function.
[0024] Preferably, the correction determination of the frequency division coefficient K value is carried out by comparing the actual measured square wave frequency value fc with the square wave PWM frequency standard value fb, which is expressed as:
[0025] If fc > fb, then increase the frequency division K; if fc < fb, then decrease the frequency division K.
[0026] Preferably, the handheld detection terminal is a frequency measurement standard device with communication function, and is regularly calibrated and checked by a detection agency to ensure the measurement accuracy of the handheld detection terminal.
[0027] Preferably, the frequency sampling measurement and data transmission process of the handheld detection terminal includes the following operations:
[0028] A1. First, the measured signal is amplified to reach the signal amplitude and effective range for effective sampling of the handheld detection terminal.
[0029] A2. Then, the measured signal passes through a comparator designed by an operational amplifier to make the collected signal meet the receiving level range of the subsequent processor.
[0030] A3. After that, the measured signal undergoes signal following to further ensure impedance matching before entering the FPGA.
[0031] A4. Finally, the accuracy and stability of the sampling of the measured signal are improved, and the sampling of the FPGA uses the falling-edge pulse valid form, and the frequency value is calculated after sampling by the FPGA logic chip.
[0032] Preferably, the calculation of the frequency value is in the internal program of the FPGA. First, define the falling-edge pulses sampled in 1 s as valid numbers, then calculate the square wave frequency collected through conversion, and finally, after data processing by the internal program, transmit the offset standard value through the communication interface to the internal MCU of the electric energy meter.
[0033] Preferably, the infrared data is sent when the serial port TXD inside the MCU is at a low level, triggering the infrared transmitting tube to perform infrared transmission with a 38KHz carrier.
[0034] Technical effects and advantages of the present invention:
[0035] The method uses a handheld detection terminal to perform regular measurement and correction of the square wave output by the electric energy meter, which not only ensures the stability and reliability of infrared communication, but also ensures that the infrared communicates at the best frequency performance, improves the success rate of the meter reading terminal when reading the electric energy meter data using infrared communication, and also improves the infrared communication distance, so that the power operation and maintenance personnel can read the electric energy meter data normally at a long distance from the electric energy meter, ensuring its safety. While improving the management efficiency of power operation and maintenance, it also avoids the problem of infrared communication failure caused by infrared carrier center frequency offset and the problem of short infrared communication distance. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a schematic diagram of the overall operation flow of the present invention.
[0037] Figure 2 It is a schematic diagram of the overall communication principle of the present invention.
[0038] Figure 3 The figure is a principle block diagram of the handheld detection terminal of the present invention.
[0039] Figure 4 This is a principle block diagram of the frequency sampling measurement and data transmission process of the present invention.
[0040] Figure 5 It is a schematic diagram of the square wave period and falling edge pulse of the present invention.
[0041] Figure 6 This is a schematic diagram of the infrared communication carrier transmission principle of the present invention. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] The present invention provides Figure 1 and Figure 2 The method for detecting and correcting the infrared communication carrier frequency of an electric energy meter shown in the figure comprises the following steps:
[0044] S1, first the energy meter is initialized after being powered on;
[0045] S2, configure the PWM clock frequency through the MCU of the energy meter, and define the PWM frequency division coefficient K as a variable in the program. The default value of the frequency division coefficient K is written at the factory. The default value at this time is 421. The calculation process can be known from the calculation in the next step S7. It is synchronously stored in the FLASH and saved when the power is off;
[0046] It should be noted that PWM (Pulse Width Modulation) is a technology that controls analog signals by changing the width of pulses. It is widely used in electronic devices, especially in motor control, LED dimming, audio signal generation and other fields. Its working principle is: pulse width, the PWM signal cycle is fixed, and the pulse width (duration of high level) will be adjusted according to needs. The larger the pulse width, the higher the average output voltage; the smaller the pulse width, the lower the average output voltage; duty cycle, duty cycle refers to the ratio of high level duration to total cycle, usually expressed as a percentage. Changes in duty cycle directly affect the output power and signal strength.
[0047] S3, register setting is performed, and each time the electric energy meter is initialized, the frequency division coefficient K in the FLASH is read, and the PWM frequency division coefficient K is called to write into the set register;
[0048] Specifically, an interface for modifying the frequency division coefficient K is added during the setting process of the S3 register, and the interface protocol with the handheld detection terminal is allowed to be modified through communication.
[0049] S4, start the electric energy meter to output PWM square wave;
[0050] S5, the handheld detection terminal performs frequency sampling detection on the square wave output by the electric energy meter;
[0051] Specifically, refer to Figure 3 As shown, when the handheld detection terminal detects and corrects the frequency, the frequency division coefficient K is adjusted according to the correction parameters transmitted by the handheld detection terminal, and the corrected frequency division coefficient K is synchronously updated to the FLASH, so that the electric energy meter can use the latest corrected frequency division coefficient K each time the PWM function is called.
[0052] Furthermore, the handheld detection terminal is a frequency measurement standard device with a communication function, and is regularly calibrated and checked by a detection agency to ensure the measurement accuracy of the handheld detection terminal.
[0053] Specifically, refer to Figure 4 As shown in the figure, the frequency sampling measurement and data transmission process of the handheld detection terminal includes the following operations:
[0054] A1, first the measured signal (PWM square wave) is amplified to achieve the signal amplitude and effective range of the handheld detection terminal;
[0055] A2, then the measured signal passes through a comparator designed by an operational amplifier, so that the collected signal meets the receiving level range of the subsequent processor;
[0056] A3, then the measured signal passes through the signal follower to further ensure the impedance matching of the signal before entering the FPGA;
[0057] A4, finally improves the accuracy and stability of the sampling of the measured signal, and the FPGA sampling adopts the effective form of the falling edge pulse, and the frequency value is calculated after sampling by the FPGA logic chip.
[0058] For further reference, Figure 5 As shown in the figure, the waveform before sampling is a square wave. There is only one falling edge pulse in one period of a square wave. The frequency value is calculated in the internal program of the FPGA. First, the falling edge pulse sampled in 1s is defined as a valid number, and then the collected square wave frequency is obtained by conversion. For example, if the valid number collected in 1s is 35000, the frequency is 35KHz. Finally, the internal program processes the data and transmits the offset standard value to the MCU inside the electric energy meter through the communication interface.
[0059] S6, calculating the measured square wave frequency value, obtaining an actual square wave frequency measurement value and setting it as fc, and the unit is KHz;
[0060] S7, correcting the frequency division coefficient K value of the actual square wave frequency measurement value in combination with the square wave frequency standard value, wherein the square wave PWM frequency standard value is set to fb, and the value is 38KHz;
[0061] Specifically, the standard value of the square wave frequency 38KHz is obtained by setting the frequency division coefficient K of the crystal oscillator clock inside the MCU.
[0062] Furthermore, the default value calculation formula of the frequency division coefficient K is:
[0063] K = 16MHz / 38KHz≈421 (1);
[0064] Among them, 16MHz is the main frequency provided to the MCU after the crystal oscillator is powered on, and 38KHz is the standard value of the square wave PWM frequency. Therefore, after the K=421 division coefficient is written into the MCU-related PWM register through software, a 38KHz square wave can be generated.
[0065] Furthermore, the correction judgment of the frequency division coefficient K value is performed by comparing the actual square wave frequency measurement value fc with the square wave PWM frequency standard value fb, which is expressed as:
[0066] If fc > fb, increase the frequency division K; if fc < fb, decrease the frequency division K.
[0067] S8. Communicate the corrected frequency division coefficient k value with the MCU inside the electricity meter through the data communication interface of the handheld detection terminal, and send the latest frequency division coefficient k value to the electricity meter MCU. After receiving it, the MCU rewrites it into the PWM configuration register;
[0068] S9. After the MCU inside the electricity meter receives the corrected frequency division coefficient k value, rewrite it into the register for PWM configuration. After configuration, maintain the square wave frequency of PWM at 38KHz. Through this method, the detection and correction of the infrared carrier frequency of the electricity meter are realized, and then it is introduced into the infrared emission part to cooperate with the universal asynchronous receiver / transmitter for infrared data transmission.
[0069] It should be noted that the universal asynchronous receiver / transmitter (UART) is a commonly used serial communication protocol, which is widely used for data transmission between microcontrollers and other electronic devices. Asynchronous communication: UART does not require a clock signal to synchronize data transmission. It relies on a pre-agreed baud rate to synchronize the sending and receiving devices. Data format: UART communication is usually transmitted in the form of data frames. Each data frame includes: Start bit (1 bit): Indicates the start of the data. Data bits (usually 5 to 9 bits): The actual data to be transmitted. Stop bit (1 or 2 bits): Indicates the end of the data. Optional parity bit: Used for error detection.
[0070] Specifically, refer to Figure 6 As shown, infrared data transmission is triggered when the serial port TXD inside the MCU is at a low level, and the infrared emitting tube emits infrared rays at a 38KHz carrier.
[0071] It should be noted that the 38KHz carrier is a square with a duty cycle of 50% generated by the electricity meter MCU through PWM. After passing through the R42 resistor, it reaches the transistor. When there is no data communication, the serial port TXD inside the MCU is defaulted to a high level. After turning on the Q19 triode, when there is no communication, 38KHz is equivalent to connecting to the reference ground, and at this time Q18 is not turned on, and the D12 infrared emitting tube does not work, and the infrared signal is not emitted. When there is communication data in TXD (communication is triggered by the falling edge of the serial port) and it is at a low level, Q19 is not turned on, and the 38KHz carrier turns on Q18, thus triggering the infrared emitting tube D12 to emit at a 38KHz carrier. Thus, the function of infrared emission is achieved. Thus, the infrared emission function is realized.
[0072] Through a method for detecting and correcting the infrared communication carrier frequency of an electric energy meter, combined with the design of the electric energy meter and the mainboard, an external communication interface is reserved on the mainboard. After the infrared carrier frequency is detected and confirmed, its center frequency is corrected, so that the infrared carrier center frequency is kept at 38KHz in real time, ensuring the stability and reliability of infrared communication, thereby improving the success rate of the meter reading terminal using infrared communication to read the electric energy meter data, and also improving the infrared communication distance, so that the power operation and maintenance personnel can read the electric energy meter data normally at a long distance from the electric energy meter, ensuring its safety. The management efficiency of power operation and maintenance is greatly improved.
[0073] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for detecting and correcting the infrared communication carrier frequency of an electric energy meter, characterized in that: The method for detection and correction includes the following steps: S1. First, after the electric energy meter is powered on, initialization is performed; S2. Configure the PWM clock frequency through the MCU of the electric energy meter, and define the division coefficient K of the PWM as a variable in the program. Write the default value of the division coefficient K at the time of factory production, synchronously store it in the FLASH and perform power-off preservation; S3. Perform register setting, and when initializing each time the electric energy meter works, read the division coefficient K in the FLASH and call the division coefficient K of the PWM to write to the set register; S4. Start the electric energy meter to output a PWM square wave; S5. The handheld detection terminal performs frequency sampling detection on the square wave output by the electric energy meter; S6. Calculate the measured square wave frequency value, obtain the actual measured square wave frequency value set as fc, and the unit is KHz; S7. Combine the square wave frequency standard value to correct the division coefficient K value of the actual square wave frequency measurement value, where the square wave PWM frequency standard value is set as fb, and the value is 38 KHz; S8. Communicate the corrected division coefficient k value with the MCU inside the electric energy meter through the data communication interface of the handheld detection terminal; S9. After the MCU inside the electric energy meter receives the corrected division coefficient k value, rewrite it into the register configured by the PWM. After configuration, maintain the square wave frequency of the PWM at 38 KHz, and then introduce it to the infrared emission part to cooperate with the universal asynchronous transceiver to perform infrared data transmission.
2. The method for detecting and correcting the infrared communication carrier frequency of an electric energy meter according to claim 1, characterized in that: The square wave frequency standard value of 38 KHz is obtained by setting the division coefficient K through the crystal oscillator clock inside the MCU.
3. The method for detecting and correcting the infrared communication carrier frequency of an electric energy meter according to claim 2, characterized in that: The default value calculation formula of the division coefficient K is: K = 16 MHz / 38 KHz ≈ 421 (1); Among them, 16 MHz is the main frequency provided to the MCU after the crystal oscillator is powered on and starts to oscillate, and 38 KHz is the square wave PWM frequency standard value. Therefore, after writing the division coefficient K = 421 into the relevant PWM register of the MCU through software, a square wave of 38 KHz can be generated.
4. The method for detecting and correcting the infrared communication carrier frequency of an electric energy meter according to claim 1, characterized in that: During the process of setting the S3 register, add a modification interface for the division coefficient K, and allow the interface protocol with the handheld detection terminal to be modified through communication.
5. A method for detecting and correcting the infrared communication carrier frequency of an electric energy meter according to claim 4, characterized in that: When the handheld detection terminal performs frequency detection and correction, adjust the division coefficient K according to the correction parameters transmitted by the handheld detection terminal, and synchronously update the corrected division coefficient K to the FLASH, so that the electric energy meter can use the latest corrected division coefficient K every time it calls the PWM function.
6. The method for detecting and correcting the infrared communication carrier frequency of an electric energy meter according to claim 1, characterized in that: The correction discrimination of the division coefficient K value is performed by comparing the actual measured square wave frequency value fc and the square wave PWM frequency standard value fb, which is expressed as: If fc > fb, increase the division K. If fc < fb, decrease the division K.
7. The method for detecting and correcting the infrared communication carrier frequency of an electric energy meter according to claim 1, characterized in that: The handheld detection terminal is a frequency measurement standard device with communication function, and is regularly calibrated and verified by a detection agency to ensure the measurement accuracy of the handheld detection terminal.
8. A method for detecting and correcting the infrared communication carrier frequency of an electric energy meter according to claim 7, characterized in that: The frequency sampling measurement and data transmission process of the handheld detection terminal includes the following operations: A1. First, the measured signal is amplified to reach the signal amplitude and effective range for effective sampling of the handheld detection terminal; A2, then the measured signal passes through a comparator designed by an operational amplifier, so that the collected signal meets the receiving level range of the subsequent processor; A3, then the measured signal passes through the signal follower to further ensure the impedance matching of the signal before entering the FPGA; A4, finally improves the accuracy and stability of the sampling of the measured signal, and the FPGA sampling adopts the effective form of the falling edge pulse, and the frequency value is calculated after sampling by the FPGA logic chip.
9. A method for detecting and correcting the infrared communication carrier frequency of an electric energy meter according to claim 8, characterized in that: The frequency value is calculated in the internal program of the FPGA. First, the falling edge pulse sampled in 1s is defined as a valid number, and then the collected square wave frequency is obtained by conversion. Finally, the internal program processes the data and transmits the offset standard value to the MCU inside the electric energy meter through the communication interface.
10. The method for detecting and correcting the infrared communication carrier frequency of an electric energy meter according to claim 1, characterized in that: The infrared data transmission is when the serial port TXD inside the MCU is at a low level, triggering the infrared transmitting tube to transmit infrared data with a 38KHz carrier.
Citation Information
Cited By
Correction method and system based on electric energy meter carrier coupling capacitor reactive crosstalk and storage medium
CN120222634A
