Embedded AI power grid waveform dynamic bit width adaptive preprocessing method and system and medium

By using Q format fixed-pointing and LUT table lookup method to preprocess the power grid waveform data in the embedded AI model, the time-consuming and memory usage problems caused by floating-point operations are solved, and efficient and adaptive preprocessing effects are achieved.

CN120045163AActive Publication Date: 2025-05-27HANGZHOU SUNRISE TECH +2

Patent Information

Application Number
CN202510525230.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2025-05-27
Estimated Expiration
2045-04-25

AI Technical Summary

Technical Problem

When deploying grid waveform detection AI models on embedded devices, floating-point operations result in more than 20 times of preprocessing, affecting real-time, and requiring additional memory for data conversion.

Method used

Data preprocessing is performed through Q format fixed-pointing and LUT table lookup method to improve efficiency and reduce memory usage, and realize adaptive preprocessing of signals collected from different bit widths.

Benefits of technology

It significantly improves the efficiency of data preprocessing, reduces memory usage, and realizes adaptive processing of signals of different bit widths, improving the real-time and resource utilization efficiency of embedded AI models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045163A_ABST
    Figure CN120045163A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an embedded AI power grid waveform dynamic bit width adaptive preprocessing method and system and a medium, and the method comprises the steps: obtaining the real-time sampling data of voltage and current, and analyzing the sampling precision of the real-time sampling data; setting a sampling precision threshold, and judging whether the sampling precision is greater than the sampling precision threshold; if the sampling precision is greater than the sampling precision threshold value, performing Q-format fixed-point number conversion on the real-time sampling data, and performing normalization processing on the real-time sampling data after the Q-format fixed-point number conversion; if the real-time sampling data is smaller than or equal to the real-time sampling data, converting the real-time sampling data into normalization by adopting an LUT table look-up method; normalized sampling data is input into a quantitative model, data bit width is output, a bit width adjustment strategy is generated based on a set bit width threshold value, the data bit width is dynamically adjusted, the data preprocessing efficiency is improved through Q format fixed-point and LUT lookup methods, memory occupation is reduced, and self-adaptive preprocessing can be conducted according to collected signals of different bit widths.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of bit-width adaptation, and more specifically, to a method, system, and medium for dynamically adapting the bit-width of power grid waveforms in embedded AI for preprocessing. Background Art

[0002] Most existing preprocessing of embedded AI model inputs uses floating-point operations. When deploying an AI model for power grid waveform detection on an embedded device, since most MCUs do not have an FPU, software simulation of floating-point is required, resulting in a preprocessing time increase of more than 20 times, seriously affecting the real-time performance of inference. Moreover, floating-point operations require converting ADC integer data to the float type for caching, occupying additional memory. Summary of the Invention

[0003] The purpose of the embodiments of this application is to provide a method, system, and medium for dynamically adapting the bit-width of power grid waveforms in embedded AI, which can improve the data preprocessing efficiency through Q-format fixed-point conversion and LUT look-up table method, reduce memory occupancy, and perform adaptive preprocessing according to acquisition signals of different bit-widths.

[0004] The embodiments of this application also provide a method for dynamically adapting the bit-width of power grid waveforms in embedded AI, including: Obtain real-time sampling data of voltage and current, and analyze the sampling accuracy of the real-time sampling data; Set a sampling accuracy threshold, and determine whether the sampling accuracy is greater than the sampling accuracy threshold; If it is greater than the sampling accuracy threshold, perform Q-format fixed-point conversion on the real-time sampling data, and normalize the real-time sampling data after Q-format fixed-point conversion; If it is less than or equal to the sampling accuracy threshold, use the LUT look-up table method to convert the real-time sampling data into a normalized value and save it to table T; Input the normalized sampling data into a quantization model, output the data bit-width, generate a bit-width adjustment strategy based on a set bit-width threshold, and dynamically adjust the data bit-width based on the bit-width adjustment strategy, and output the adjustment result.

[0005] Optionally, in the method for dynamically adapting the bit-width of power grid waveforms in embedded AI described in the embodiments of this application, obtaining real-time sampling data of voltage and current and analyzing the sampling accuracy of the real-time sampling data specifically includes: Obtain real-time sampling data of voltage and current, sequentially store the real-time sampling data in a buffer area to obtain a stored value; Use the cyclic redundancy check algorithm to generate a check code for each group of real-time sampling data and store it, compare the check code with the stored value, and determine whether they are consistent; If they are inconsistent, re-sample the real-time sampled data of voltage and current. If they are consistent, set the reference voltage and reference current, and set the sampling accuracy value based on the reference voltage and reference current; Compare the sampling accuracy value with the real-time sampled data to obtain a sampling deviation value, and determine whether the sampling deviation value is within the set accuracy interval; If it is within the set accuracy interval, generate the sampling accuracy of the real-time sampled data. If it is not within the set sampling accuracy interval, generate a correction factor, and perform drift correction on the sampled data based on the correction factor.

[0006] Optionally, in the grid waveform dynamic bit-width adaptive preprocessing method of the embedded AI described in the embodiments of the present application, convert the real-time sampled data into Q-format fixed-point numbers, and perform normalization processing on the real-time sampled data after the Q-format fixed-point number conversion, specifically including: Determine the dynamic range of the real-time sampled data to obtain the maximum and minimum values of the dynamic range; Set a scale factor based on the maximum and minimum values of the dynamic range, multiply the real-time sampled data by the scale factor, and round to the nearest integer to obtain an integer in Q-format; Perform Q-format fixed-point number conversion on the real-time sampled data based on the integer in Q-format to obtain the converted data; Map the converted data to obtain a mapping result, and analyze whether the mapping result is within the set mapping interval; If it is, determine that the converted data meets the requirements. If it is within the set mapping interval, perform normalization processing on the real-time sampled data.

[0007] Optionally, in the grid waveform dynamic bit-width adaptive preprocessing method of the embedded AI described in the embodiments of the present application, use the LUT look-up table method to convert the real-time sampled data into a normalized value and save it in table T, specifically including: Determine the dynamic range of the real-time sampled data to obtain the maximum and minimum values of the dynamic range Calculate the index position in the look-up table for each real-time sampled data based on the dynamic range of the sampled data; Obtain the corresponding normalized value from the look-up table based on the index position to complete the normalization processing; Save the normalized value to table T.

[0008] Optionally, in the grid waveform dynamic bit-width adaptive preprocessing method of the embedded AI described in the embodiments of the present application, input the sampled data after normalization processing into a quantization model to output the data bit-width, specifically including: Use a clustering algorithm to cluster the normalized values into several clusters, and the center of each cluster is used as a quantization level; Map each data point to the nearest cluster center to obtain mapped data; Input the mapped data into a quantization model and calculate the required data bit width according to the number of clusters.

[0009] Optionally, in the method for dynamically adapting the bit width of power grid waveforms in an embedded AI according to an embodiment of the present application, a bit width adjustment strategy is generated based on a set bit width threshold, and the data bit width is dynamically adjusted based on the bit width adjustment strategy, specifically including: Set different bit width thresholds based on performance requirements, resource limitations, and data characteristics; Obtain real-time sampling data and extract data features; Compare the data features with the set bit width thresholds to generate corresponding bit width adjustment strategies; Dynamically adjust the data bit width according to the corresponding bit width adjustment strategy.

[0010] In a second aspect, an embodiment of the present application provides a system for dynamically adapting the bit width of power grid waveforms in an embedded AI, the system including: a memory and a processor, where the memory includes a program for the method for dynamically adapting the bit width of power grid waveforms in an embedded AI, and when the program for the method for dynamically adapting the bit width of power grid waveforms in an embedded AI is executed by the processor, the following steps are implemented: Obtain real-time sampling data of voltage and current, and analyze the sampling accuracy of the real-time sampling data; Set a sampling accuracy threshold, and determine whether the sampling accuracy is greater than the sampling accuracy threshold; If it is greater than the sampling accuracy threshold, convert the real-time sampling data into Q-format fixed-point numbers, and perform normalization processing on the real-time sampling data after the Q-format fixed-point number conversion; If it is less than or equal to the sampling accuracy threshold, use the LUT look-up table method to convert the real-time sampling data into a normalized value and save it to table T; Input the normalized sampling data into a quantization model, output the data bit width, generate a bit width adjustment strategy based on the set bit width threshold, dynamically adjust the data bit width based on the bit width adjustment strategy, and output the adjustment result.

[0011] Optionally, in the system for dynamically adapting the bit width of power grid waveforms in an embedded AI according to an embodiment of the present application, obtaining real-time sampling data of voltage and current and analyzing the sampling accuracy of the real-time sampling data specifically includes: Obtain real-time sampling data of voltage and current, sequentially store the real-time sampling data in a buffer area to obtain a stored value; Use a cyclic redundancy check algorithm to generate a check code for each group of real-time sampling data and store it, compare the check code with the stored value, and determine whether they are consistent; If they are inconsistent, re-sample the real-time sampling data of voltage and current. If they are consistent, set the reference voltage and reference current, and set the sampling accuracy value based on the reference voltage and reference current; Compare the sampling accuracy value with the real-time sampling data to obtain a sampling deviation value, and determine whether the sampling deviation value is within the set accuracy interval; If it is within the set accuracy interval, generate the sampling accuracy of the real-time sampling data. If it is not within the set sampling accuracy interval, generate a correction factor and perform drift correction on the sampling data based on the correction factor.

[0012] Optionally, in the embedded AI-based power grid waveform dynamic bit-width adaptive preprocessing system described in the embodiments of the present application, convert the real-time sampling data into Q-format fixed-point numbers, and perform normalization processing on the real-time sampling data after Q-format fixed-point number conversion, specifically including: Determine the dynamic range of the real-time sampling data to obtain the maximum and minimum values of the dynamic range; Set a scale factor based on the maximum and minimum values of the dynamic range, multiply the real-time sampling data by the scale factor, and round to the nearest integer to obtain a Q-format integer; Perform Q-format fixed-point number conversion on the real-time sampling data based on the Q-format integer to obtain the converted data; Map the converted data to obtain a mapping result, and analyze whether the mapping result is within the set mapping interval; If it is, determine that the converted data meets the requirements. If it is within the set mapping interval, perform normalization processing on the real-time sampling data.

[0013] In a third aspect, the embodiments of the present application further provide a computer-readable storage medium, which includes a program for the embedded AI-based power grid waveform dynamic bit-width adaptive preprocessing method. When the program for the embedded AI-based power grid waveform dynamic bit-width adaptive preprocessing method is executed by a processor, the steps of the embedded AI-based power grid waveform dynamic bit-width adaptive preprocessing method described in any one of the above are implemented.

[0014] As described above, an embedded AI-based power grid waveform dynamic bit-width adaptive preprocessing method, system, and medium provided by the embodiments of the present application obtain real-time sampling data of voltage and current, analyze the sampling accuracy of the real-time sampling data; set a sampling accuracy threshold, and determine whether the sampling accuracy is greater than the sampling accuracy threshold; if it is greater than the sampling accuracy threshold, convert the real-time sampling data into Q-format fixed-point numbers, and perform normalization processing on the real-time sampling data after Q-format fixed-point number conversion; if it is less than or equal to the sampling accuracy threshold, use the LUT look-up table method to convert the real-time sampling data into a normalized value and save it to table T; input the normalized sampling data into a quantization model, output the data bit-width, generate a bit-width adjustment strategy based on the set bit-width threshold, dynamically adjust the data bit-width based on the bit-width adjustment strategy, and output the adjustment result; improve the data preprocessing efficiency through Q-format fixed-point quantization and the LUT look-up table method, reduce memory occupancy, and can perform adaptive preprocessing according to acquisition signals of different bit-widths. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] To more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can also be obtained based on these drawings without creative efforts.

[0016] Figure 1 It is a flowchart of the embedded AI-based power grid waveform dynamic bit-width adaptive preprocessing method provided by the embodiments of the present application; Figure 2 It is a flowchart of the sampling accuracy analysis method of the embedded AI-based power grid waveform dynamic bit-width adaptive preprocessing method provided by the embodiments of the present application; Figure 3 It is a flowchart of the Q-format fixed-point number conversion method of the embedded AI-based power grid waveform dynamic bit-width adaptive preprocessing method provided by the embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0017] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all of them. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of the present application provided in the drawings below is not intended to limit the scope of the present application to be protected, but only represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.

[0018] It should be noted that similar reference numerals and letters denote similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. At the same time, in the description of the present application, terms such as "first" and "second" are only used for distinguishing descriptions and cannot be construed as indicating or implying relative importance.

[0019] Please refer to Figure 1 , Figure 1 which is a flowchart of a method for dynamically adapting the bit width of the grid waveform in an embedded AI in some embodiments of the present application. The method for dynamically adapting the bit width of the grid waveform in the embedded AI is used in a terminal device. The method for dynamically adapting the bit width of the grid waveform in the embedded AI includes the following steps: S101, obtaining real-time sampling data of voltage and current, and analyzing the sampling accuracy of the real-time sampling data; S102, setting a sampling accuracy threshold, and determining whether the sampling accuracy is greater than the sampling accuracy threshold; S103, if it is greater than the sampling accuracy threshold, converting the real-time sampling data into Q-format fixed-point numbers, and normalizing the real-time sampling data after the Q-format fixed-point number conversion; S104, if it is less than or equal to the sampling accuracy threshold, using the LUT look-up table method to convert the real-time sampling data into a normalized value and save it in table T; S105, inputting the normalized sampling data into a quantization model, outputting a data bit width, generating a bit width adjustment strategy based on a set bit width threshold, dynamically adjusting the data bit width based on the bit width adjustment strategy, and outputting an adjustment result.

[0020] It should be noted that the sampling accuracy: N bit is obtained according to the manual of the metering chip. The voltage waveform and current waveform are obtained through the metering chip, and the real-time sampling data adc of voltage and current is dynamically obtained according to the voltage waveform and current waveform.

[0021] When N > 12 bit, perform Q-format fixed-point number conversion on the adc data, and the conversion formula is as follows: Q M = ((2 × adc − (2N − 1)) × scale) ≫ (N - M + 1) In the formula, M is the number of decimal places, scale is the scaling factor, scale = 2M / (2N - 1), and both N and M are fixed values in a specific project. Therefore, the entire operation only involves multiplication, addition, and shift operations on adc, and the calculation efficiency is relatively high.

[0022] When N <= 12 bits, the LUT look-up table method is adopted. All bit data are converted into normalized values in advance and stored in table T, and the conversion is performed in real time according to the following formula: Q = T[adc]; The preprocessed Q data is directly input into the quantization model for deduction.

[0023] Please refer to Figure 2 , Figure 2 is a flowchart of a sampling accuracy analysis method for a dynamic bit-width adaptive preprocessing method of power grid waveforms of an embedded AI in some embodiments of this application. According to the embodiments of the present invention, real-time sampling data of voltage and current are obtained, and the sampling accuracy of the real-time sampling data is analyzed, specifically including: S201, obtain real-time sampling data of voltage and current, store the real-time sampling data in the buffer area in sequence to obtain a stored value; S202, use the cyclic redundancy check algorithm to generate a check code for each group of real-time sampling data and store it, compare the check code with the stored value to determine whether they are consistent; S203, if they are inconsistent, resample the real-time sampling data of voltage and current, if they are consistent, set a reference voltage and a reference current, and set a sampling accuracy value based on the reference voltage and the reference current; S204, compare the sampling accuracy value with the real-time sampling data to obtain a sampling deviation value, and determine whether the sampling deviation value is within a set accuracy interval; S205, if it is within the set accuracy interval, generate the sampling accuracy of the real-time sampling data, if it is not within the set sampling accuracy interval, generate a correction coefficient, and perform drift correction on the sampling data based on the correction coefficient.

[0024] It should be noted that high-precision reference voltage and reference current are introduced. At the same time point, the ADC samples the reference signal and the actual power grid voltage and current signals. Compare the known accurate value of the reference signal with the sampled value, and calculate the deviation between the two. If the deviation is within the theoretical error range of the ADC, the sampling accuracy meets the standard; if the deviation is too large, it is necessary to check the hardware circuit, such as whether there is parameter drift in the anti-aliasing filter, resulting in additional attenuation or phase shift of the signal, affecting the sampling accuracy. The stability of the sampling can also be evaluated by sampling the reference signal multiple times and statistically calculating the standard deviation of the sampled values. The smaller the standard deviation, the more stable the sampling accuracy.

[0025] Please refer to Figure 3 , Figure 3It is a flowchart of the Q - format fixed - point number conversion method for the dynamic bit - width adaptive pre - processing method of power grid waveforms of embedded AI in some embodiments of this application. According to the embodiments of the present invention, the real - time sampling data is converted into Q - format fixed - point numbers, and the real - time sampling data after Q - format fixed - point number conversion is normalized. Specifically, it includes: S301, determine the dynamic range of the real - time sampling data to obtain the maximum and minimum values of the dynamic range; S302, set a scaling factor based on the maximum and minimum values of the dynamic range, multiply the real - time sampling data by the scaling factor, and round to the nearest integer to obtain the Q - format integer; S303, perform Q - format fixed - point number conversion on the real - time sampling data based on the Q - format integer to obtain the converted data; S304, map the converted data to obtain a mapping result, and analyze whether the mapping result is within the set mapping interval; S305, if it is within, determine that the converted data meets the requirements. If it is within the set mapping interval, normalize the real - time sampling data.

[0026] It should be noted that the Q - format is a method for representing fixed - point numbers. It can effectively process numerical operations in the case of limited hardware resources (such as embedded systems). Normalizing the data after Q - format fixed - point number conversion is to map the data to a specific range, usually [0, 1] or [-1, 1], for subsequent processing and analysis.

[0027] According to the embodiments of the present invention, using the LUT look - up table method, the real - time sampling data is converted into a normalized value and saved in the table T. Specifically, it includes: Determine the dynamic range of the real - time sampling data to obtain the maximum and minimum values of the dynamic range Based on the dynamic range of the sampling data, calculate the index position in the look - up table for each real - time sampling data; Based on the index position, obtain the corresponding normalized value from the look - up table to complete the normalization process; Save the normalized value to the table T.

[0028] It should be noted that clarifying the maximum and minimum values of the real - time sampling data will determine the normalization interval and the construction range of the look - up table.

[0029] Construct a look - up table: According to the set precision (i.e., data interval), generate a series of values within the data range, and calculate the corresponding normalized values (usually normalized to the [0, 1] interval) of these values, and store these normalized values in the look - up table.

[0030] Lookup and normalization: For each real-time sampled data, the normalization process is completed by calculating its index position in the lookup table (based on the data range and precision), and then obtaining the corresponding normalized value from the lookup table.

[0031] According to an embodiment of the present invention, the sampled data after normalization is input into a quantization model to output the data bit width, which specifically includes: Using a clustering algorithm to cluster the normalized values into several clusters, and the center of each cluster is used as a quantization level; Mapping each data point to the nearest cluster center to obtain the mapped data; Inputting the mapped data into the quantization model and calculating the required data bit width according to the number of clusters.

[0032] According to an embodiment of the present invention, a bit width adjustment strategy is generated based on a set bit width threshold, and the data bit width is dynamically adjusted based on the bit width adjustment strategy, which specifically includes: Based on performance requirements, resource limitations, and data characteristics, different bit width thresholds are set; Obtaining real-time sampled data and extracting data characteristics; Comparing the data characteristics with the set bit width threshold to generate a corresponding bit width adjustment strategy; Dynamically adjusting the data bit width according to the corresponding bit width adjustment strategy.

[0033] It should be noted that when the waveform complexity of the data is low, the real-time requirement is high, and the storage and computing resources are limited, the data bit width is set to a low bit width threshold (8 bits). The data characteristics include sampling time characteristics, data performance characteristics, and waveform characteristics; the bit width adjustment strategy is specifically that if the data characteristics show that the complexity of the current data is low and the system resources are limited, the data bit width can be appropriately reduced to save resources; on the contrary, if the data characteristics indicate that the amount of information in the data is large, the accuracy requirement is high, and the system performance allows, the data bit width can be increased to ensure the quality of data processing.

[0034] When the waveform complexity of the data is high, the accuracy requirement is high, and the data dynamic range is wide, the data bit width is set to a high bit width threshold (16 bits).

[0035] In the case between the two, the bit width can be appropriately adjusted according to the specific situation. For example, when the waveform complexity increases slightly but the real-time requirement is still high, the bit width can be adjusted to 10 bits or 12 bits.

[0036] Through the above bit width threshold setting and adjustment strategy, on the premise of meeting performance requirements, limited resources can be fully utilized to ensure the stable operation of the monitoring system.

[0037] In a second aspect, an embodiment of the present application provides a grid waveform dynamic bit-width adaptive preprocessing system for embedded AI, which includes: a memory and a processor. The memory includes a program for the grid waveform dynamic bit-width adaptive preprocessing method of embedded AI. When the program for the grid waveform dynamic bit-width adaptive preprocessing method of embedded AI is executed by the processor, the following steps are implemented: Obtain real-time sampling data of voltage and current, and analyze the sampling accuracy of the real-time sampling data; Set a sampling accuracy threshold, and determine whether the sampling accuracy is greater than the sampling accuracy threshold; If it is greater than the sampling accuracy threshold, perform Q-format fixed-point number conversion on the real-time sampling data, and perform normalization processing on the real-time sampling data after Q-format fixed-point number conversion; If it is less than or equal to the sampling accuracy threshold, use the LUT look-up table method to convert the real-time sampling data into a normalized value and save it in table T; Input the normalized sampling data into the quantization model, output the data bit-width, generate a bit-width adjustment strategy based on the set bit-width threshold, dynamically adjust the data bit-width based on the bit-width adjustment strategy, and output the adjustment result.

[0038] It should be noted that the sampling accuracy: N bit is obtained according to the manual of the metering chip, and the real-time sampling data adc of voltage and current is obtained through the metering chip.

[0039] When N>12bit, perform Q-format fixed-point number conversion on the adc data, and the conversion formula is as follows: Q M = ((2×adc−(2N−1))×scale) ≫ (N - M + 1) In the formula, Q M represents the result of Q-format fixed-point number conversion, M is the number of decimal places, scale is the scaling factor, scale =2M / (2N-1), where N and M are fixed values in a specific project. Therefore, the entire operation only involves multiplication, addition, and shift operations on adc, and the calculation efficiency is relatively high.

[0040] When N<= 12bit, use the LUT look-up table method, convert all bit data into normalized values in advance and save them in table T, and perform real-time conversion according to the following formula: Q = T[adc]; Directly input the preprocessed Q data into the quantization model for deduction.

[0041] According to the embodiment of the present invention, obtaining the real-time sampling data of voltage and current and analyzing the sampling accuracy of the real-time sampling data specifically includes: Obtain the real-time sampling data of voltage and current, store the real-time sampling data in the buffer in sequence to obtain the stored value; Use the cyclic redundancy check algorithm to generate and store the check code for each group of real-time sampling data, compare the check code with the stored value to determine whether they are consistent; If they are inconsistent, resample the real-time sampling data of voltage and current. If they are consistent, set the reference voltage and reference current, and set the sampling accuracy value based on the reference voltage and reference current; Compare the sampling accuracy value with the real-time sampling data to obtain the sampling deviation value, and determine whether the sampling deviation value is within the set accuracy interval; If it is within the set accuracy interval, generate the sampling accuracy of the real-time sampling data. If it is not within the set sampling accuracy interval, generate a correction factor and perform drift correction on the sampling data based on the correction factor.

[0042] It should be noted that high-precision reference voltage and reference current are introduced. At the same time point, the ADC samples the reference signal and the actual grid voltage and current signals. Compare the known accurate value of the reference signal with the sampled value, and calculate the deviation between the two. If the deviation is within the theoretical error range of the ADC, the sampling accuracy meets the standard; if the deviation is too large, it is necessary to check the hardware circuit, such as whether there is parameter drift in the anti-aliasing filter, resulting in additional attenuation or phase shift of the signal, affecting the sampling accuracy. It is also possible to sample the reference signal multiple times, calculate the standard deviation of the sampled values, and evaluate the stability of the sampling. The smaller the standard deviation, the more stable the sampling accuracy.

[0043] According to the embodiments of the present invention, perform Q-format fixed-point number conversion on the real-time sampling data, and perform normalization processing on the real-time sampling data after Q-format fixed-point number conversion, specifically including: Determine the dynamic range of the real-time sampling data to obtain the maximum and minimum values of the dynamic range; Set the scale factor based on the maximum and minimum values of the dynamic range, multiply the real-time sampling data by the scale factor, and round to the nearest integer to obtain the Q-format integer; Perform Q-format fixed-point number conversion on the real-time sampling data based on the Q-format integer to obtain the converted data; Map the converted data to obtain the mapping result, and analyze whether the mapping result is within the set mapping interval; If it is within, it is determined that the converted data meets the requirements. If it is within the set mapping interval, perform normalization processing on the real-time sampling data.

[0044] It should be noted that the Q format is a method for representing fixed-point numbers, which can effectively handle numerical operations in the case of limited hardware resources (such as embedded systems). Normalizing the data after converting Q format fixed-point numbers is to map the data to a specific range, usually [0, 1] or [-1, 1], for subsequent processing and analysis.

[0045] According to the embodiments of the present invention, using the LUT look-up table method, the real-time sampling data is converted into normalized values and saved in the table T, which specifically includes: Determine the dynamic range of the real-time sampling data to obtain the maximum and minimum values of the dynamic range Based on the dynamic range of the sampling data, calculate the index position in the look-up table for each real-time sampling data; Based on the index position, obtain the corresponding normalized value from the look-up table to complete the normalization process; Save the normalized value to the table T.

[0046] It should be noted that clarifying the maximum and minimum values of the real-time sampling data will determine the normalization interval and the construction range of the look-up table.

[0047] Construct a look-up table: According to the set precision (i.e., data interval), generate a series of values within the data range, and calculate the corresponding normalized values (usually normalized to the [0, 1] interval) for these values, and store these normalized values in the look-up table.

[0048] Lookup and normalization: For each real-time sampling data, by calculating its index position in the look-up table (based on the data range and precision), and then obtaining the corresponding normalized value from the look-up table, the normalization process is completed.

[0049] According to the embodiments of the present invention, input the normalized sampling data into the quantization model to output the data bit width, which specifically includes: Use the clustering algorithm to cluster the normalized values into several clusters, and the center of each cluster is used as a quantization level; Map each data point to the nearest cluster center to obtain the mapped data; Input the mapped data into the quantization model, and calculate the required data bit width according to the number of clusters.

[0050] According to the embodiments of the present invention, generate a bit width adjustment strategy based on the set bit width threshold, and dynamically adjust the data bit width based on the bit width adjustment strategy, which specifically includes: Based on performance requirements, resource limitations, and data characteristics, set different bit width thresholds; Obtain the real-time sampling data and extract data features; Compare the data features with the set bit-width threshold to generate corresponding bit-width adjustment strategies; Dynamically adjust the data bit-width according to the corresponding bit-width adjustment strategy.

[0051] It should be noted that when the waveform complexity of the data is low, the real-time requirement is high, and the storage and computing resources are limited, the data bit-width is set to the low bit-width threshold (8 bits).

[0052] When the waveform complexity of the data is high, the precision requirement is high, and the data dynamic range is wide, the data bit-width is set to the high bit-width threshold (16 bits).

[0053] In the case between the two, the bit-width can be appropriately adjusted according to the specific situation. For example, when the waveform complexity increases slightly but the real-time requirement is still high, the bit-width can be adjusted to 10 bits or 12 bits.

[0054] Through the above bit-width threshold setting and adjustment strategy, limited resources can be fully utilized on the premise of meeting performance requirements to ensure the stable operation of the monitoring system.

[0055] The third aspect of the present invention provides a computer-readable storage medium, which includes a program for the dynamic bit-width adaptive preprocessing method of the power grid waveform with embedded AI. When the program for the dynamic bit-width adaptive preprocessing method of the power grid waveform with embedded AI is executed by a processor, the steps of the dynamic bit-width adaptive preprocessing method of the power grid waveform with embedded AI as described in any one of the above are implemented.

[0056] A dynamic bit-width adaptive preprocessing method, system and medium for the power grid waveform with embedded AI disclosed in the present invention, by acquiring real-time sampling data of voltage and current, analyzing the sampling accuracy of the real-time sampling data; setting a sampling accuracy threshold, and judging whether the sampling accuracy is greater than the sampling accuracy threshold; if it is greater than the sampling accuracy threshold, converting the real-time sampling data into Q-format fixed-point numbers, and normalizing the real-time sampling data after Q-format fixed-point number conversion; if it is less than or equal to the sampling accuracy threshold, using the LUT look-up table method, converting the real-time sampling data into a normalized value and saving it to table T; inputting the normalized sampling data into a quantization model, outputting the data bit-width, generating a bit-width adjustment strategy based on the set bit-width threshold, dynamically adjusting the data bit-width based on the bit-width adjustment strategy, and outputting the adjustment result; improving the data preprocessing efficiency through Q-format fixed-point quantization and LUT look-up table method, reducing the memory occupancy, and performing adaptive preprocessing according to the acquisition signals of different bit-widths.

[0057] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the displayed or discussed components can be through some interfaces. The indirect coupling or communication connection of devices or units can be electrical, mechanical, or other forms.

[0058] The units described above as separate components may or may not be physically separated. The components displayed as units may or may not be physical units; they can be located in one place or distributed to multiple network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0059] In addition, each functional unit in the embodiments of the present invention can be all integrated in a processing unit, or each unit can be separately used as a unit, or two or more units can be integrated in one unit; the above-mentioned integrated units can be implemented in the form of hardware, or in the form of a combination of hardware and software functional units.

[0060] Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a readable storage medium. When the program is executed, it executes the steps including the above method embodiments; and the foregoing storage medium includes: removable storage devices, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disks or optical disks and other various media that can store program codes.

[0061] Or, if the above-mentioned integrated units of the present invention are implemented in the form of software functional modules and sold or used as independent products, they can also be stored in a readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present invention, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. The software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the embodiments of the present invention. And the foregoing storage medium includes: removable storage devices, ROM, RAM, magnetic disks or optical disks and other various media that can store program codes.

Claims

1. An embedded AI power grid waveform dynamic bit width adaptive preprocessing method, characterized in that: include: Obtain real-time sampling data of voltage and current, and analyze the sampling accuracy of real-time sampling data; Set the sampling accuracy threshold to determine whether the sampling accuracy is greater than the sampling accuracy threshold; If it is greater than the sampling accuracy threshold, the real-time sampling data is converted into a Q-format fixed-point number, and the real-time sampling data after the Q-format fixed-point number conversion is normalized; If it is less than or equal to the sampling accuracy threshold, the LUT table lookup method is used to convert the real-time sampling data into normalized values ​​and save them in table T; The normalized sampled data is input into the quantization model, the data bit width is output, a bit width adjustment strategy is generated based on the set bit width threshold, the data bit width is dynamically adjusted based on the bit width adjustment strategy, and the adjustment result is output.

2. The method for adaptive preprocessing of dynamic bit width of power grid waveform of embedded AI according to claim 1 is characterized in that: Obtain real-time sampling data of voltage and current, and analyze the sampling accuracy of real-time sampling data, including: Acquire real-time sampling data of voltage and current, store the real-time sampling data into a buffer area in sequence, and obtain storage values; A cyclic redundancy check algorithm is used to generate and store a check code for each set of real-time sampling data, and the check code is compared with the stored value to determine whether they are consistent; If they are inconsistent, the real-time sampling data of voltage and current are resampled. If they are consistent, the reference voltage and reference current are set, and the sampling precision value is set based on the reference voltage and reference current; Compare the sampling precision value with the real-time sampling data to obtain a sampling deviation value, and determine whether the sampling deviation value is within a set accuracy range; If it is within the set accuracy range, the sampling accuracy of the real-time sampling data is generated. If it is not within the set sampling accuracy range, a correction coefficient is generated and drift correction is performed on the sampling data based on the correction coefficient.

3. The method for adaptive preprocessing of dynamic bit width of power grid waveform of embedded AI according to claim 2 is characterized in that: The real-time sampling data is converted into Q-format fixed-point numbers, and the real-time sampling data after the Q-format fixed-point number conversion is normalized, specifically including: Determine the dynamic range of real-time sampling data and obtain the maximum and minimum values ​​of the dynamic range; The scale factor is set based on the maximum value and the minimum value of the dynamic range, the real-time sampling data is multiplied by the scale factor, and the data is rounded off to obtain an integer in Q format; Based on the integer in Q format, the real-time sampling data is converted into a Q format fixed-point number to obtain the converted data; Map the converted data to obtain a mapping result, and analyze whether the mapping result is within the set mapping range; If it is, it is determined that the converted data meets the requirements; if it is in the set mapping interval, the real-time sampling data is normalized.

4. The method for adaptive preprocessing of dynamic bit width of power grid waveform of embedded AI according to claim 3 is characterized in that: The LUT table lookup method is used to convert the real-time sampling data into normalized values ​​and save them in table T, including: Determine the dynamic range of real-time sampling data and obtain the maximum and minimum values ​​of the dynamic range Calculate the index position in the lookup table for each real-time sampling data based on the dynamic range of the sampling data; Obtain the corresponding normalized value from the lookup table based on the index position to complete the normalization process; Save the normalized values ​​into table T.

5. The method for adaptive preprocessing of dynamic bit width of power grid waveform of embedded AI according to claim 4 is characterized in that: The normalized sampled data is input into the quantization model, and the output data bit width includes: Use a clustering algorithm to cluster the normalized values ​​into several clusters, with the center of each cluster as a quantization level; Map each data point to the nearest cluster center to obtain mapping data; The mapped data is input into the quantization model, and the required data width is calculated according to the number of clusters.

6. The method for adaptive preprocessing of dynamic bit width of power grid waveform of embedded AI according to claim 5 is characterized in that: Generate a bit width adjustment strategy based on the set bit width threshold, and dynamically adjust the data bit width based on the bit width adjustment strategy, specifically including: Set different bit width thresholds based on performance requirements, resource limitations, and data characteristics; Obtain real-time sampling data and extract data features; Compare the data features with the set bit width threshold and generate a corresponding bit width adjustment strategy; The data bit width is dynamically adjusted according to the corresponding bit width adjustment strategy.

7. An embedded AI power grid waveform dynamic bit width adaptive preprocessing system, characterized in that: The system includes: a memory and a processor, wherein the memory includes a program of a method for adaptively preprocessing a dynamic bit width of a power grid waveform with embedded AI, and when the program of the method for adaptively preprocessing a dynamic bit width of a power grid waveform with embedded AI is executed by the processor, the following steps are implemented: Obtain real-time sampling data of voltage and current, and analyze the sampling accuracy of real-time sampling data; Set the sampling accuracy threshold to determine whether the sampling accuracy is greater than the sampling accuracy threshold; If it is greater than the sampling accuracy threshold, the real-time sampling data is converted into a Q-format fixed-point number, and the real-time sampling data after the Q-format fixed-point number conversion is normalized; If it is less than or equal to the sampling accuracy threshold, the LUT table lookup method is used to convert the real-time sampling data into normalized values ​​and save them in table T; The normalized sampled data is input into the quantization model, the data bit width is output, a bit width adjustment strategy is generated based on the set bit width threshold, the data bit width is dynamically adjusted based on the bit width adjustment strategy, and the adjustment result is output.

8. The embedded AI power grid waveform dynamic bit width adaptive preprocessing system according to claim 7 is characterized in that: Obtain real-time sampling data of voltage and current, and analyze the sampling accuracy of real-time sampling data, including: Acquire real-time sampling data of voltage and current, store the real-time sampling data into a buffer area in sequence, and obtain storage values; A cyclic redundancy check algorithm is used to generate and store a check code for each set of real-time sampling data, and the check code is compared with the stored value to determine whether they are consistent; If they are inconsistent, the real-time sampling data of voltage and current are resampled. If they are consistent, the reference voltage and reference current are set, and the sampling precision value is set based on the reference voltage and reference current; Compare the sampling precision value with the real-time sampling data to obtain a sampling deviation value, and determine whether the sampling deviation value is within a set accuracy range; If it is within the set accuracy range, the sampling accuracy of the real-time sampling data is generated. If it is not within the set sampling accuracy range, a correction coefficient is generated and drift correction is performed on the sampling data based on the correction coefficient.

9. The embedded AI power grid waveform dynamic bit width adaptive preprocessing system according to claim 8 is characterized in that: The real-time sampling data is converted into Q-format fixed-point numbers, and the real-time sampling data after the Q-format fixed-point number conversion is normalized, specifically including: Determine the dynamic range of real-time sampling data and obtain the maximum and minimum values ​​of the dynamic range; The scale factor is set based on the maximum value and the minimum value of the dynamic range, the real-time sampling data is multiplied by the scale factor, and the data is rounded off to obtain an integer in Q format; Based on the integer in Q format, the real-time sampling data is converted into a Q format fixed-point number to obtain the converted data; Map the converted data to obtain a mapping result, and analyze whether the mapping result is within the set mapping range; If it is, it is determined that the converted data meets the requirements; if it is in the set mapping interval, the real-time sampling data is normalized.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a program of a method for adaptively preprocessing a dynamic bit width of a power grid waveform with an embedded AI. When the program of the method for adaptively preprocessing a dynamic bit width of a power grid waveform with an embedded AI is executed by a processor, the steps of the method for adaptively preprocessing a dynamic bit width of a power grid waveform with an embedded AI as described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Self-adaptive weight bit width quantification method and device based on statistical analysis

    CN115470885A

  • System and method based on envelope tracking and adaptive digital pre-distortion

    CN116131773A

  • A remote dynamic current evaluation method and system based on AC / DC comparison technology

    CN119757911A

  • Arc fault protection for power conversion

    US20150098251A1

Cited By

  • Efficient format conversion method

    CN121742797A

  • A high-efficiency format conversion method

    CN121742797B