Power data acquisition system, device and method
By optimizing the time calibration module and multi-channel communication, the problem of insufficient acquisition and communication capabilities of existing power data acquisition terminals has been solved, realizing efficient and reliable power data acquisition and transmission, supporting automated operation and maintenance of equipment, and improving system performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-03
- Publication Date
- 2026-04-03
AI Technical Summary
Existing power data acquisition terminals collect power meter data via RS485 interfaces, which have limited acquisition and communication capabilities, making it difficult to meet the needs of large-scale real-time power data acquisition and transmission. Furthermore, maintenance and upgrades are complex, time synchronization accuracy is low, and system performance is affected.
A time calibration module is used to compensate for clock drift, dynamically allocate electricity meter reading tasks, and combine multi-channel communication optimization and storage strategies to achieve efficient data acquisition and transmission. Redundant links ensure data transmission reliability and support automated operation and maintenance of equipment.
It achieves absolute accuracy and efficient parallel acquisition of power data, improves storage resource utilization, reduces maintenance costs and system downtime, and avoids the risk of data interruption.
Smart Images

Figure CN121643227B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power data acquisition technology, and in particular to power data acquisition systems, devices and methods. Background Technology
[0002] In power automation systems, accurate acquisition of electrical energy data is crucial for achieving intelligent grid management. Existing technologies collect data through electrical energy acquisition terminals and upload it to the main station for analysis and processing.
[0003] However, existing power data acquisition terminals mainly rely on RS485 interfaces to collect power meter data and communicate with the main station via Ethernet or wireless communication. Their limited acquisition and communication capabilities make it difficult to meet the needs of large-scale real-time power data acquisition and transmission. Furthermore, complex maintenance and upgrades, along with low time synchronization accuracy, negatively impact the overall system performance. Therefore, improvements are needed. Summary of the Invention
[0004] The purpose of this invention is to address the shortcomings of existing technologies by proposing an electrical energy data acquisition system, device, and method.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: the power data acquisition system includes:
[0006] The time calibration module is used to send a test frame carrying a transmission time marker to the energy meter according to the standard time reference signal, capture the arrival time marker of the energy meter's return frame, calculate the transmission loop delay value between the transmission time marker and the arrival time marker, read the real-time frequency count value of the local crystal oscillator, calculate the frequency deviation value between the real-time frequency count value and the standard time reference signal, fit the historical frequency deviation value to form a drift slope curve, extract the drift slope parameter at the current temperature, and combine the transmission loop delay value and the drift slope parameter to calculate the dynamic correction offset of the local clock and generate the clock drift compensation value.
[0007] The data acquisition and storage module is used to correct the local data acquisition time reference point according to the clock drift compensation value, scan the number of devices connected to multiple RS485 interfaces, assign the electricity meter reading task to the RS485 interface with the lowest number of connected devices, read the voltage and current values of the electricity meter, match the electricity meter address code with a preset list of key devices, allocate storage cycle parameters for the voltage and current values according to the matching results, write the voltage and current values into the non-volatile storage block of the corresponding storage cycle, and generate a hierarchical electricity dataset.
[0008] Preferably, the system further includes:
[0009] The routing transmission module is used to detect the carrier signal strength values of the Ethernet interface and 4G communication interface according to the graded power data set, calculate the data packet loss rate of the current communication link, compare the data packet loss rate with the communication quality blocking threshold, assign weight values to each communication channel according to the comparison result and the carrier signal strength value, sort the available communication channels according to the weight values, lock the communication channel with the first sort position, load the graded power data set into the transmission buffer of the locked communication channel, add cyclic redundancy check codes to the data packets, and generate the preferred channel transmission packet.
[0010] The operation and maintenance management module is used to monitor the response frame return time after the data packet is sent according to the preferred channel transmission packet, read the operating temperature value of the central processing unit and the remaining capacity value of the memory card, compare the operating temperature value with the hardware overheat protection threshold, combine the response frame return time with the hardware status parameters, send the combined status data to the cloud server, receive the remote control command code returned by the cloud, trigger the firmware update write operation according to the remote control command code, and generate the device health maintenance command.
[0011] Preferably, the time calibration module includes:
[0012] The delay calculation submodule sends a test frame carrying a transmission time marker to the energy meter according to the standard time reference signal, captures the arrival time marker of the energy meter's return frame, subtracts the transmission time marker from the arrival time marker, continuously acquires the difference data for multiple cycles, calculates the average value of the difference data, and generates the transmission loop delay value.
[0013] The drift fitting submodule reads the real-time frequency count value of the local crystal oscillator based on the transmission loop delay value, calculates the frequency deviation value between the real-time frequency count value and the standard time reference signal, obtains the current temperature sensor value, calls the historical frequency deviation record corresponding to the temperature sensor value in the memory, performs least squares linear regression calculation on the historical frequency deviation record, extracts the slope term of the regression equation, and generates drift slope parameters.
[0014] The dynamic compensation submodule records the elapsed time from the last successful satellite time synchronization operation to the current moment as the synchronization interval duration, reads the difference between the current temperature and the reference temperature, calculates the product of the drift slope parameter, the difference between the current temperature and the reference temperature, and the synchronization interval duration, adds the product to the transmission loop delay value to obtain the total correction time, writes the total correction time to the microsecond-level counter of the system clock, adjusts the microsecond field of the current system timestamp, and generates the clock drift compensation value.
[0015] Preferably, the acquisition and storage module includes:
[0016] The task allocation submodule corrects the local data acquisition time reference point according to the clock drift compensation value, traverses the status registers of all RS485 interfaces, counts the number of slave device addresses currently connected to each interface, compares the number of slave device addresses of each interface, identifies the interface number with the smallest number, maps the energy meter reading instructions to be executed to the sending queue corresponding to the interface number, and generates a balanced acquisition task list.
[0017] The data reading submodule, according to the balanced acquisition task list, drives the RS485 transceiver to send voltage reading instructions and current reading instructions to the target energy meter, receives the hexadecimal byte stream including voltage data and current data returned by the energy meter, parses the byte stream to extract voltage and current values, associates and binds the voltage and current values with the corresponding energy meter hardware address, and generates the original electrical parameter set.
[0018] The hierarchical writing submodule extracts the energy meter hardware address based on the original electrical parameter set, queries the hardware address in the preset key equipment index table, obtains the storage cycle configuration parameters corresponding to the query results, locates the target sector address based on the storage cycle configuration parameters, writes the voltage and current values to the target sector address, and generates a hierarchical energy dataset.
[0019] Preferably, the routing transmission module includes:
[0020] The link evaluation submodule reads the signal-to-noise ratio register value of the Ethernet interface controller and the received signal strength indicator value of the 4G communication interface according to the graded power dataset, counts the number of data packets in the transmission queue that have not received acknowledgment frames to calculate the packet loss rate, compares the packet loss rate with the preset communication quality blocking threshold, and assigns weight values to each communication channel according to the comparison results and signal strength values to generate channel quality status indicators.
[0021] The channel selection submodule sorts the weight values of all available communication channels in descending order according to the channel quality status index, identifies the channel identifier at the top of the sort list, detects the physical link status bit corresponding to the channel identifier, switches the data output path selector to the physical interface corresponding to the channel identifier, locks the transmission parameter configuration of the physical interface, and generates the target communication link.
[0022] Preferably, the routing transmission module further includes:
[0023] The encapsulated transmission submodule loads the graded power data set into the transmission buffer of the locked communication channel according to the target communication link, calculates the cyclic redundancy check code of the data payload, appends the cyclic redundancy check code to the end of the data frame, performs the transmission operation, and generates the preferred channel transmission packet.
[0024] Preferably, the operation and maintenance management module includes:
[0025] The status monitoring submodule starts a hardware timer to record the waiting time after the data packet is sent, reads the operating temperature value of the CPU's built-in temperature sensor, queries the remaining capacity value of the memory card file system, compares the operating temperature value with the hardware overheat protection threshold, and packages the waiting time, operating temperature value and remaining capacity value into a status byte stream to generate terminal operating status data.
[0026] The cloud interaction submodule establishes a socket connection with the cloud server based on the terminal's operating status data, sends a status byte stream through the current active link, receives a response message returned by the cloud server, parses the opcode field in the response message, compares the opcode field with the local instruction set definition table, extracts the corresponding control logic code, and generates a remote control action code.
[0027] Preferably, the operation and maintenance management module further includes:
[0028] The maintenance execution submodule verifies the digital signature of the remote control action code, suspends non-critical background tasks, erases the specified flash memory block in the firmware storage area, writes the updated data to the erased flash memory block, and generates a device health maintenance instruction.
[0029] The present invention also provides an apparatus storing computer program instructions, which, when executed by a processor, implement an electrical energy data acquisition system.
[0030] The present invention also provides a method comprising the following steps:
[0031] Based on the standard time reference signal, a test frame carrying a transmission time marker is sent to the energy meter. The arrival time marker of the energy meter's return frame is captured. The transmission loop delay value between the transmission time marker and the arrival time marker is calculated. The real-time frequency count value of the local crystal oscillator is read. The frequency deviation value between the real-time frequency count value and the standard time reference signal is calculated. The historical frequency deviation value is fitted to form a drift slope curve. The drift slope parameter at the current temperature is extracted. Combining the transmission loop delay value and the drift slope parameter, the dynamic correction offset of the local clock is calculated, and the clock drift compensation value is generated.
[0032] Based on the clock drift compensation value, the local data acquisition time reference point is corrected, the number of devices connected to the multi-channel RS485 interface is scanned, the electricity meter reading task is assigned to the RS485 interface with the lowest number of connected devices, the voltage and current values of the electricity meter are read, the electricity meter address code is matched with the preset key device list, the storage cycle parameters are assigned to the voltage and current values according to the matching result, the voltage and current values are written into the non-volatile storage block of the corresponding storage cycle, and a hierarchical electricity dataset is generated.
[0033] Based on the graded power dataset, the carrier signal strength values of the Ethernet interface and 4G communication interface are detected, the data packet loss rate of the current communication link is calculated, the data packet loss rate is compared with the communication quality blocking threshold, and weight values are assigned to each communication channel according to the comparison results and the carrier signal strength values. The available communication channels are sorted according to the weight values, the communication channel with the first sorted position is locked, the graded power dataset is loaded into the transmission buffer of the locked communication channel, a cyclic redundancy check code is added to the data packet, and the preferred channel transmission packet is generated.
[0034] According to the preferred channel transmission packet, monitor the response frame return time after the data packet is sent, read the operating temperature value of the central processing unit and the remaining capacity value of the memory card, compare the operating temperature value with the hardware overheat protection threshold, combine the response frame return time with the hardware status parameters, send the combined status data to the cloud server, receive the remote control command code returned by the cloud, trigger the firmware update write operation according to the remote control command code, and generate the device health maintenance command.
[0035] Compared with the prior art, the advantages and positive effects of the present invention are as follows:
[0036] In this invention, by sending test frames to the energy meter and calculating the transmission loop delay value, combined with the deviation between the local crystal oscillator real-time frequency count value and the standard time signal, drift slope parameters at different temperatures are fitted. This dual calibration mechanism based on physical link characteristics and ambient temperature can eliminate the uncertain jitter introduced by long-distance bus transmission and the timing error caused by hardware aging temperature drift, thereby ensuring the absolute accuracy of data acquisition. Furthermore, by scanning the number of connected multi-channel interfaces and dynamically allocating reading tasks to the port with the lowest load, coupled with a differentiated storage cycle allocation strategy for key equipment, not only is the bottleneck of single-channel serial communication eliminated, but the parallel acquisition speed is also improved. In addition to improving efficiency, it also achieves efficient utilization of storage resources and long-term retention of core data by writing non-volatile storage blocks in a hierarchical manner. It monitors carrier signal strength and data packet loss rate in real time, sorts and locks multiple channels according to communication quality blocking thresholds, and builds highly reliable redundant links for data transmission, avoiding the risk of data interruption caused by single network fluctuations. It combines hardware status parameters such as response frame return time and central processing unit temperature to establish a two-way interaction mechanism with the cloud server, and triggers firmware updates based on remote commands, realizing automated operation and maintenance and fault early warning throughout the entire life cycle of the device, reducing the maintenance cost of on-site manual troubleshooting and system downtime. Attached Figure Description
[0037] Figure 1 This is a schematic diagram of the system framework structure of the present invention. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0039] Please see Figure 1 The present invention provides a technical solution: an energy data acquisition system comprising:
[0040] The time calibration module is used to send a test frame carrying a transmission time marker to the energy meter according to the standard time reference signal, capture the arrival time marker of the energy meter's return frame, calculate the transmission loop delay value between the transmission time marker and the arrival time marker, read the real-time frequency count value of the local crystal oscillator, calculate the frequency deviation value between the real-time frequency count value and the standard time reference signal, fit the historical frequency deviation value to form a drift slope curve, extract the drift slope parameter at the current temperature, and combine the transmission loop delay value and the drift slope parameter to calculate the dynamic correction offset of the local clock and generate the clock drift compensation value.
[0041] The data acquisition and storage module is used to correct the local data acquisition time reference point according to the clock drift compensation value, scan the number of devices connected to multiple RS485 interfaces, assign the energy meter reading task to the RS485 interface with the fewest connected devices, read the voltage and current values of the energy meter, match the energy meter address code with the preset key device list, allocate storage cycle parameters for the voltage and current values according to the matching results, write the voltage and current values into the non-volatile storage block of the corresponding storage cycle, and generate a hierarchical energy dataset.
[0042] The routing transmission module is used to detect the carrier signal strength values of the Ethernet interface and 4G communication interface based on the graded power data set, calculate the data packet loss rate of the current communication link, compare the data packet loss rate with the communication quality blocking threshold, assign weight values to each communication channel according to the comparison result and the carrier signal strength value, sort the available communication channels according to the weight values, lock the communication channel with the first sort position, load the graded power data set into the transmission buffer of the locked communication channel, add cyclic redundancy check codes to the data packets, and generate the preferred channel transmission packet.
[0043] The operation and maintenance management module is used to monitor the response frame return time after data packet transmission based on the preferred channel, read the operating temperature value of the central processing unit and the remaining capacity value of the memory card, compare the operating temperature value with the hardware overheat protection threshold, combine the response frame return time with the hardware status parameters, send the combined status data to the cloud server, receive the remote control command code returned by the cloud, trigger the firmware update write operation according to the remote control command code, and generate device health maintenance instructions.
[0044] The time calibration module includes:
[0045] The delay calculation submodule sends a test frame carrying a transmission time marker to the energy meter according to the standard time reference signal, captures the arrival time marker of the energy meter's return frame, subtracts the transmission time marker from the arrival time marker, continuously acquires the difference data for multiple cycles, calculates the average value of the difference data, and generates the transmission loop delay value.
[0046] The drift fitting submodule reads the real-time frequency count value of the local crystal oscillator based on the transmission loop delay value, calculates the frequency deviation value between the real-time frequency count value and the standard time reference signal, obtains the current temperature sensor value, calls the historical frequency deviation record corresponding to the temperature sensor value in the memory, performs least squares linear regression calculation on the historical frequency deviation record, extracts the slope term of the regression equation, and generates drift slope parameters.
[0047] The dynamic compensation submodule records the elapsed time from the last successful satellite time synchronization operation to the current moment as the synchronization interval duration, reads the difference between the current temperature and the reference temperature, calculates the product of the drift slope parameter, the difference between the current temperature and the reference temperature, and the synchronization interval duration, adds the product to the transmission loop delay value to obtain the total correction time, writes the total correction time to the microsecond-level counter of the system clock, adjusts the microsecond field of the current system timestamp, and generates the clock drift compensation value.
[0048] Specifically, based on a standard time reference signal, a high-precision second pulse signal captured by a satellite receiver is used as an external reference source. A high-frequency timing interrupt service routine is built inside the microcontroller. The rising edge of the second pulse signal is used as the time synchronization trigger point to send a set of test data frames containing a specific frame header and function code to the energy meter connected to the RS485 bus. The frame header of the test data frame is defined as 0x68, and the function code is set to 0x11 to identify the loop delay test request. At the instant the start bit of the test data frame is transmitted to the physical link, the current count value of the local high-precision timer is immediately read as the transmission time marker. The receiving port remains in listening mode. When the end bit of the response frame returned by the energy meter in response to the test request is detected to have entered the receiving buffer, the count value of the local high-precision timer is read again as the arrival time marker. The arrival time marker and the transmission time marker are subtracted to obtain the round-trip time. This process is repeated for a set number of samples, for example, a set number of samples. The system collects twenty consecutive sets of loop latency data, iterates through these twenty sets, and removes outliers exceeding a preset valid range. This valid range is calculated based on the physical bus length and baud rate. For example, for a scenario with a baud rate of 9600 bps and a bus length not exceeding 1000 meters, the upper limit of the valid range is set to 500 milliseconds. If data exceeds this upper limit, it is considered a communication conflict or timeout and is discarded. The remaining valid difference data... The summation and average calculation are performed using the following expression: ,in, This represents the final calculated average transmission delay. This represents the number of valid data sets remaining after outlier removal. Representing the The effective loop time obtained from the measurement is calculated and stored in a dedicated register of volatile memory to generate the transmission loop delay value.
[0049] Based on the transmission loop delay value, the accumulated count value of the local crystal oscillator-driven counter is periodically read within a unit standard time interval. This unit standard time interval is defined by two consecutive second pulse signals from the aforementioned satellite receiving device. The read accumulated count value is compared with the theoretical standard frequency count value. For example, for a crystal oscillator with a nominal frequency of 10MHz, the theoretical standard count value should be 10,000,000. The difference between the two is calculated and divided by the theoretical standard count value to obtain the current real-time frequency deviation value. Simultaneously, it reads data from the digital temperature sensor register mounted next to the crystal oscillator via the I2C bus to obtain the current ambient temperature value accurate to one decimal place. The ambient temperature value and the calculated real-time frequency deviation value are combined into a record. The data is stored in a circular historical database, configured to store the 100 most recent records. When the database is full, it automatically overwrites the oldest data. The least squares algorithm is then called, using the temperature values from the historical database as the independent variable. Frequency deviation value as dependent variable Linear regression analysis was performed on these 100 sets of historical data to construct a regression model. Calculate the slope term of the regression line. The calculation formula is: ,in, This represents the number of historical records, with a value of 100. Representing the The temperature values in the record, This represents the average of all historical temperature values. Representing the Frequency deviation values in the records, The slope term represents the average of all historical frequency deviations. This reflects the sensitivity of the current crystal oscillator frequency deviation to temperature changes, and the calculated slope term... Extract the data to the computation buffer and generate the drift slope parameters.
[0050] Based on the drift slope parameter, a microsecond-level time interval counter is started to record the elapsed time from the last successful satellite time synchronization operation to the current time, denoted as . Read the current real-time ambient temperature change. The drift slope parameters obtained using the aforementioned steps With time interval The calculations are performed on the temperature change to estimate the cumulative time error caused by crystal oscillator temperature drift during this period. In order to restore the data's time stamp to the actual physical time of the data collection by the energy meter, the transmission time of the signal on the bus needs to be taken into account. The estimated cumulative error is then compared with the aforementioned transmission loop delay value. Perform addition and composition operations to calculate the total correction time. The calculation expression is: ,in, The drift slope parameter represents the rate of change of relative frequency deviation caused by a unit change in temperature. This represents the difference between the current temperature and the reference temperature. The synchronization interval duration. The total correction time is calculated as the transmission loop delay value. The value is converted to a microsecond count and written into the compensation register of the real-time clock (RTC). This directly modifies the microsecond field of the current system timestamp, causing the local time reference point to shift forward or backward to offset the effects of transmission delay and hardware drift, thus generating a clock drift compensation value.
[0051] The data acquisition and storage module includes:
[0052] The task allocation submodule corrects the local data acquisition time reference point based on the clock drift compensation value, traverses the status registers of all RS485 interfaces, counts the number of slave device addresses currently connected to each interface, compares the number of slave device addresses of each interface, identifies the interface number with the smallest number, maps the energy meter reading instructions to be executed to the sending queue corresponding to the interface number, and generates a balanced acquisition task list.
[0053] The data reading submodule, according to the balanced acquisition task list, drives the RS485 transceiver to send voltage reading instructions and current reading instructions to the target energy meter, receives the hexadecimal byte stream including voltage and current data returned by the energy meter, parses the byte stream to extract voltage and current values, associates and binds the voltage and current values with the corresponding energy meter hardware address, and generates the original electrical parameter set.
[0054] The hierarchical writing submodule extracts the energy meter hardware address based on the original electrical parameter set, queries the hardware address in the preset key equipment index table, obtains the storage cycle configuration parameters corresponding to the query results, locates the target sector address based on the storage cycle configuration parameters, writes the voltage and current values to the target sector address, and generates a hierarchical energy dataset.
[0055] Specifically, based on the clock drift compensation value, after completing the high-precision calibration of the local time base, all available RS485 communication ports are polled and scanned. The port numbers range from 0 to 15. The hardware status control block corresponding to each port is accessed one by one, and the "count of mounted devices" field recorded therein is read. This field is automatically filled through the broadcast handshake protocol during the device initialization phase. A temporary port load statistics table is created, which contains the port ID and the corresponding number of mounted devices. The statistics table is traversed, and numerical comparison logic is executed to find the port with the smallest number of mounted devices. For example, the number of mounted devices 5 for port 1 is compared with the number of mounted devices 5 for port 2. 3. Determine port 2 as the current preferred choice. If multiple ports have the same number of connected devices and all have the minimum value, the first one is selected by default according to the port ID in ascending order. The current unprocessed electricity meter reading instruction packet, including the target electricity meter address and function code, is encapsulated into a task object and inserted into the tail of the transmission FIFO queue of the selected port with the minimum load. At the same time, the estimated transmission time of the port is updated to ensure that the task load of all parallel ports is kept in a balanced state, and to prevent the polling cycle of a single port from exceeding the preset 1-minute limit due to task backlog. A balanced collection task list is generated.
[0056] Based on the balanced acquisition task list, a multi-threaded or interrupt-driven data transceiver engine is started. For each acquisition task in the list, the corresponding RS485 transceiver chip is controlled to enter transmit mode. Following the DL / T 645-2007 or Modbus-RTU communication protocol standard, a binary instruction stream is assembled, including the device address field, function code field (e.g., 0x03 for reading the holding register), data start address field (e.g., 0x0000 for the voltage register), and checksum field. This instruction stream is sent to the bus at a baud rate of 9600bps. Immediately afterwards, the transceiver is switched to receive mode and a timeout timer is started, with a timeout threshold set to 200 milliseconds. After receiving the response byte stream from the energy meter, the checksum or CRC cyclic redundancy check code at the end of the frame is first verified. If the verification passes, the data field is parsed according to the protocol definition, and hexadecimal byte segments representing voltage and current values are extracted, for example, 0x12. The two bytes 0x34 are combined according to the rule of high byte first and low byte last to form the decimal value 4660. Then, based on the transformer ratio configuration (e.g., 100:1), it is converted into the actual physical quantity 46.60. The parsed voltage value is then... and current value The electricity meter hardware address when the command is issued Establish mapping relationships and construct structured data objects. This generates the original electrical parameter set.
[0057] Based on the original electrical parameter set, the hardware address field of the energy meter in the data object is extracted. A critical device index table, pre-stored in non-volatile memory, is loaded. This index table, pre-configured by maintenance personnel according to the substation wiring diagram, contains the energy meter addresses of important monitoring points such as the high-voltage side of the main transformer and tie lines. A binary search algorithm is used to retrieve the currently extracted hardware address from the index table. If the search is successful, it indicates that the energy meter belongs to critical monitoring equipment, and its data storage cycle flag is set to 1 minute. If the search fails, it is determined to be ordinary monitoring equipment, and the storage cycle flag is set to 10 minutes. Based on the determined storage cycle flag, the target write physical address in the NAND Flash memory chip is calculated. For example, for critical equipment, it is mapped to the high-frequency storage area from Block 0 to Block 100; for ordinary equipment, it is mapped to Block 101 to Block 100. In the 500-fold low-frequency storage area, voltage and current values are appended to the calculated physical sector pages in chronological order. Before each write, the remaining space in the sector is checked. If it is insufficient, a block erase operation is performed to ensure the continuity of the storage cycle. Finally, the data index information of the classified storage is fed back to the file system to generate a graded energy dataset.
[0058] The routing transmission module includes:
[0059] The link evaluation submodule reads the signal-to-noise ratio register value of the Ethernet interface controller and the received signal strength indicator value of the 4G communication interface based on the graded power dataset. It counts the number of data packets in the transmission queue that have not received acknowledgment frames to calculate the packet loss rate. It compares the packet loss rate with the preset communication quality blocking threshold. Based on the comparison result and the signal strength value, it assigns weight values to each communication channel and generates a channel quality status index.
[0060] The channel selection submodule sorts the weight values of all available communication channels in descending order according to the channel quality status index, identifies the channel identifier at the top of the sort list, detects the physical link status bit corresponding to the channel identifier, switches the data output path selector to the physical interface corresponding to the channel identifier, locks the transmission parameter configuration of the physical interface, and generates the target communication link.
[0061] The encapsulated transmission submodule loads the graded power data set into the transmission buffer of the locked communication channel according to the target communication link, calculates the cyclic redundancy check code of the data payload, appends the cyclic redundancy check code to the end of the data frame, performs the transmission operation, and generates the preferred channel transmission packet.
[0062] Specifically, based on the graded power dataset, the physical layer register PHY_SSR (status register) of the Ethernet controller is accessed, and the register data at address offset 0x1F is read. Bits 5 to 10 are extracted through bitmasking to obtain the Ethernet signal-to-noise ratio value. Simultaneously, it sends an AT+CSQ command to the 4G communication module, receives the RSSI index value returned by the receiving module, and then uses this index value according to the formula. Converted to standard dBm power values, where, To receive signal power, To retrieve the returned signal strength index, read the Transmit Control Block (TCB) in the TCP / IP protocol stack and obtain the count of packets in the transmit queue that have been sent but have not yet received an ACK. And the total number of messages sent per unit time Using the formula Calculate the packet loss rate of the current link, where, Indicates packet loss rate. Number of unconfirmed frames Set a communication quality blocking threshold for the total number of transmissions. This threshold is set according to the real-time requirements of the power automation system communication protocol DL / T 634.5104 for telemetry data. That is, when the packet loss rate exceeds 5%, the link is considered unavailable, and the calculated data packet loss rate is used as the threshold. With blocking threshold Perform numerical comparisons, if If so, then directly set the weight flag of that channel to 0. Then, the channel scoring weight is calculated by combining the signal strength value. The calculation formula is: ,in, The transmission stability weighting coefficient is set to 0.6. The signal quality weighting coefficient is set to 0.4. The normalized signal strength value is obtained by linearly mapping the signal strength value to the [0,100] interval through maximum and minimum normalization. The calculated channel weight values are then filled into the channel status structure array to generate the channel quality status index.
[0063] Based on the channel quality status index, the quicksort algorithm is used to sort the weight values in the channel status structure array. Sort the array in descending order, traverse the sorted array, read the channel ID field of the first element of the array, identify the communication channel identifier with the highest weight, such as Ethernet_0 or LTE_1, access the network interface management unit of the microprocessor, read the physical layer link status register corresponding to the channel identifier, check the status of bit 0, if the bit is 1, confirm that the physical link is in the Up state and the carrier lock is normal, control the GPIO pin level of the multiplexer, switch the output path selector of the data link layer to the MAC controller interface corresponding to the channel, call the configuration interface of the network protocol stack, write the IP address, subnet mask and gateway address of the channel into the default exit entry of the current routing table, lock the transmission parameter configuration to prevent session interruption due to automatic route switching during data transmission, and generate the target communication link.
[0064] Based on the target communication link, a contiguous transmission buffer is allocated in the random access memory (RAM). The graded power data set is serialized according to the application layer protocol format and filled into this buffer. The CRC check calculation unit is initialized, using the CRC-32 standard polynomial. Performing a byte-by-byte modulo-2 division operation on the data payload in the buffer yields a 32-bit cyclic redundancy check (CRC) code. To generate polynomials, The calculated 4-byte checksum is appended to the end of the data frame. The underlying driver's send function Socket_Send() is called. The data in the send buffer is moved to the hardware send FIFO queue of the target communication link through the DMA direct memory access controller, triggering a hardware send interrupt. The modulation and transmission of the physical layer signal are completed, and the preferred channel transmission packet is generated.
[0065] The operation and maintenance management module includes:
[0066] The status monitoring submodule starts a hardware timer to record the waiting time after the data packet is sent, reads the operating temperature value of the CPU's built-in temperature sensor, queries the remaining capacity value of the memory card file system, compares the operating temperature value with the hardware overheat protection threshold, and packages the waiting time, operating temperature value and remaining capacity value into a status byte stream to generate terminal operating status data.
[0067] The cloud interaction submodule establishes a socket connection with the cloud server based on the terminal's running status data, sends a status byte stream through the current active link, receives the response message returned by the cloud server, parses the opcode field in the response message, compares the opcode field with the local instruction set definition table, extracts the corresponding control logic code, and generates a remote control action code.
[0068] The maintenance execution submodule verifies the digital signature of the remote control action code, suspends non-critical background tasks, erases the specified flash memory block in the firmware storage area, writes the updated data to the erased flash memory block, and generates device health maintenance instructions.
[0069] Specifically, based on the preferred channel transmission packet, a hardware timer TIM3 with a precision of 1 millisecond is started simultaneously with the interrupt triggering the transmission completion, entering a state of waiting to receive an acknowledgment frame (ACK). When an ACK signal is received from the cloud, the timer is stopped, and the current value of the counter is read as the duration of the acknowledgment frame return. The voltage value of the temperature sensor embedded inside the central processing unit chip is read through an ADC analog-to-digital converter. Using the temperature conversion formula Calculate the operating temperature value, where, CPU temperature For the current measured voltage, This is the standard voltage value at 25℃. Set the hardware overheat protection threshold for the temperature and voltage slope parameters. This threshold is set based on the maximum junction temperature of the industrial-grade chip datasheet minus a safety margin of 10°C. The calculated value... and If a comparison is made, If the overheat alarm flag is set, the file system API function f_getfree() is called to query the memory card cluster allocation table, calculate the product of the remaining cluster count and the number of bytes per cluster to obtain the remaining capacity of the memory card, and return the response frame with the specified duration. Operating temperature values The remaining capacity value is packaged into a status monitoring frame according to big-endian byte order to generate terminal running status data.
[0070] Based on the terminal's running status data, the TCP protocol stack's socket interface connect() is called to initiate a connection request to the pre-configured cloud server IP address and port number (e.g., 10.1.1.200:8080). After establishing a connection through a three-way handshake, a status monitoring frame is written to the sending stream, and the recv() function is used to block and wait for the server's response message. Upon receiving the response message, the synchronization word and length field in the message header are removed, and the 8th byte opcode field (OpCode) is extracted. A predefined instruction set mapping table in the local firmware is loaded. This table contains key-value pairs such as 0x10 (immediate reset), 0x20 (parameter read), and 0x30 (firmware update). A hash lookup method is used to match the extracted opcode field with the key in the mapping table. If a match is successful, the corresponding value field is read, which is the internal control logic entry address or function pointer corresponding to the opcode. The control logic code is extracted. For example, for the 0x30 opcode, the Firmware_Update_Handler function pointer is extracted, and a remote control action code is generated.
[0071] Based on the remote control action code, the digital signature data block accompanying the action code is first parsed. The SHA-256 secure hash algorithm is used to calculate the digest of the instruction content, and the signature is decrypted and verified using the built-in public key. If the decrypted digest matches the calculated digest, it is confirmed as a valid instruction. The vTaskSuspendAll() function of the real-time operating system FreeRTOS is called to suspend all low-priority non-critical background tasks, such as LED blinking and debugging serial port printing, to release CPU resources and prevent Flash read / write conflicts. According to the memory mapping address pointed to by the action code, the firmware backup area of the Flash memory is located, and a Flash sector erase instruction (0x20) is sent to erase the specified flash block with the starting address 0x08040000. After waiting for the Busy bit of the status register to be cleared, the received firmware update data is written to the erased flash block in units of pages (256 bytes). After each page is written, the data is immediately read back and the integrity is verified to generate a device health maintenance instruction.
Claims
1. An electrical energy data acquisition system, characterized in that, The system includes: The time calibration module is used to send a test frame carrying a transmission time marker to the energy meter according to the standard time reference signal, capture the arrival time marker of the energy meter's return frame, calculate the transmission loop delay value between the transmission time marker and the arrival time marker, read the real-time frequency count value of the local crystal oscillator, calculate the frequency deviation value between the real-time frequency count value and the standard time reference signal, fit the historical frequency deviation value to form a drift slope curve, extract the drift slope parameter at the current temperature, and combine the transmission loop delay value and the drift slope parameter to calculate the dynamic correction offset of the local clock and generate the clock drift compensation value. The data acquisition and storage module is used to correct the local data acquisition time reference point according to the clock drift compensation value, scan the number of devices connected to multiple RS485 interfaces, assign the electricity meter reading task to the RS485 interface with the lowest number of connected devices, read the voltage and current values of the electricity meter, match the electricity meter address code with a preset list of key devices, allocate storage cycle parameters for the voltage and current values according to the matching results, write the voltage and current values into the non-volatile storage block of the corresponding storage cycle, and generate a hierarchical electricity dataset.
2. The power data acquisition system according to claim 1, characterized in that, The system also includes: The routing transmission module is used to detect the carrier signal strength values of the Ethernet interface and 4G communication interface according to the graded power data set, calculate the data packet loss rate of the current communication link, compare the data packet loss rate with the communication quality blocking threshold, assign weight values to each communication channel according to the comparison result and the carrier signal strength value, sort the available communication channels according to the weight values, lock the communication channel with the first sort position, load the graded power data set into the transmission buffer of the locked communication channel, add cyclic redundancy check codes to the data packets, and generate the preferred channel transmission packet. The operation and maintenance management module is used to monitor the response frame return time after the data packet is sent according to the preferred channel transmission packet, read the operating temperature value of the central processing unit and the remaining capacity value of the memory card, compare the operating temperature value with the hardware overheat protection threshold, combine the response frame return time with the hardware status parameters, send the combined status data to the cloud server, receive the remote control command code returned by the cloud, trigger the firmware update write operation according to the remote control command code, and generate the device health maintenance command.
3. The power data acquisition system according to claim 1, characterized in that, The time calibration module includes: The delay calculation submodule sends a test frame carrying a transmission time marker to the energy meter according to the standard time reference signal, captures the arrival time marker of the energy meter's return frame, subtracts the transmission time marker from the arrival time marker, continuously acquires the difference data for multiple cycles, calculates the average value of the difference data, and generates the transmission loop delay value. The drift fitting submodule reads the real-time frequency count value of the local crystal oscillator based on the transmission loop delay value, calculates the frequency deviation value between the real-time frequency count value and the standard time reference signal, obtains the current temperature sensor value, calls the historical frequency deviation record corresponding to the temperature sensor value in the memory, performs least squares linear regression calculation on the historical frequency deviation record, extracts the slope term of the regression equation, and generates drift slope parameters. The dynamic compensation submodule records the elapsed time from the last successful satellite time synchronization operation to the current moment as the synchronization interval duration, reads the difference between the current temperature and the reference temperature, calculates the product of the drift slope parameter, the difference between the current temperature and the reference temperature, and the synchronization interval duration, adds the product to the transmission loop delay value to obtain the total correction time, writes the total correction time to the microsecond-level counter of the system clock, adjusts the microsecond field of the current system timestamp, and generates the clock drift compensation value.
4. The power data acquisition system according to claim 1, characterized in that, The data acquisition and storage module includes: The task allocation submodule corrects the local data acquisition time reference point according to the clock drift compensation value, traverses the status registers of all RS485 interfaces, counts the number of slave device addresses currently connected to each interface, compares the number of slave device addresses of each interface, identifies the interface number with the smallest number, maps the energy meter reading instructions to be executed to the sending queue corresponding to the interface number, and generates a balanced acquisition task list. The data reading submodule, according to the balanced acquisition task list, drives the RS485 transceiver to send voltage reading instructions and current reading instructions to the target energy meter, receives the hexadecimal byte stream including voltage data and current data returned by the energy meter, parses the byte stream to extract voltage and current values, associates and binds the voltage and current values with the corresponding energy meter hardware address, and generates the original electrical parameter set. The hierarchical writing submodule extracts the electricity meter hardware address based on the original electrical parameter set, queries the hardware address in the preset key equipment index table, obtains the storage cycle configuration parameters corresponding to the query results, locates the target sector address based on the storage cycle configuration parameters, writes the voltage and current values to the target sector address, and generates a hierarchical electricity dataset.
5. The power data acquisition system according to claim 2, characterized in that, The routing transmission module includes: The link evaluation submodule reads the signal-to-noise ratio register value of the Ethernet interface controller and the received signal strength indicator value of the 4G communication interface according to the graded power dataset, counts the number of data packets in the transmission queue that have not received acknowledgment frames to calculate the packet loss rate, compares the packet loss rate with the preset communication quality blocking threshold, and assigns weight values to each communication channel according to the comparison results and signal strength values to generate channel quality status indicators. The channel selection submodule sorts the weight values of all available communication channels in descending order according to the channel quality status index, identifies the channel identifier at the top of the sort list, detects the physical link status bit corresponding to the channel identifier, switches the data output path selector to the physical interface corresponding to the channel identifier, locks the transmission parameter configuration of the physical interface, and generates the target communication link.
6. The power data acquisition system according to claim 5, characterized in that, The routing transmission module also includes: The encapsulated transmission submodule loads the graded power data set into the transmission buffer of the locked communication channel according to the target communication link, calculates the cyclic redundancy check code of the data payload, appends the cyclic redundancy check code to the end of the data frame, performs the transmission operation, and generates the preferred channel transmission packet.
7. The power data acquisition system according to claim 2, characterized in that, The operation and maintenance management module includes: The status monitoring submodule starts a hardware timer to record the waiting time after the data packet is sent, reads the operating temperature value of the CPU's built-in temperature sensor, queries the remaining capacity value of the memory card file system, compares the operating temperature value with the hardware overheat protection threshold, and packages the waiting time, operating temperature value and remaining capacity value into a status byte stream to generate terminal operating status data. The cloud interaction submodule establishes a socket connection with the cloud server based on the terminal's operating status data, sends a status byte stream through the current active link, receives a response message returned by the cloud server, parses the opcode field in the response message, compares the opcode field with the local instruction set definition table, extracts the corresponding control logic code, and generates a remote control action code.
8. The power data acquisition system according to claim 7, characterized in that, The operation and maintenance management module also includes: The maintenance execution submodule verifies the digital signature of the remote control action code, suspends non-critical background tasks, erases the specified flash memory block in the firmware storage area, writes the updated data to the erased flash memory block, and generates a device health maintenance instruction.
9. An electrical energy data acquisition device, which stores computer program instructions, characterized in that, The computer program instructions, when executed by a processor, implement the system as described in any one of claims 1-8.
10. A method for acquiring electrical energy data, using the electrical energy data acquisition system according to any one of claims 1-8, characterized in that, Includes the following steps: Based on the standard time reference signal, a test frame carrying a transmission time marker is sent to the energy meter. The arrival time marker of the energy meter's return frame is captured. The transmission loop delay value between the transmission time marker and the arrival time marker is calculated. The real-time frequency count value of the local crystal oscillator is read. The frequency deviation value between the real-time frequency count value and the standard time reference signal is calculated. The historical frequency deviation value is fitted to form a drift slope curve. The drift slope parameter at the current temperature is extracted. Combining the transmission loop delay value and the drift slope parameter, the dynamic correction offset of the local clock is calculated, and the clock drift compensation value is generated. Based on the clock drift compensation value, the local data acquisition time reference point is corrected, the number of devices connected to the multi-channel RS485 interface is scanned, the electricity meter reading task is assigned to the RS485 interface with the lowest number of connected devices, the voltage and current values of the electricity meter are read, the electricity meter address code is matched with the preset key device list, the storage cycle parameters are assigned to the voltage and current values according to the matching result, the voltage and current values are written into the non-volatile storage block of the corresponding storage cycle, and a hierarchical electricity dataset is generated. Based on the graded power dataset, the carrier signal strength values of the Ethernet interface and 4G communication interface are detected, the data packet loss rate of the current communication link is calculated, the data packet loss rate is compared with the communication quality blocking threshold, and weight values are assigned to each communication channel according to the comparison results and the carrier signal strength values. The available communication channels are sorted according to the weight values, the communication channel with the first sorted position is locked, the graded power dataset is loaded into the transmission buffer of the locked communication channel, a cyclic redundancy check code is added to the data packet, and the preferred channel transmission packet is generated. According to the preferred channel transmission packet, monitor the response frame return time after the data packet is sent, read the operating temperature value of the central processing unit and the remaining capacity value of the memory card, compare the operating temperature value with the hardware overheat protection threshold, combine the response frame return time with the hardware status parameters, send the combined status data to the cloud server, receive the remote control command code returned by the cloud, trigger the firmware update write operation according to the remote control command code, and generate the device health maintenance command.
Citation Information
Patent Citations
Electric energy acquisition system based on remote electric energy data acquisition terminal
CN104422821A
Remote communication electric energy meter based on carrier wave communication as well as working process of same
CN107886702A