An embedded AI-based power grid waveform dynamic bit width adaptive preprocessing method, system, and medium
By using Q-format fixed-point conversion and the LUT lookup method to adaptively adjust the data bit width, the problems of time-consuming preprocessing and memory usage of embedded AI models in power grid waveform detection are solved, and efficient data preprocessing and real-time requirements are achieved.
Patent Information
- Application Number
- CN202510525230.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2045-04-25
AI Technical Summary
The existing embedded AI model lacks a floating-point unit processor when detecting power grid waveforms, which results in preprocessing time increasing by more than 20 times. Floating-point operations also occupy additional memory, affecting real-time performance.
Q-format fixed-point conversion and LUT lookup method are used for data preprocessing. The data bit width is adaptively adjusted according to the sampling accuracy, including Q-format fixed-point conversion and LUT lookup method, which reduces memory usage and improves preprocessing efficiency.
Through adaptive preprocessing methods, memory usage is reduced, data preprocessing efficiency is improved, real-time requirements are met, and acquisition signals of different bit widths are adapted.
Smart Images

Figure CN120045163B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of bit width adaptation technology, and more specifically, to a method, system, and medium for adaptive preprocessing of dynamic bit width of power grid waveforms using embedded AI. Background Art
[0002] Existing embedded AI model input preprocessing mostly uses floating-point operations. When deploying power grid waveform detection AI models on embedded devices, since most MCUs do not have an FPU, software simulation of floating points is required, resulting in preprocessing time increasing by more than 20 times, seriously affecting the real-time performance of inference. In addition, floating-point operations require converting ADC integer data into a float type cache, which takes up additional memory. Summary of the Invention
[0003] The purpose of the embodiments of the present application is to provide an embedded AI-based method, system, and medium for adaptive preprocessing of power grid waveform dynamic bit widths, which improves data preprocessing efficiency through Q-format fixed-point conversion and LUT lookup, reduces memory usage, and can perform adaptive preprocessing based on collected signals of different bit widths.
[0004] The present application also provides an embedded AI-based power grid waveform dynamic bit width adaptive preprocessing method, including:
[0005] Obtain real-time sampling data of voltage and current, and analyze the sampling accuracy of real-time sampling data;
[0006] Set the sampling accuracy threshold and determine whether the sampling accuracy is greater than the sampling accuracy threshold;
[0007] If it is greater than the sampling accuracy threshold, 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;
[0008] If it is less than or equal to the sampling accuracy threshold, the LUT lookup method is used to convert the real-time sampling data into normalized values and save them in table T;
[0009] 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.
[0010] Optionally, in the embedded AI power grid waveform dynamic bit width adaptive preprocessing method described in the 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 include:
[0011] Acquire real-time sampling data of voltage and current, store the real-time sampling data into a buffer in sequence, and obtain storage values;
[0012] A cyclic redundancy check algorithm is used to generate a check code for each set of real-time sampling data and store it. The check code is compared with the stored value to determine whether they are consistent;
[0013] 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 accuracy value is set based on the reference voltage and reference current;
[0014] 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 range;
[0015] 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 accuracy range, a correction coefficient is generated and the sampling data is drift corrected based on the correction coefficient.
[0016] Optionally, in the embedded AI power grid waveform dynamic bit width adaptive preprocessing method described in the embodiment of the present application, the real-time sampled data is converted into a Q format fixed-point number, and the real-time sampled data after the Q format fixed-point number conversion is normalized, specifically including:
[0017] Determine the dynamic range of real-time sampling data and obtain the maximum and minimum values of the dynamic range;
[0018] A scaling factor is set based on the maximum and minimum values of the dynamic range, the real-time sampling data is multiplied by the scaling factor, and the data is rounded off to obtain an integer in Q format;
[0019] 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;
[0020] Map the converted data to obtain a mapping result, and analyze whether the mapping result is within the set mapping range;
[0021] If it is, the converted data is determined to meet the requirements; if it is in the set mapping interval, the real-time sampling data is normalized.
[0022] Optionally, in the embedded AI power grid waveform dynamic bit width adaptive preprocessing method described in the embodiment of the present application, a LUT lookup table method is used to convert the real-time sampled data into normalized values and save them in table T, specifically including:
[0023] Determine the dynamic range of real-time sampling data and obtain the maximum and minimum values of the dynamic range
[0024] Calculate the index position in the lookup table for each real-time sampling data based on the dynamic range of the sampling data;
[0025] Obtain the corresponding normalized value from the lookup table based on the index position to complete the normalization process;
[0026] Save the normalized values into table T.
[0027] Optionally, in the embedded AI power grid waveform dynamic bit width adaptive preprocessing method described in the embodiment of the present application, the normalized sampled data is input into the quantization model, and the output data bit width specifically includes:
[0028] Use clustering algorithm to cluster the normalized values into several clusters, and the center of each cluster is used as a quantization level;
[0029] Map each data point to the nearest cluster center to obtain the mapping data;
[0030] The mapped data is input into the quantization model, and the required data width is calculated based on the number of clusters.
[0031] Optionally, in the embedded AI power grid waveform dynamic bit width adaptive preprocessing method described in the 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:
[0032] Set different bit width thresholds based on performance requirements, resource limitations, and data characteristics;
[0033] Obtain real-time sampling data and extract data features;
[0034] Compare the data characteristics with the set bit width threshold and generate the corresponding bit width adjustment strategy;
[0035] The data bit width is dynamically adjusted according to the corresponding bit width adjustment strategy.
[0036] In a second aspect, an embodiment of the present application provides an embedded AI power grid waveform dynamic bit width adaptive preprocessing system, the system comprising: a memory and a processor, the memory comprising a program of an embedded AI power grid waveform dynamic bit width adaptive preprocessing method, the embedded AI power grid waveform dynamic bit width adaptive preprocessing method program when executed by the processor to implement the following steps:
[0037] Obtain real-time sampling data of voltage and current, and analyze the sampling accuracy of real-time sampling data;
[0038] Set the sampling accuracy threshold and determine whether the sampling accuracy is greater than the sampling accuracy threshold;
[0039] If it is greater than the sampling accuracy threshold, 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;
[0040] If it is less than or equal to the sampling accuracy threshold, the LUT lookup method is used to convert the real-time sampling data into normalized values and save them in table T;
[0041] 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.
[0042] Optionally, in the embedded AI power grid waveform dynamic bit width adaptive preprocessing system described in the 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 include:
[0043] Acquire real-time sampling data of voltage and current, store the real-time sampling data into a buffer in sequence, and obtain storage values;
[0044] A cyclic redundancy check algorithm is used to generate a check code for each set of real-time sampling data and store it. The check code is compared with the stored value to determine whether they are consistent;
[0045] 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 accuracy value is set based on the reference voltage and reference current;
[0046] 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 range;
[0047] 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 accuracy range, a correction coefficient is generated and the sampling data is drift corrected based on the correction coefficient.
[0048] Optionally, in the embedded AI power grid waveform dynamic bit width adaptive preprocessing system described in the embodiment of the present application, the real-time sampled data is converted into a Q format fixed-point number, and the real-time sampled data after the Q format fixed-point number conversion is normalized, specifically including:
[0049] Determine the dynamic range of real-time sampling data and obtain the maximum and minimum values of the dynamic range;
[0050] A scaling factor is set based on the maximum and minimum values of the dynamic range, the real-time sampling data is multiplied by the scaling factor, and the data is rounded off to obtain an integer in Q format;
[0051] 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;
[0052] Map the converted data to obtain a mapping result, and analyze whether the mapping result is within the set mapping range;
[0053] If it is, the converted data is determined to meet the requirements; if it is in the set mapping interval, the real-time sampling data is normalized.
[0054] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, which includes a program for a method for adaptively preprocessing a dynamic bit width of a power grid waveform with embedded AI. When the program for adaptively preprocessing a dynamic bit width of a power grid waveform with 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 embedded AI as described in any one of the above items are implemented.
[0055] As can be seen from the above, an embedded AI power grid waveform dynamic bit width adaptive preprocessing method, system and medium provided in the embodiment of the present application obtains real-time sampling data of voltage and current, analyzes the sampling accuracy of the real-time sampling data; sets a 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 to 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 a normalized value and save it in table T; the normalized sampling data is input into the quantization model, the data bit width is output, and 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; the data preprocessing efficiency is improved by Q format fixed-point conversion and LUT table lookup method, memory usage is reduced, and adaptive preprocessing can be performed according to the acquisition signals of different bit widths. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0057] Figure 1 Flowchart of the method for adaptive preprocessing of dynamic bit width of power grid waveform using embedded AI provided in an embodiment of the present application;
[0058] Figure 2 Flowchart of the sampling accuracy analysis method of the embedded AI power grid waveform dynamic bit width adaptive preprocessing method provided in the embodiment of the present application;
[0059] Figure 3Flowchart of the Q-format fixed-point number conversion method for the embedded AI power grid waveform dynamic bit width adaptive preprocessing method provided in the embodiment of the present application. DETAILED DESCRIPTION
[0060] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work fall within the scope of protection of the present application.
[0061] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and should not be understood as indicating or implying relative importance.
[0062] Please refer to Figure 1 , Figure 1 This is a flowchart of a method for adaptively preprocessing a power grid waveform using an embedded AI in some embodiments of the present application. The method is used in a terminal device and includes the following steps:
[0063] S101, acquiring real-time sampling data of voltage and current, and analyzing the sampling accuracy of the real-time sampling data;
[0064] S102, setting a sampling accuracy threshold, and determining whether the sampling accuracy is greater than the sampling accuracy threshold;
[0065] S103, if it is greater than the sampling accuracy threshold, converting the real-time sampling data into a Q-format fixed-point number, and normalizing the real-time sampling data after the Q-format fixed-point number conversion;
[0066] S104, if it is less than or equal to the sampling accuracy threshold, then use the LUT lookup method to convert the real-time sampling data into normalized values and save them in table T;
[0067] S105 , inputting the normalized sampled data into a quantization model, outputting the 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 the adjustment result.
[0068] It should be noted that according to the manual of the metering chip, the sampling accuracy is N bit. 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 based on the voltage waveform and current waveform.
[0069] When N > 12 bits, perform Q format fixed-point conversion on the ADC data. The conversion formula is as follows:
[0070] Q M = ((2×adc−(2N−1))×scale) ≫ (N - M + 1)
[0071] In the formula, M is the number of decimal places, scale is the scaling factor, scale = 2M / (2N-1), and N and M are fixed values in specific projects. Therefore, the entire operation only involves multiplication, addition, and shift operations on the ADC, which has high computational efficiency.
[0072] When N <= 12 bits, the LUT lookup method is used to convert all bit data into normalized values in advance and save them in table T. The conversion is then performed in real time according to the following formula:
[0073] Q = T[adc];
[0074] The preprocessed Q data is directly input into the quantitative model for deduction.
[0075] Please refer to Figure 2 , Figure 2 This is a flow chart of a sampling accuracy analysis method for a dynamic bit width adaptive preprocessing method of a power grid waveform using embedded AI in some embodiments of the present application. According to an embodiment of the present invention, real-time sampling data of voltage and current is obtained, and the sampling accuracy of the real-time sampling data is analyzed, specifically including:
[0076] S201, acquiring real-time sampling data of voltage and current, and storing the real-time sampling data in a buffer in sequence to obtain a storage value;
[0077] S202, using a cyclic redundancy check algorithm to generate a check code for each set of real-time sampled data and store it, and compare the check code with the stored value to determine whether they are consistent;
[0078] S203, if they are inconsistent, re-sampling the real-time sampling data of voltage and current; if they are consistent, setting a reference voltage and a reference current, and setting a sampling precision value based on the reference voltage and the reference current;
[0079] S204, comparing the sampling accuracy value with the real-time sampling data to obtain a sampling deviation value, and determining whether the sampling deviation value is within a set accuracy range;
[0080] S205: If the accuracy is within the set accuracy range, the sampling accuracy of the real-time sampling data is generated; if the accuracy is not within the set accuracy range, a correction coefficient is generated, and drift correction is performed on the sampling data based on the correction coefficient.
[0081] It should be noted that high-precision reference voltage and reference current are introduced. At the same time, the ADC samples the reference signal and the actual grid voltage and current signals simultaneously. The known precise value of the reference signal is compared with the sampled value, and the deviation between the two is calculated. If the deviation is within the theoretical error range of the ADC, the sampling accuracy meets the requirements. If the deviation is too large, the hardware circuit should be checked, such as the anti-aliasing filter, to see if parameter drift is causing additional signal attenuation or phase shift, affecting sampling accuracy. The stability of the sampling can also be assessed by sampling the reference signal multiple times and calculating the standard deviation of the sampled values. The smaller the standard deviation, the more stable the sampling accuracy.
[0082] Please refer to Figure 3 , Figure 3 This is a flow chart of a Q-format fixed-point number conversion method for a dynamic bit-width adaptive preprocessing method of a power grid waveform using embedded AI in some embodiments of the present application. According to an embodiment of the present invention, real-time sampled data is converted to Q-format fixed-point numbers, and the real-time sampled data after Q-format fixed-point number conversion is normalized, specifically including:
[0083] S301, determining the dynamic range of the real-time sampling data, and obtaining the maximum value and the minimum value of the dynamic range;
[0084] S302, setting a scaling factor based on the maximum and minimum values of the dynamic range, multiplying the real-time sampled data by the scaling factor, and rounding the data to obtain an integer in Q format;
[0085] S303, converting the real-time sampled data into Q-format fixed-point numbers based on the Q-format integers to obtain converted data;
[0086] S304, mapping the converted data to obtain a mapping result, and analyzing whether the mapping result is within the set mapping range;
[0087] S305: 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.
[0088] It should be noted that the Q format is a method for representing fixed-point numbers. It can effectively handle numerical operations when hardware resources are limited (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], to facilitate subsequent processing and analysis.
[0089] According to an embodiment of the present invention, a LUT lookup table method is used to convert real-time sampled data into normalized values and then save them into table T, which specifically includes:
[0090] Determine the dynamic range of real-time sampling data and obtain the maximum and minimum values of the dynamic range
[0091] Calculate the index position in the lookup table for each real-time sampling data based on the dynamic range of the sampling data;
[0092] Obtain the corresponding normalized value from the lookup table based on the index position to complete the normalization process;
[0093] Save the normalized values into table T.
[0094] It should be noted that the maximum and minimum values of the real-time sampling data must be clearly defined, as this will determine the normalization interval and the range of the lookup table.
[0095] Build a lookup table: Generate a series of values within the data range according to the set accuracy (that is, the data interval), calculate the normalized values corresponding to these values (usually normalized to the [0, 1] interval), and store these normalized values in the lookup table.
[0096] Lookup and normalization: For each real-time sample data, normalization 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.
[0097] According to an embodiment of the present invention, the normalized sampled data is input into a quantization model, and the data bit width is output, specifically including:
[0098] Use clustering algorithm to cluster the normalized values into several clusters, and the center of each cluster is used as a quantization level;
[0099] Map each data point to the nearest cluster center to obtain the mapping data;
[0100] The mapped data is input into the quantization model, and the required data width is calculated based on the number of clusters.
[0101] According to an embodiment of the present invention, a bit width adjustment strategy is generated based on a set bit width threshold, and data bit width is dynamically adjusted based on the bit width adjustment strategy, specifically including:
[0102] Set different bit width thresholds based on performance requirements, resource limitations, and data characteristics;
[0103] Obtain real-time sampling data and extract data features;
[0104] Compare the data characteristics with the set bit width threshold and generate the corresponding bit width adjustment strategy;
[0105] The data bit width is dynamically adjusted according to the corresponding bit width adjustment strategy.
[0106] It should be noted that when the waveform complexity of the data is low, the real-time requirements are high, and the storage and computing resources are limited, the data bit width is set to the low bit width threshold (8 bits). The data characteristics include sampling time characteristics, data performance characteristics, and waveform characteristics. The specific bit width adjustment strategy is 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; conversely, if the data characteristics indicate that the data has a large amount of information, the accuracy requirements are high, and the system performance allows, the data bit width can be increased to ensure the quality of data processing.
[0107] When the data waveform is highly complex, the accuracy requirement is high, and the data dynamic range is wide, set the data bit width to the high bit width threshold (16 bits).
[0108] In the case between the two, the bit width can be adjusted appropriately 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.
[0109] Through the above bit width threshold setting and adjustment strategy, limited resources can be fully utilized while meeting performance requirements to ensure the stable operation of the monitoring system.
[0110] In a second aspect, an embodiment of the present application provides an embedded AI power grid waveform dynamic bit width adaptive preprocessing system, the system comprising: a memory and a processor, the memory including a program of an embedded AI power grid waveform dynamic bit width adaptive preprocessing method, and when the embedded AI power grid waveform dynamic bit width adaptive preprocessing method program is executed by the processor, the following steps are implemented:
[0111] Obtain real-time sampling data of voltage and current, and analyze the sampling accuracy of real-time sampling data;
[0112] Set the sampling accuracy threshold and determine whether the sampling accuracy is greater than the sampling accuracy threshold;
[0113] If it is greater than the sampling accuracy threshold, 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;
[0114] If it is less than or equal to the sampling accuracy threshold, the LUT lookup method is used to convert the real-time sampling data into normalized values and save them in table T;
[0115] 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.
[0116] It should be noted that according to the manual of the metering chip, the sampling accuracy is N bit, and the real-time sampling data ADC of voltage and current is obtained through the metering chip.
[0117] When N > 12 bits, perform Q format fixed-point conversion on the ADC data. The conversion formula is as follows:
[0118] Q M = ((2×adc−(2N−1))×scale) ≫ (N - M + 1)
[0119] In the formula, Q M Indicates the conversion result of a Q-format fixed-point number. M is the number of decimal places, and scale is the scaling factor, scale = 2M / (2N-1). N and M are fixed values in a specific project. Therefore, the entire operation only involves multiplication, addition, and shift operations on the adc, resulting in high computational efficiency.
[0120] When N <= 12 bits, the LUT lookup method is used to convert all bit data into normalized values in advance and save them in table T. The conversion is then performed in real time according to the following formula:
[0121] Q = T[adc];
[0122] The preprocessed Q data is directly input into the quantitative model for deduction.
[0123] According to an embodiment of the present invention, obtaining real-time sampling data of voltage and current and analyzing the sampling accuracy of the real-time sampling data specifically include:
[0124] Acquire real-time sampling data of voltage and current, store the real-time sampling data into a buffer in sequence, and obtain storage values;
[0125] A cyclic redundancy check algorithm is used to generate a check code for each set of real-time sampling data and store it. The check code is compared with the stored value to determine whether they are consistent;
[0126] 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 accuracy value is set based on the reference voltage and reference current;
[0127] 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 range;
[0128] 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 accuracy range, a correction coefficient is generated and the sampling data is drift corrected based on the correction coefficient.
[0129] It should be noted that high-precision reference voltage and reference current are introduced. At the same time, the ADC samples the reference signal and the actual grid voltage and current signals simultaneously. The known precise value of the reference signal is compared with the sampled value, and the deviation between the two is calculated. If the deviation is within the theoretical error range of the ADC, the sampling accuracy meets the requirements. If the deviation is too large, the hardware circuit should be checked, such as the anti-aliasing filter, to see if parameter drift is causing additional signal attenuation or phase shift, affecting sampling accuracy. The stability of the sampling can also be assessed by sampling the reference signal multiple times and calculating the standard deviation of the sampled values. The smaller the standard deviation, the more stable the sampling accuracy.
[0130] According to an embodiment of the present invention, the real-time sampled data is converted into a Q-format fixed-point number, and the real-time sampled data after the Q-format fixed-point number conversion is normalized, specifically including:
[0131] Determine the dynamic range of real-time sampling data and obtain the maximum and minimum values of the dynamic range;
[0132] A scaling factor is set based on the maximum and minimum values of the dynamic range, the real-time sampling data is multiplied by the scaling factor, and the data is rounded off to obtain an integer in Q format;
[0133] 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;
[0134] Map the converted data to obtain a mapping result, and analyze whether the mapping result is within the set mapping range;
[0135] If it is, the converted data is determined to meet the requirements; if it is in the set mapping interval, the real-time sampling data is normalized.
[0136] It should be noted that the Q format is a method for representing fixed-point numbers. It can effectively handle numerical operations when hardware resources are limited (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], to facilitate subsequent processing and analysis.
[0137] According to an embodiment of the present invention, a LUT lookup table method is used to convert real-time sampled data into normalized values and then save them into table T, which specifically includes:
[0138] Determine the dynamic range of real-time sampling data and obtain the maximum and minimum values of the dynamic range
[0139] Calculate the index position in the lookup table for each real-time sampling data based on the dynamic range of the sampling data;
[0140] Obtain the corresponding normalized value from the lookup table based on the index position to complete the normalization process;
[0141] Save the normalized values into table T.
[0142] It should be noted that the maximum and minimum values of the real-time sampling data must be clearly defined, as this will determine the normalization interval and the range of the lookup table.
[0143] Build a lookup table: Generate a series of values within the data range according to the set accuracy (that is, the data interval), calculate the normalized values corresponding to these values (usually normalized to the [0, 1] interval), and store these normalized values in the lookup table.
[0144] Lookup and normalization: For each real-time sample data, normalization 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.
[0145] According to an embodiment of the present invention, the normalized sampled data is input into a quantization model, and the data bit width is output, specifically including:
[0146] Use clustering algorithm to cluster the normalized values into several clusters, and the center of each cluster is used as a quantization level;
[0147] Map each data point to the nearest cluster center to obtain the mapping data;
[0148] The mapped data is input into the quantization model, and the required data width is calculated based on the number of clusters.
[0149] According to an embodiment of the present invention, a bit width adjustment strategy is generated based on a set bit width threshold, and data bit width is dynamically adjusted based on the bit width adjustment strategy, specifically including:
[0150] Set different bit width thresholds based on performance requirements, resource limitations, and data characteristics;
[0151] Obtain real-time sampling data and extract data features;
[0152] Compare the data characteristics with the set bit width threshold and generate the corresponding bit width adjustment strategy;
[0153] The data bit width is dynamically adjusted according to the corresponding bit width adjustment strategy.
[0154] It should be noted that when the waveform complexity of the data is low, the real-time requirements are high, and the storage and computing resources are limited, the data bit width is set to the low bit width threshold (8 bits).
[0155] When the data waveform is highly complex, the accuracy requirement is high, and the data dynamic range is wide, set the data bit width to the high bit width threshold (16 bits).
[0156] In the case between the two, the bit width can be adjusted appropriately 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.
[0157] Through the above bit width threshold setting and adjustment strategy, limited resources can be fully utilized while meeting performance requirements to ensure the stable operation of the monitoring system.
[0158] The third aspect of the present invention provides a computer-readable storage medium, which includes a program for the adaptive preprocessing method of the dynamic bit width of the power grid waveform with embedded AI. When the program for the adaptive preprocessing method of the dynamic bit width of the power grid waveform with embedded AI is executed by a processor, the steps of the adaptive preprocessing method of the dynamic bit width of the power grid waveform with embedded AI as described in any one of the above items are implemented.
[0159] The present invention discloses an embedded AI-based power grid waveform dynamic bit width adaptive preprocessing method, system and medium. The method acquires real-time sampling data of voltage and current and analyzes the sampling accuracy of the real-time sampling data; sets a sampling accuracy threshold to determine whether the sampling accuracy is greater than the sampling accuracy threshold; if greater than the sampling accuracy threshold, performs Q-format fixed-point number conversion on the real-time sampling data, and normalizes the real-time sampling data after the Q-format fixed-point number conversion; if less than or equal to the sampling accuracy threshold, uses a LUT lookup method to convert the real-time sampling data into normalized values and save them in a table T; inputs the normalized sampling data into a quantization model, outputs the data bit width, generates a bit width adjustment strategy based on the set bit width threshold, dynamically adjusts the data bit width based on the bit width adjustment strategy, and outputs the adjustment result; improves data preprocessing efficiency through Q-format fixed-point conversion and the LUT lookup method, reduces memory usage, and performs adaptive preprocessing according to acquisition signals with different bit widths.
[0160] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of units is merely a logical function division. In actual implementation, there may be other division methods, such as: 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 components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0161] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed across multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.
[0162] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0163] Those skilled in the art will appreciate that all or part of the steps of the above-mentioned method embodiments may be implemented by hardware associated with program instructions, and the aforementioned program may be stored in a readable storage medium. When the program is executed, the program executes the steps of the above-mentioned method embodiments. The aforementioned storage medium includes various media that can store program codes, such as mobile storage devices, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.
[0164] Alternatively, if the integrated units described above are implemented as software modules and sold or used as standalone products, they can also be stored on a readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present invention, or the portion that contributes to the prior art, can be embodied in the form of a software product. This software product, stored on a storage medium, includes instructions for enabling a computer device (such as a personal computer, server, or network device) to execute all or part of the methods described in the various embodiments of the present invention. The aforementioned storage media include various media capable of storing program code, such as removable storage devices, ROM, RAM, magnetic disks, or optical disks.
Claims
1. An embedded AI-based 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 and 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 Q format fixed-point numbers, 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 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 with 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 the real-time sampling data, including: Acquire real-time sampling data of voltage and current, store the real-time sampling data into a buffer in sequence, and obtain storage values; A cyclic redundancy check algorithm is used to generate a check code for each set of real-time sampling data and store it. 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 accuracy value is set 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 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 accuracy range, a correction coefficient is generated and the sampling data is drift corrected based on the correction coefficient.
3. The method for adaptive preprocessing of dynamic bit width of power grid waveform using 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; A scaling factor is set based on the maximum and minimum values of the dynamic range, the real-time sampling data is multiplied by the scaling 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, the converted data is determined to meet 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 with embedded AI according to claim 3 is characterized in that: Use the LUT lookup method to convert 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 with 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 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 mapping data; The mapped data is input into the quantization model, and the required data width is calculated based on the number of clusters.
6. The method for adaptive preprocessing of dynamic bit width of power grid waveform with 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 characteristics with the set bit width threshold and generate the 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 by: 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 and 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 Q format fixed-point numbers, 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 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 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 the real-time sampling data, including: Acquire real-time sampling data of voltage and current, store the real-time sampling data into a buffer in sequence, and obtain storage values; A cyclic redundancy check algorithm is used to generate a check code for each set of real-time sampling data and store it. 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 accuracy value is set 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 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 accuracy range, a correction coefficient is generated and the sampling data is drift corrected based on the correction coefficient.
9. The embedded AI 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; A scaling factor is set based on the maximum and minimum values of the dynamic range, the real-time sampling data is multiplied by the scaling 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, the converted data is determined to meet 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 an embedded AI power grid waveform dynamic bit width adaptive preprocessing method program. When the embedded AI power grid waveform dynamic bit width adaptive preprocessing method program is executed by a processor, the steps of the embedded AI power grid waveform dynamic bit width adaptive preprocessing method according to any one of claims 1 to 6 are implemented.