Communication synchronization method and system for dual-core electric energy meter protocol consistency test device

The GPIO controls the CS signal and the timer to detect the serial clock signal, which solves the problem of clock signal misalignment in the dual-core power meter and ensures the normality and accuracy of data interaction.

CN113132047BActive Publication Date: 2024-11-29CHINA ELECTRIC POWER RESEARCH INSTITUTE CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110412866.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-16
Publication Date
2024-11-29
Estimated Expiration
2041-04-16

AI Technical Summary

Technical Problem

The host in the dual-core power meter does not control the CS signal, which causes the slave to be unable to determine the starting position of the clock, causing the clock signal to be misaligned, affecting the normality of data interaction.

Method used

The CS signal is controlled through the general-purpose input and output port GPIO, and the synchronization sequence and timer are realized to detect the serial clock signal, determine the timer cycle, and clear the counting memory to synchronize the clock to avoid data misalignment.

Benefits of technology

When the host does not provide CS signals, communication monitoring is implemented, data misalignment is avoided, and data validity and accuracy are ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113132047B_ABST
    Figure CN113132047B_ABST
Patent Text Reader

Abstract

The present application discloses a communication synchronization method for a dual-core electric energy meter protocol consistency test device. The method includes: connecting a dual-core electric energy meter protocol consistency test device to a serial peripheral interface of the dual-core electric energy meter, the test device is a serial peripheral communication control device, connecting a universal input and output port to a chip select signal of the test device; according to the universal input and output port, controlling the switching of the chip select signal to realize a synchronization sequence, and starting data monitoring; allocating a timer to detect a serial clock signal, determining a timer cycle according to the interval between data frames of the serial clock signal, starting a timer to detect a serial clock signal, and the serial clock signal is a clock source of the timer; if a clock edge is detected on a timer pin, clearing the count memory of the timer until an overflow interrupt of the triggering timer is triggered, and synchronizing the clock.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a communication synchronization method and system for a dual-core electric energy meter protocol consistency test device. Background Art

[0002] As the State Grid's demand for dual-core electric energy meters increases, the new generation of State Grid meters must maintain mutual independence in legal metering functions and non-metering functions. The metering core needs to pass legal certification to ensure that it can operate independently in the case of non-metering functions and other system software upgrades, failures, etc., and ensure that it does not affect the metering accuracy, stability and data traceability. The dual core will directly exchange data through the SPI interface. Its communication must implement data interaction in accordance with certain protocol specifications. Otherwise, normal data interaction cannot be achieved, affecting the normal operation of the electric energy meter. Therefore, a dual-core electric energy meter protocol consistency test device is required to capture the communication protocol of the SPI interface to test the protocol consistency.

[0003] SPI (Serial Peripheral Interface) is a high-speed, full-duplex, synchronous communication bus. It works in master-slave mode. Generally, the host controls the slave through the SPI's CS (Chip Select) signal, which is used to synchronize the SCLK (Serial Clock) of the host SPI and receive and send data on the clock edge. If the host does not control the CS signal, the slave cannot determine the starting position of the clock, resulting in clock signal misalignment, causing data misalignment, and affecting the normal interaction of data.

[0004] With respect to the technical problem that if the host does not control the CS signal in the dual-core electric energy meter in the above-mentioned prior art, the slave cannot determine the starting position of the clock, resulting in clock signal misalignment, causing data misalignment, and affecting the normal data interaction, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present disclosure provide a communication synchronization method and system for a dual-core electric energy meter protocol consistency test device, so as to at least solve the technical problem in the prior art that if the host of the dual-core electric energy meter does not control the CS signal, the slave cannot determine the starting position of the clock, resulting in clock signal misalignment, causing data misalignment and affecting the normal data interaction.

[0006] According to one aspect of an embodiment of the present disclosure, a communication synchronization method for a dual-core electric energy meter protocol consistency test device is provided, comprising: connecting a dual-core electric energy meter protocol consistency test device to a serial peripheral interface of the dual-core electric energy meter, the test device being a serial peripheral communication control device, and connecting a universal input / output port to a chip select signal of the test device; according to the universal input / output port, controlling the switching of the chip select signal to implement a synchronization sequence, and starting data monitoring; allocating a timer to detect a serial clock signal, determining a timer period according to an interval between data frames of the serial clock signal, starting the timer to detect a serial clock signal, the serial clock signal being a clock source of the timer; if a clock edge is detected on the timer pin, clearing the count memory of the timer until an overflow interrupt of the trigger timer is triggered, and synchronizing the clock.

[0007] According to another aspect of the embodiment of the present disclosure, a communication synchronization system of a dual-core electric energy meter protocol consistency test device is also provided, including: an access connection module, used to connect the dual-core electric energy meter protocol consistency test device to the serial peripheral interface of the dual-core electric energy meter, the test device is a serial peripheral communication control device, and connects the general input and output port with the chip select signal of the test device; a synchronization sequence module, used to control the switching of the chip select signal according to the general input and output port to realize the synchronization sequence and start data monitoring; a detection signal module, used to allocate a timer to detect a serial clock signal, determine the timer period according to the interval between the data frames of the serial clock signal, start the timer to detect the serial clock signal, and the serial clock signal is the clock source of the timer; a synchronization clock module, used to clear the count memory of the timer to zero if a clock edge is detected on the timer pin until the overflow interrupt of the trigger timer is triggered, and synchronize the clock.

[0008] In the present invention, the CS signal is controlled through the general purpose input and output port GPIO, and the clock is synchronized at intervals, so that communication monitoring can be achieved when the host has no CS signal, which solves the problem that the slave cannot determine the starting position of the clock, avoids data misalignment, and ensures the validity of the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present application. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure. In the drawings:

[0010] Figure 1 It is a flow chart of a communication synchronization method of a dual-core electric energy meter protocol consistency test device according to an embodiment of the present disclosure;

[0011] Figure 2 It is a flow chart of a communication synchronization method of a dual-core electric energy meter protocol consistency test device according to an embodiment of the present disclosure;

[0012] Figure 3 is a schematic diagram of a chip select signal synchronization sequence according to an embodiment of the present disclosure;

[0013] Figure 4 It is a schematic diagram of a communication synchronization system of a dual-core electric energy meter protocol consistency testing device according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0014] Now, exemplary embodiments of the present invention are described with reference to the accompanying drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. These embodiments are provided to disclose the present invention in detail and completely and to fully convey the scope of the present invention to those skilled in the art. The terms used in the exemplary embodiments shown in the accompanying drawings are not intended to limit the present invention. In the accompanying drawings, the same units / elements are marked with the same reference numerals.

[0015] Unless otherwise specified, the terms (including technical terms) used herein have the commonly understood meanings to those skilled in the art. In addition, it is understood that the terms defined in commonly used dictionaries should be understood to have the same meanings as those in the context of the relevant fields, and should not be understood as idealized or overly formal meanings.

[0016] According to a first aspect of this embodiment, a communication synchronization method 100 of a dual-core electric energy meter protocol consistency test device is provided. Figure 1 As shown, the method 100 includes:

[0017] S102: Connecting a dual-core electric energy meter protocol consistency test device to the serial peripheral interface of the dual-core electric energy meter, wherein the test device is a serial peripheral communication control device, and connecting a general-purpose input and output port to a chip select signal of the test device;

[0018] S104: According to the universal input and output port, control the switching of the chip select signal to implement a synchronization sequence and start data monitoring;

[0019] S106: Allocate a timer to detect a serial clock signal, determine a timer period according to an interval between data frames of the serial clock signal, start the timer to detect the serial clock signal, and the serial clock signal is a clock source of the timer;

[0020] S108: If a clock edge is detected on the timer pin, the count memory of the timer is cleared until the overflow interrupt of the timer is triggered, and the clock is synchronized.

[0021] Specifically, refer to the dual-core electric energy meter protocol consistency test device as a slave, access the dual-core SPI interface, use the interaction interval between communication data protocol frames, and actively switch the CS signal through the synchronization sequence that prohibits and re-enables the slave CS signal to achieve clock synchronization.

[0022] Specific workflow reference Figure 2 As shown below:

[0023] Step 1: The dual-core electric energy meter protocol consistency test device itself is used as a SPI communication monitoring device and will work as a SPI slave device. Use a GPIO (General-purpose input / output) to connect to the CS (chip select) signal of the SPI peripheral to control the switching of CS to achieve the synchronization sequence;

[0024] Step 2: Control GPIO to pull CS high so that SPI does not receive data on the SDI (Serial Data Input) pin to prevent abnormal data from being received when it is not ready.

[0025] Step 3: Set the SPI CS signal to hardware control, let the MCU's SPI peripheral enter the data receiving and sending state by itself, enable SPI, and start data monitoring;

[0026] Step 4: Allocate a timer to detect SCLK, and use the SCLK signal as the clock source of the timer. Determine the timer period based on the SCLK interval (the interval between data frames) and start the timer;

[0027] Step 5: When the timer detects the clock signal SCLK, if a clock edge is detected on the timer pin, the timer count register is cleared to 0, and step 5 is repeated until the timer overflow interrupt is triggered; once the timer overflow interrupt is entered, it means that there is no clock signal within the judgment time, that is, no data frame is received, then the clock can be resynchronized and step 6 is entered;

[0028] Step 6: Control the CS signal to perform a synchronization sequence: pull the CS signal high and then low to achieve clock synchronization, and return to step 5 to repeat the operation.

[0029] Furthermore, in step 4, the SCLK interval (the interval between data frames) needs to be greater than the SCLK clock cycle.

[0030] Furthermore, the overflow value of the timer in step 5 is determined according to the interval of SCLK and the clock cycle of SCLK. The overflow value needs to be greater than the clock cycle of SCLK and less than the interval of SCLK.

[0031] Furthermore, the synchronization sequence of the CS signal in step 6 needs to be completed within the SCLK interval.

[0032] Therefore, by controlling the CS signal and intermittently synchronizing the clock through the general-purpose input and output port GPIO, communication monitoring can be achieved when the host has no CS signal, solving the problem that the slave cannot determine the starting position of the clock, avoiding data misalignment, and ensuring the validity of the data.

[0033] Optionally, according to the universal input / output port, the switching of the chip select signal is controlled to implement a synchronization sequence and start data monitoring, including: according to the universal input / output port, the chip select signal is controlled to be pulled high so that the serial peripheral interface does not receive and process the data on the serial data input pin; the control mode of the chip select signal controlled by the universal input / output port is determined as hardware control so that the serial peripheral interface automatically enters a data sending and receiving state, the serial peripheral interface is enabled, and data monitoring is started.

[0034] Optionally, according to the universal input and output port, the switching of the chip select signal is controlled to realize a synchronization sequence and start data monitoring, and also includes: after controlling the chip select signal to be pulled high, the chip select signal is pulled low to realize synchronous clock synchronization; if a clock edge is detected on the timer pin, the count memory of the timer is cleared to zero until the overflow interrupt of the timer is triggered, and then the step of synchronizing the clock is repeated.

[0035] Optionally, the interval between data frames of the serial clock signal is greater than a clock period of the serial clock signal, and the switching of the chip select signal is controlled to complete the synchronization sequence within the interval time of the serial clock signal.

[0036] Optionally, if a clock edge is detected on the timer pin, the count memory of the timer is cleared until the overflow interrupt of the timer is triggered, and the clock is synchronized, including: determining the overflow value of the timer based on the interval of the serial clock signal and the clock cycle of the serial clock signal, the overflow value being greater than the clock cycle of the serial clock signal and less than the clock cycle of the serial clock signal.

[0037] Therefore, by controlling the CS signal and intermittently synchronizing the clock through the general-purpose input and output port GPIO, communication monitoring can be achieved when the host has no CS signal, solving the problem that the slave cannot determine the starting position of the clock, avoiding data misalignment, and ensuring the validity of the data.

[0038] According to another aspect of the present embodiment, a communication synchronization system 400 of a dual-core electric energy meter protocol consistency test device is also provided. The system 400 includes: an access interface module 410, which is used to connect the dual-core electric energy meter protocol consistency test device to the serial peripheral interface of the dual-core electric energy meter, the test device is a serial peripheral communication control device, and the universal input and output port is connected to the chip select signal of the test device; a synchronization sequence module 420, which is used to control the switching of the chip select signal according to the universal input and output port to realize the synchronization sequence and start data monitoring; a detection signal module 430, which is used to allocate a timer to detect a serial clock signal, determine the timer period according to the interval between the data frames of the serial clock signal, start the timer to detect the serial clock signal, and the serial clock signal is the clock source of the timer; a synchronization clock module 440, which is used to clear the count memory of the timer until the overflow interrupt of the trigger timer is triggered if a clock edge is detected on the timer pin, and synchronize the clock.

[0039] Optionally, the synchronization sequence module 420 includes: a control signal pulling high submodule, used to control the chip select signal to be pulled high according to the universal input and output port, so that the serial peripheral interface does not receive and process the data on the serial data input pin; and a control mode determination submodule, used to determine the control mode of the chip select signal controlled by the universal input and output port as hardware control, so that the serial peripheral interface automatically enters the data sending and receiving state, enables the serial peripheral interface, and starts monitoring data.

[0040] Optionally, the synchronization sequence module 420 also includes: a chip select signal pull-down submodule, which is used to pull down the chip select signal after controlling the chip select signal to be pulled high, so as to achieve synchronous clock synchronization; and a repeat synchronous clock submodule, which is used to repeat the step of synchronizing the clock by clearing the count memory of the timer until an overflow interrupt of the timer is triggered if a clock edge is detected on the timer pin.

[0041] Optionally, the interval between data frames of the serial clock signal is greater than a clock period of the serial clock signal, and the switching of the chip select signal is controlled to complete the synchronization sequence within the interval time of the serial clock signal.

[0042] Optionally, the synchronous clock module 440 includes: a submodule for determining an overflow value, which is used to determine the overflow value of the timer according to the interval of the serial clock signal and the clock cycle of the serial clock signal, and the overflow value is greater than the clock cycle of the serial clock signal and less than the clock cycle of the serial clock signal.

[0043] The communication synchronization system 400 of a dual-core electric energy meter protocol consistency test device in an embodiment of the present invention corresponds to the communication synchronization method 100 of a dual-core electric energy meter protocol consistency test device in another embodiment of the present invention, which will not be described in detail here.

[0044] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of complete hardware embodiments, complete software embodiments, or embodiments in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code. The scheme in the embodiments of the present application can be implemented in various computer languages, for example, object-oriented programming language Java and literal scripting language JavaScript, etc.

[0045] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0046] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0047] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0048] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0049] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A communication synchronization method for a dual-core electric energy meter protocol consistency test device, It is characterized in that include: Connect a dual-core electric energy meter protocol consistency test device to the serial peripheral interface of the dual-core electric energy meter, wherein the test device is a serial peripheral communication control device, and connect a universal input and output port to a chip select signal of the test device; According to the universal input and output port, control the switching of the chip select signal to realize the synchronization sequence and start data monitoring; Allocate a timer to detect a serial clock signal, determine a timer period according to an interval between data frames of the serial clock signal, start the timer to detect the serial clock signal, and the serial clock signal is a clock source of the timer; If a clock edge is detected on the timer pin, the count memory of the timer is cleared until an overflow interrupt of the triggering timer is triggered, and the clock is synchronized; According to the universal input and output port, the switching of the chip select signal is controlled to realize the synchronization sequence and start data monitoring, including: According to the universal input and output port, controlling the chip select signal to be pulled high, so that the serial peripheral interface does not receive and process the data on the serial data input pin; The control mode of the chip select signal controlled by the universal input / output port is determined to be hardware control, so that the serial peripheral interface automatically enters a data transceiver state, enables the serial peripheral interface, and starts monitoring data; According to the universal input and output port, the switching of the chip select signal is controlled to realize the synchronization sequence, and data monitoring is started, and the method further includes: After controlling the chip select signal to be pulled high, pulling the chip select signal low to achieve clock synchronization; Repeat the steps of clearing the count memory of the timer to zero if a clock edge is detected on the timer pin until an overflow interrupt of the timer is triggered, and then synchronizing the clock.

2. The method according to claim 1, It is characterized in that The interval between data frames of the serial clock signal is greater than the clock period of the serial clock signal, and the switching of the chip select signal is controlled to achieve that the synchronization sequence is completed within the interval time of the serial clock signal.

3. The method according to claim 1, It is characterized in that If a clock edge is detected on the timer pin, the count memory of the timer is cleared until an overflow interrupt of the timer is triggered, and the clock is synchronized, including: An overflow value of a timer is determined according to an interval of the serial clock signal and a clock cycle of the serial clock signal, wherein the overflow value is greater than the clock cycle of the serial clock signal and less than the clock cycle of the serial clock signal.

4. A communication synchronization system for a dual-core electric energy meter protocol consistency test device, It is characterized in that include: An access interface module is used to connect a dual-core electric energy meter protocol consistency test device to the serial peripheral interface of the dual-core electric energy meter, wherein the test device is a serial peripheral communication control device, and connects a general-purpose input and output port to a chip select signal of the test device; A synchronization sequence module, used to control the switching of the chip select signal to realize the synchronization sequence and start data monitoring according to the universal input and output port; A detection signal module, used for allocating a timer to detect a serial clock signal, determining a timer period according to an interval between data frames of the serial clock signal, and starting the timer to detect the serial clock signal, wherein the serial clock signal is a clock source of the timer; A synchronous clock module, for clearing the count memory of the timer to zero if a clock edge is detected on the timer pin until an overflow interrupt of the timer is triggered, and synchronizing the clock; Synchronous sequence module, including: A control signal pull-up submodule, used for controlling the chip select signal to be pulled high according to the universal input and output port, so that the serial peripheral interface does not receive and process the data on the serial data input pin; and A control mode determination submodule is used to determine the control mode of the chip select signal controlled by the universal input / output port as hardware control, so that the serial peripheral interface automatically enters a data transceiver state, enables the serial peripheral interface, and starts monitoring data; The synchronization sequence module also includes: A chip select signal pull-down submodule is used to pull down the chip select signal after controlling the chip select signal to be pulled high, so as to achieve clock synchronization; The repeating synchronous clock submodule is used to repeat the steps of clearing the count memory of the timer to zero if a clock edge is detected on the timer pin until an overflow interrupt of the timer is triggered, and then synchronizing the clock.

5. The system according to claim 4, It is characterized in that include: The interval between data frames of the serial clock signal is greater than the clock period of the serial clock signal, and the switching of the chip select signal is controlled to achieve that the synchronization sequence is completed within the interval time of the serial clock signal.

6. The system according to claim 4, It is characterized in that Synchronous clock module, including: The overflow value determination submodule is used to determine the overflow value of the timer according to the interval of the serial clock signal and the clock cycle of the serial clock signal, wherein the overflow value is greater than the clock cycle of the serial clock signal and less than the clock cycle of the serial clock signal.

Citation Information

Patent Citations

  • Intelligent mobile communication base station energy management system

    CN105589438A

  • Method and system for synchronization testing of electric quantity of double-core electric energy meter

    CN106569164A