Management and communication method suitable for metering chip of electric energy meter
By using the communication mechanism of asynchronous and synchronous virtual metering chips, the problems of low communication speed of low-cost metering chips and low resource utilization of advanced metering chips are solved, and efficient and stable multi-task concurrency and synchronous data acquisition are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGSU LINYANG ENERGY CO LTD
- Filing Date
- 2025-12-25
- Publication Date
- 2026-05-08
AI Technical Summary
Existing low-cost metering chips have low communication speeds, making it difficult to support the implementation of advanced functions. Furthermore, the single communication interface of advanced metering chips limits resource utilization and task parallel processing capabilities.
The asynchronous non-blocking communication mechanism of the asynchronous virtual metering chip and the multi-channel synchronous communication mechanism of the synchronous virtual metering chip are adopted. The communication state is managed by a state machine to achieve non-blocking scheduling and multi-task concurrency support, thereby optimizing communication throughput and data synchronous acquisition.
It improves the utilization rate of communication resources, reduces communication conflicts and latency, ensures the stability and efficiency of multi-chip collaborative work, and supports reliable communication in complex metering scenarios.
Smart Images

Figure CN121996438A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart meters, and more specifically, to a management and communication method applicable to metering chips in electricity meters. Background Technology
[0002] As smart meter technology continues to evolve, users' demands for meter functionality are increasing. Especially with the growing need for power quality monitoring, particularly regarding harmonics and interharmonics, higher requirements are being placed on the communication speed and data exchange content of metering chips. However, currently widely used low-cost metering chips typically only support low-speed UART communication. If advanced functions such as harmonic analysis are to be implemented on these chips, the traditional in-place, wait-and-go UART communication processing method will be unsuitable, as it will consume CPU resources for extended periods, severely impacting the overall system response and processing efficiency.
[0003] In composite schemes employing multiple single-phase low-cost metering chips (such as the 3MnCo tungsten energy meter), the system needs to access each metering chip at a high frequency to obtain instantaneous power data in order to complete power integration calculations. Simultaneously, it must achieve synchronous acquisition of data from multiple chips to ensure temporal consistency of data across phases. Furthermore, complex communication tasks such as raw waveform transmission place higher demands on the system's real-time performance and concurrent processing capabilities.
[0004] On the other hand, while advanced metering chips such as metering SOCs can provide richer functions and support complex services such as "harmonic analysis," "raw waveform output," and "power quality monitoring," their communication channels with external systems are often still limited to a single interface. When a certain service task continuously occupies this communication interface to interact with the metering chip, other services are forced to wait, which limits the overall resource utilization and parallel processing capabilities of the system.
[0005] Therefore, there is an urgent need for a new communication management method for metering chips that can effectively improve communication throughput, ensure concurrent execution of multiple tasks, and realize synchronous data acquisition and processing among multiple chips without increasing hardware costs. Summary of the Invention
[0006] This invention addresses a series of technical problems caused by the fact that existing low-cost metering chips used in electricity meters only support low-speed UART communication interfaces, and provides a management and communication method suitable for electricity meter metering chips. This method achieves non-blocking scheduling, multi-task concurrency support, and multi-channel quasi-synchronous communication control of the communication process of the real metering chip by constructing an architecture of asynchronous and synchronous virtual metering chips.
[0007] The technical solution of this invention is: In a first aspect, the present invention provides a management and communication method applicable to electricity meter metering chips, wherein a state machine is configured for each real metering chip to manage the communication state of the corresponding real metering chip; the communication method includes an asynchronous non-blocking communication mechanism based on asynchronous virtual metering chips and a multi-channel synchronous communication mechanism based on synchronous virtual metering chips; The asynchronous virtual metering chip is deployed in a one-to-one correspondence with each real metering chip, and is used to proxy all business modules' access requests to the real metering chip. The synchronous virtual metering chip is used to proxy business requests that need to access multiple real metering chips simultaneously, and to coordinate the start timing of communication in each channel to achieve time alignment of data collection.
[0008] Furthermore, for the asynchronous virtual metering chip, when a task needs to access the real metering chip, it sends a communication request to the asynchronous virtual metering chip, which then inserts the communication request into the asynchronous communication request loop. An asynchronous scheduler is used to extract communication requests from the asynchronous communication request loop. Communication frame data is generated based on the parameters of the communication request and the metering chip protocol and provided to the state machine. The communication frame data includes the sending frame, the sending length, and the receiving length. After the scheduler sends the first byte of communication frame data, it is managed by the state machine.
[0009] Furthermore, the asynchronous communication request ring is a ring data structure that can sequentially store multiple communication requests and cyclically use a preset RAM space; When a communication request is inserted into the asynchronous communication request ring, if a low-priority task is being inserted, the high-priority task will wait for the low-priority task to finish inserting before it can access the request, through mutual exclusion protection. The asynchronous communication request ring provides an occupancy function. For tasks that need to guarantee the execution order, the asynchronous communication request ring prevents other tasks from accessing it. At this time, the task exclusively uses the asynchronous virtual metering chip, and accessing the asynchronous virtual metering chip is equivalent to directly accessing the real metering chip.
[0010] Furthermore, the state machine includes five states: communication idle, transmitting, receiving, communication error, and serial port reset. The state machine is initially in the communication idle state; After the asynchronous scheduler sends the first byte, the state machine switches to the sending state. After sending is complete, the state machine switches to receiving. During the receiving process, if the number of bytes received reaches the length specified in the request, the measurement chip protocol is used for verification. If the verification passes, the received data is filled into the task container to restore communication idle. If the verification fails or a disconnection occurs during the receiving process, the state machine transitions to the communication error state.
[0011] Furthermore, in the communication error state, the state machine checks whether the communication request is configured with a number of retries; If there are remaining retries, after a preset serial port silence period, the state machine will be restored to the idle state, and the asynchronous scheduler will retrieve the communication request again and resend it in the next cycle. If there are no remaining retries, the state machine enters the serial port reset state. After the management task intervenes to handle the exception, the state machine is returned to the idle state.
[0012] Furthermore, for the synchronous virtual metering chip, when a task needs to acquire data from multiple metering chips simultaneously, a synchronous communication request is sent to the synchronous virtual metering chip, and the synchronous virtual metering chip inserts the communication requests of each real metering chip into the corresponding synchronous communication request ring. A synchronous scheduler is used to check the synchronous communication request ring. If a synchronous request exists, all new request scheduling of asynchronous schedulers is stopped. When the ongoing communication ends, it indicates that the corresponding real metering chip channel is idle. At this time, the synchronous request is extracted to generate a communication frame and start communication of each channel in sequence. The subsequent management is handled by a state machine.
[0013] Furthermore, the synchronization request ring is a ring group structure corresponding to multiple real metering chips, and internally it is a communication request ring of multiple symmetrical single real metering chips. When a task accesses the virtual metering chip, it combines the communication requests from each real metering chip and inserts them together into the synchronization request loop.
[0014] Furthermore, the synchronous scheduler periodically checks whether there is a synchronous communication request in the synchronous request ring. If there is, it stops scheduling new requests from all asynchronous schedulers and checks whether the state machine of each corresponding real metering chip is idle. After all state machines are idle, the synchronous scheduler extracts the synchronous request from the synchronous request ring, generates each communication frame according to the synchronous request parameters, shortens the start interval of each channel and sends the first byte in sequence. The subsequent communication of each channel is managed by the state machine.
[0015] Secondly, the present invention provides a management and communication system suitable for electricity meter metering chips, applied to the method described, comprising: The state machine module corresponds to the configuration of each actual metering chip and is used to manage the communication status of the corresponding actual metering chip. An asynchronous communication module implements an asynchronous non-blocking communication mechanism based on an asynchronous virtual metering chip. The asynchronous virtual metering chip is deployed one-to-one with each real metering chip and is used to proxy all business modules' access requests to the corresponding real metering chip. The synchronous communication module implements a multi-channel synchronous communication mechanism based on a synchronous virtual metering chip. The synchronous virtual metering chip is used to proxy business requests that need to access multiple real metering chips simultaneously, and coordinates the start timing of communication for each channel to achieve time alignment of data acquisition from multiple real metering chips.
[0016] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the management and communication method applicable to an electricity meter metering chip.
[0017] The beneficial effects of this invention are: This invention provides a management and communication method applicable to electricity meter metering chips. By using asynchronous and synchronous communication request rings, combined with priority insertion mechanism and mutual exclusion protection, it achieves orderly storage and efficient scheduling of service requests. Through state machine fine management of communication state, it ensures the reliability of data transmission and reception and error retry mechanism. The synchronous scheduler optimizes the channel start interval by periodically checking the state of each chip, thereby achieving near-synchronous communication.
[0018] The solution of this invention significantly improves the utilization rate of communication resources in multi-service scenarios, reduces communication conflicts and latency, ensures the stability and efficiency of multi-chip collaborative work, and provides reliable technical support for complex metering scenarios.
[0019] Other features and advantages of the present invention will be described in detail in the following detailed description section. Attached Figure Description
[0020] The above and other objects, features and advantages of the present invention will become more apparent from the more detailed description of exemplary embodiments of the invention in conjunction with the accompanying drawings, wherein the same reference numerals generally represent the same components in the exemplary embodiments of the invention.
[0021] Figure 1 A flowchart illustrating the asynchronous non-blocking communication process based on the asynchronous virtual metering chip in this invention is shown.
[0022] Figure 2 A flowchart of the multi-channel synchronous communication process based on the synchronous virtual metering chip in this invention is shown. Detailed Implementation
[0023] Preferred embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While preferred embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be limited to the embodiments set forth herein.
[0024] This invention provides a management and communication method for electricity meter metering chips, wherein a state machine is configured for each real metering chip to manage the communication state of the corresponding real metering chip; the communication method includes an asynchronous non-blocking communication mechanism based on asynchronous virtual metering chips and a multi-channel synchronous communication mechanism based on synchronous virtual metering chips; The asynchronous virtual metering chip is deployed in a one-to-one correspondence with each real metering chip, and is used to proxy all business modules' access requests to the real metering chip. The synchronous virtual metering chip is used to proxy business requests that need to access multiple real metering chips simultaneously, and to coordinate the start timing of communication in each channel to achieve time alignment of data collection.
[0025] Figure 1 A flowchart illustrating the asynchronous non-blocking communication process based on the asynchronous virtual metering chip in this invention is shown.
[0026] like Figure 1 As shown, for the asynchronous virtual metering chip, when a task needs to access the real metering chip, it sends a communication request to the asynchronous virtual metering chip, and the asynchronous virtual metering chip inserts the communication request into the asynchronous communication request loop. An asynchronous scheduler is used to extract communication requests from the asynchronous communication request loop. Communication frame data is generated based on the parameters of the communication request and the metering chip protocol and provided to the state machine. The communication frame data includes the sending frame, the sending length, and the receiving length. After the scheduler sends the first byte of communication frame data, it is managed by the state machine.
[0027] Specifically, an asynchronous virtual metering chip is embedded between each service and the real metering chip. When each service accesses the real metering chip, it actually accesses the virtual metering chip. The asynchronous virtual metering chip is responsible for saving the access requests of each service to the asynchronous communication request ring.
[0028] An asynchronous communication request ring is a ring-shaped data structure whose core concept is to use a ring to store communication requests. The ring can store multiple communication requests sequentially and can handle unlimited insertions and retrievals with limited RAM resources. When the allocated RAM space is exhausted by inserted communication requests, previously used positions are reused. This also facilitates high-priority services communicating with the metering chip in advance; only the ring head needs to be inserted.
[0029] When multiple services simultaneously require access to the asynchronous virtual metering chip, the requests are inserted into the communication ring in the order of actual access.
[0030] The communication request ring will protect against resource mutual exclusion. When a low-priority service is accessing the metering chip and inserting a communication request into the communication request ring, if a high-priority service also needs to access the metering chip at this time, it will not be allowed to access the chip due to the existence of the mutual exclusion lock. It can only wait until the low-priority service has finished accessing the chip before it can access the chip.
[0031] The communication request ring provides a occupancy function. For services that require guaranteed execution order or immediate communication, this function can be used to independently occupy the metering request ring. In this case, the asynchronous virtual metering chip truly belongs to the occupying service, exclusively occupying the real metering chip. Under occupancy, other services cannot access the virtual metering chip.
[0032] When the state machine is idle, the asynchronous scheduler is responsible for extracting a communication request from the metering request loop according to a certain strategy, organizing the communication frame format according to the request parameters and the metering chip manual, obtaining information such as the sending frame, sending length, and receiving length, and then passing this information to the state machine and sending the first byte. The subsequent management is then handled by the state machine.
[0033] To ensure timely processing of communication requests, the asynchronous scheduler needs to be invoked during periodic interrupts.
[0034] The asynchronous scheduler has the following states: The asynchronous scheduler is not running: This is the default state or the state after a CPU reset, meaning the asynchronous scheduler is not running.
[0035] Asynchronous scheduler in operation: The asynchronous scheduler is in normal operating state, normally extracting data from the asynchronous metering request loop and framing and sending it; Asynchronous scheduler in suspension: The asynchronous scheduler is in a paused state, meaning it is no longer retrieving data from the asynchronous metering request loop.
[0036] The above states allow for suspension and resumption of operation via the asynchronous scheduler controlled by the business. When a business needs to immediately access the actual metering chip or stop the virtual metering chip from accessing the actual metering chip, the asynchronous scheduler can be suspended to pause the extraction of data from the metering request loop. The business can then independently access the actual metering chip while bypassing the virtual metering chip.
[0037] A state machine has the following states: ① Communication Idle State: Only maintains the idle state; communication is initiated by the scheduler, i.e., the first byte is sent.
[0038] ② During communication transmission: Determine if the transmission is interrupted. If interrupted, set the state machine to communication error. After transmission is completed in the UART interrupt function, switch to communication reception.
[0039] ③ During communication reception: Check if the number of received bytes has reached the required length. If so, perform a communication check on the received data according to the metering chip manual.
[0040] Once the check is successful, the received data is filled into the container provided by the service, the communication ends, the state machine returns to the communication idle state, and the scheduler can extract new requests from the communication request ring again to start interacting with the real metering chip again.
[0041] If the check fails, the state machine is set to a communication error. If reception is not complete, check if the reception has been interrupted. If the reception has been interrupted, the state machine is set to a communication error.
[0042] ④ Communication Error State: Check if there are any retransmission attempts. If so, after the serial port silence period ends, restore the state machine to the idle state, and the scheduler will restart the communication request. If there are no retransmission attempts, set the state machine to the communication reset state.
[0043] ⑤ Serial port reset state: Remains in the reset state. In this state, management services need to handle this abnormal state, and it can only be returned to the idle state after the handling is completed. Example
[0044] Figure 2 A flowchart of the multi-channel synchronous communication process based on the synchronous virtual metering chip in this invention is shown.
[0045] like Figure 2 As shown, for a synchronous virtual metering chip, when a task needs to acquire data from multiple metering chips simultaneously, a synchronous communication request is sent to the synchronous virtual metering chip, and the synchronous virtual metering chip inserts the communication requests of each real metering chip into the corresponding synchronous communication request ring. A synchronous scheduler is used to check the synchronous communication request ring. If a synchronous request exists, all new request scheduling of asynchronous schedulers is stopped. When the ongoing communication ends, it indicates that the corresponding real metering chip channel is idle. At this time, the synchronous request is extracted to generate a communication frame and start communication of each channel in sequence. The subsequent management is handled by a state machine.
[0046] Specifically, a synchronous virtual metering chip is embedded between the business and all real metering chips. When a task needs to access multiple real metering chips at the same time, it actually accesses the synchronous virtual metering chip, and the synchronous interaction request is inserted into a synchronous request ring.
[0047] The synchronous communication request ring is a ring structure that can store the communication requests of all metering chips. It contains multiple symmetrical communication request rings for individual metering chips. When accessing a synchronous virtual metering chip, the communication request to the respective metering chip is inserted into the corresponding ring.
[0048] Synchronous communication requires communication with multiple real metering chips simultaneously and can only be initiated when all the corresponding real metering chips are idle.
[0049] The synchronization scheduler is responsible for checking whether there is a synchronization communication request. If there is a synchronization communication request, it will continue to check whether the corresponding real metering chip is idle (i.e. no virtual metering chip is interacting with the real metering chip). When all the corresponding chips are idle, the synchronization scheduler will extract the synchronization request and perform synchronization communication.
[0050] During synchronous communication, due to hardware limitations, it is basically impossible to start multiple UART communications at the same time. The only thing to do is to shorten the time between starting each UART communication and reduce the interval between transmissions of each channel. Therefore, preparations such as organizing and sending frames are made according to the communication request, and then each channel is sent in sequence. Subsequent communication is managed by the state machine.
[0051] The various embodiments of the present invention have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments.
Claims
1. A management and communication method suitable for electricity meter metering chips, characterized in that, Each real metering chip is equipped with a state machine to manage the communication state of the corresponding real metering chip; the communication method includes an asynchronous non-blocking communication mechanism based on asynchronous virtual metering chips and a multi-channel synchronous communication mechanism based on synchronous virtual metering chips. The asynchronous virtual metering chip is deployed in a one-to-one correspondence with each real metering chip, and is used to proxy all business modules' access requests to the real metering chip. The synchronous virtual metering chip is used to proxy business requests that need to access multiple real metering chips simultaneously, and to coordinate the start timing of communication in each channel to achieve time alignment of data collection.
2. The management and communication method for electricity meter metering chips as described in claim 1, characterized in that, For asynchronous virtual metering chips, when a task needs to access the real metering chip, it sends a communication request to the asynchronous virtual metering chip, which then inserts the communication request into the asynchronous communication request loop. An asynchronous scheduler is used to extract communication requests from the asynchronous communication request loop. Communication frame data is generated based on the parameters of the communication request and the metering chip protocol and provided to the state machine. The communication frame data includes the sending frame, the sending length, and the receiving length. After the scheduler sends the first byte of communication frame data, it is managed by the state machine.
3. The management and communication method for electricity meter metering chips as described in claim 2, characterized in that, The asynchronous communication request ring is a ring data structure that can sequentially store multiple communication requests and cyclically use a preset RAM space; When a communication request is inserted into the asynchronous communication request ring, if a low-priority task is being inserted, the high-priority task will wait for the low-priority task to finish inserting before it can access the request, through mutual exclusion protection. The asynchronous communication request ring provides an occupancy function. For tasks that need to guarantee the execution order, the asynchronous communication request ring prevents other tasks from accessing it. At this time, the task exclusively uses the asynchronous virtual metering chip, and accessing the asynchronous virtual metering chip is equivalent to directly accessing the real metering chip.
4. The management and communication method for electricity meter metering chips as described in claim 1, characterized in that, The state machine includes five states: communication idle, transmitting, receiving, communication error, and serial port reset. The state machine is initially in the communication idle state; After the asynchronous scheduler sends the first byte, the state machine switches to the sending state. After sending is complete, the state machine switches to receiving. During the receiving process, if the number of bytes received reaches the length specified in the request, the measurement chip protocol will be used for verification. If the verification passes, the received data will be filled into the task container and communication will be restored to idle state. If the verification fails or a disconnection occurs during reception, the state machine transitions to a communication error state.
5. The management and communication method for electricity meter metering chips as described in claim 4, characterized in that, In the communication error state, the state machine checks whether the communication request has a set number of retries; If there are remaining retries, after a preset serial port silence period, the state machine will be restored to the idle state, and the asynchronous scheduler will retrieve the communication request again and resend it in the next cycle. If there are no remaining retries, the state machine enters the serial port reset state. After the management task intervenes to handle the exception, the state machine is returned to the idle state.
6. The management and communication method for electricity meter metering chips as described in claim 1, characterized in that, For the synchronous virtual metering chip, when a task needs to acquire data from multiple metering chips simultaneously, a synchronous communication request is sent to the synchronous virtual metering chip, which inserts the communication requests of each real metering chip into the corresponding synchronous communication request ring. A synchronous scheduler is used to check the synchronous communication request ring. If a synchronous request exists, all new request scheduling of asynchronous schedulers is stopped. When the ongoing communication ends, it indicates that the corresponding real metering chip channel is idle. At this time, the synchronous request is extracted to generate a communication frame and start communication of each channel in sequence. The subsequent management is handled by a state machine.
7. The management and communication method for electricity meter metering chips as described in claim 6, characterized in that, The synchronization request ring is a ring group structure corresponding to multiple real metering chips, and internally it is a communication request ring of multiple symmetrical single real metering chips. When a task accesses the virtual metering chip, it combines the communication requests from each real metering chip and inserts them together into the synchronization request loop.
8. The management and communication method for electricity meter metering chips as described in claim 6, characterized in that, A synchronization scheduler is used to periodically check whether a synchronization request ring exists for a synchronization communication request. If it exists, stop scheduling new requests for all asynchronous schedulers and check whether the state machine of each corresponding real metering chip is in an idle state; After all state machines are idle, the synchronization scheduler extracts the synchronization request from the synchronization request ring, generates each communication frame according to the synchronization request parameters, shortens the start interval of each channel and sends the first byte in sequence, and then the state machine manages the communication of each channel.
9. A management and communication system suitable for electricity meter metering chips, applied to the method described in any one of claims 1-8, characterized in that, include: The state machine module corresponds to the configuration of each actual metering chip and is used to manage the communication status of the corresponding actual metering chip. An asynchronous communication module implements an asynchronous non-blocking communication mechanism based on an asynchronous virtual metering chip. The asynchronous virtual metering chip is deployed one-to-one with each real metering chip and is used to proxy all business modules' access requests to the corresponding real metering chip. The synchronous communication module implements a multi-channel synchronous communication mechanism based on a synchronous virtual metering chip. The synchronous virtual metering chip is used to proxy business requests that need to access multiple real metering chips simultaneously, and coordinates the start timing of communication for each channel to achieve time alignment of data acquisition from multiple real metering chips.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the management and communication method applicable to the metering chip of the electricity meter as described in any one of claims 1-8.