A method and device for quickly measuring analog electrical signals
By transferring the median filtering, average filtering and true value calculation tasks to FPGA in the processor + FPGA + ADC system, the problem of analog signal conversion in the existing technology occupying a large amount of processor resources is solved, and rapid measurement is achieved and efficient resource utilization.
Patent Information
- Application Number
- CN202411310393.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-09-20
AI Technical Summary
The prior art requires a large amount of processor resources to convert analog signals to digital real values, resulting in extremely tight running time of other functions.
Using processor + FPGA + ADC, median filtering, average filtering and real value calculation are transferred to FPGA to complete to shorten the computing time and reduce the resource consumption of the processor.
By transferring the computing task to the FPGA, the computing time is significantly shortened, the processor resource consumption is reduced, and the processor has sufficient time to execute other logic processing and control algorithms, which improves the measurement speed of analog electrical signals.
Smart Images

Figure CN118837623B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of electrical variable measurement, and in particular, relates to a method and a device for quickly measuring analog electrical signals. Background Art
[0002] An electronic load is a device that consumes electrical energy by controlling the conduction of its internal power MOSFET or transistor and relying on the power dissipation of the power tube. It can accurately adjust the load voltage and load current, and can simulate working conditions such as load short circuit, as well as inductive load, resistive load and capacitive load. It has been widely used in the performance testing of power supply equipment such as power supplies, batteries and generators.
[0003] The electronic load has the ability to sample and output the voltage and current of the circuit where it is located, and the output is in the form of analog signals. It needs to cooperate with processors such as MCU or DSP to complete the conversion from analog to digital real values before it can be applied to the subsequent test process. Whether it is voltage or current, to convert an analog signal into a real voltage value or real current value that can be actually used, it is inevitable to go through the process of analog-to-digital conversion → median filtering → average filtering → conversion to real value dimension → real value accuracy calibration. The most common method at present is to configure the ADC separately for analog-to-digital conversion, output digital quantity, and then transmit it to the MCU or DSP to calculate the median, average value, conversion of digital quantity and real value dimension, and real value accuracy calibration in a serial manner.
[0004] However, with the development of technology, the requirements for sampling rate are getting higher and higher. In high-end electronic products, the sampling rate has reached 500KHz, that is, a sample is completed every 2us. It takes more than 900ns to use MCU or DSP to perform median filtering, average filtering and true value calculation, which takes up nearly half of the working cycle. This makes the time reserved by MCU or DSP for subsequent logic processing, control algorithms, and given calculations extremely tight or even impossible to complete, which in turn affects the realization of other functions. Summary of the invention
[0005] In order to solve the problem in the prior art that a large amount of processor resources are required when converting analog signals to digital real values, resulting in abnormally tight running time of other functions, the present invention proposes a method and device for rapid measurement of analog electrical signals, which adopts a processor + FPGA + ADC method to transfer median filtering, average filtering and real value calculation to FPGA to shorten the operation time and reduce the resource consumption of the processor.
[0006] In order to solve the above technical problems, the present invention adopts the following technical solutions to achieve the above problems:
[0007] In one aspect, the present invention provides a method for quickly measuring an analog electrical signal, comprising:
[0008] Adjust the range of the collected analog electrical signal to the analog signal input range specified by the ADC;
[0009] Use ADC to convert the input signal into digital form and generate 0~2 N The digital signal, N is the number of digital bits of ADC;
[0010] Use FPGA to configure the following functional modules:
[0011] ADC digital quantity reading module, which reads the digital quantity signal output by ADC;
[0012] A median filter module, which has m N-bit registers for storing m historical data closest to the current time; the median filter module receives the digital signal output by the ADC digital quantity reading module, and takes the median from the currently received digital signal and the m historical data stored in the register as the current data output; updates the historical data in the m registers for median calculation in the next sampling period; wherein m≥2;
[0013] The module for converting digital quantity to real dimension determines the binary conversion coefficient K according to the corresponding relationship between the real analog electrical signal and the digital signal; after K is shifted left by M bits and rounded, it is multiplied by the current data output by the median filter module to generate the real value after 2N bit shift expansion; where the value of M is the maximum digital value output by ADC × K × [2 M ] The number of digits after the digit does not exceed the maximum value when 2N; [ ] is the rounding symbol;
[0014] The mean filter module receives the real value after the shift expansion, sums four consecutive real values after the shift expansion, shifts right by two bits, and generates a conversion result output; the conversion result is shifted right by M bits to obtain the real value of the analog electrical signal.
[0015] In some embodiments of the present application, in order to accurately read the digital quantity signal output by the ADC, the clock signal of the ADC digital quantity reading module can be configured to be synchronized with the ADC, and the data reading cycle of the ADC digital quantity reading module can be configured to be 2N clock signals, the first N clock signals wait for the ADC to perform analog-to-digital conversion, and the last N clock signals read the N-bit digital quantity signal output by the ADC; after the ADC digital quantity reading module receives the N-bit digital quantity signal, it is configured to control the median filtering module to enable and enter the median calculation process.
[0016] In some embodiments of the present application, the median filtering module may be configured to perform the following process in an enabled state:
[0017] When the first clock signal arrives, the digital quantity signal output by the ADC digital quantity reading module is latched, and the median filtering completion signal is set to an invalid state;
[0018] When the second clock signal arrives, the median calculation is performed and the calculation result is output;
[0019] When the third clock signal arrives, the median filtering completion signal is set to a valid state, the digital quantity to real dimension conversion module is controlled to be enabled, and the dimension conversion process is entered;
[0020] Before or when the fourth clock signal arrives, the median filtering module is disabled and waits for median calculation of the next digital quantity signal output by the ADC digital quantity reading module.
[0021] In some embodiments of the present application, the digital quantity to real dimension conversion module may be configured to perform the following process in an enabled state:
[0022] When the first clock signal arrives, the calculation result output by the median filter module is latched, and the dimension conversion completion signal is set to an invalid state;
[0023] When the second clock signal arrives, the digital quantity is converted into the real value after the shift expansion, and the real value after the shift expansion is output;
[0024] When the third clock signal arrives, the dimension conversion completion signal is set to a valid state, the mean filter module is controlled to be enabled, and the mean calculation process is entered;
[0025] Before or when the fourth clock signal arrives, the digital quantity to real dimension conversion module exits enabling and waits for dimension conversion of the next calculation result output by the median filtering module.
[0026] In some embodiments of the present application, the mean filter module may be configured to perform the following process in an enabled state:
[0027] When the first clock signal arrives, the shifted and expanded real value output by the digital quantity to real dimension module is latched, and the mean filtering completion signal is set to an invalid state;
[0028] When the second clock signal arrives, the mean value is calculated and the calculation result is output;
[0029] When the third clock signal arrives, the mean filtering completion signal is set to a valid state and output, so as to notify an external processor to accurately read the calculation result;
[0030] Before or when the fourth clock signal arrives, the mean filtering module exits enabling and waits for the mean calculation of the next shifted and expanded real value output by the digital quantity to real dimension conversion module.
[0031] In another aspect, the present invention further provides a rapid measurement device for analog electrical signals, comprising:
[0032] ADC is used to convert analog input signals into digital signals and generate 0~2 N The digital signal, N is the number of digital bits of ADC;
[0033] A conditioning circuit receives the collected analog electrical signal and performs range adjustment to adjust it to the analog signal input interval specified by the ADC, and outputs it to the ADC;
[0034] FPGA, which includes:
[0035] An ADC digital quantity reading module, which reads the digital quantity signal output by the ADC;
[0036] A median filter module, which has m N-bit registers for storing m historical data closest to the current time; the median filter module receives the digital signal output by the ADC digital quantity reading module, and takes the median from the currently received digital signal and the m historical data stored in the register as the current data output; updates the historical data in the m registers for median calculation in the next sampling period; wherein m≥2;
[0037] The module for converting digital quantity to real dimension determines the binary conversion coefficient K according to the corresponding relationship between the real analog electrical signal and the digital signal; after K is shifted left by M bits and rounded, it is multiplied by the current data output by the median filter module to generate the real value after 2N bit shift expansion; where the value of M is the maximum digital value output by ADC × K × [2 M ] The number of digits after the digit does not exceed the maximum value when 2N; [ ] is the rounding symbol;
[0038] A mean filter module receives the real value after the shift expansion, sums four consecutive real values after the shift expansion, right-shifts them by two bits, and generates a conversion result output;
[0039] A processor receives the conversion result output by the mean filter module and right-shifts it by M bits to obtain the real value of the analog electrical signal.
[0040] Compared with the prior art, the advantages and positive effects of the present invention are mainly reflected in:
[0041] 1. The present invention adopts ADC+FPGA+processor to construct a rapid measurement device for analog electrical signals, uses ADC to convert the collected analog electrical signals into digital signals, uses FPGA to perform median filtering, average filtering and true value calculation on the converted digital signals, and outputs the measurement results to the processor for direct use, thereby reducing excessive consumption of processor resources, allowing the processor to have enough time to execute other logic processing, control algorithms, given calculations and other tasks, thereby ensuring the smooth implementation of other functions.
[0042] 2. The present invention uses FPGA to complete the calculation from digital quantity to real value. The whole process only needs a few clock cycles. Compared with the existing method of completing the whole process in the processor, the calculation time can be shortened by several times or even dozens of times (for example, it can be shortened from 975ns to 90ns or even 50ns), which greatly improves the measurement speed of analog electrical signals and can fully meet the measurement requirements of high-end electronic products with sampling rates of up to 500KHz or above for analog electrical signals.
[0043] 3. In the process of converting digital quantity to real value dimension, the present invention adopts the shift expansion method to shift the decimal to the left and enlarge it when the conversion coefficient is a decimal, and retains as many parameters after the decimal point as possible. This can not only reduce the precision loss of the calculation result and ensure the accuracy of the measurement result, but also solve the problem of difficulty in FPGA decimal multiplication operation, which can greatly shorten the operation time and improve the conversion efficiency.
[0044] After reading the specific embodiments of the present invention in conjunction with the accompanying drawings, other features and advantages of the present invention will become more clear. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0046] Figure 1 It is a circuit principle block diagram of an embodiment of the rapid measurement device for analog electrical signals proposed by the present invention;
[0047] Figure 2 It is a circuit principle block diagram of another embodiment of the rapid measurement device for analog electrical signals proposed by the present invention;
[0048] Figure 3 This is the communication timing diagram between the ADC digital quantity reading module and the ADC chip;
[0049] Figure 4 It is the median filter timing diagram;
[0050] Figure 5 It is a timing diagram of converting digital quantity to real value dimension;
[0051] Figure 6 This is the mean filter timing diagram. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] In the description of the present invention, it should be noted that the terms "first" and "second" are used only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features.
[0054] In the description of the present invention, unless otherwise specified, "plurality" means two or more.
[0055] This embodiment proposes a fast measurement method for analog electrical signals, which mainly includes the following processes:
[0056] (1) Adjust the range of the collected analog electrical signal;
[0057] The range adjustment here is the analog quantity adjustment process, and its goal is to adjust the collected analog electrical signal to the analog signal input range specified by the analog-to-digital converter ADC (or ADC chip) to meet the ADC's range requirements for the analog input signal.
[0058] (2) Use ADC to perform analog-to-digital conversion on the input signal to generate a digital signal;
[0059] Here, for an ADC with a digital quantity of N bits, the analog input signal can be converted to generate 0~2 N digital signal for subsequent calculations.
[0060] (3) Use a field programmable gate array (FPGA) to configure multiple different functional modules to perform median filtering, true value calculation, and average value filtering on the digital signal output by the ADC to generate measurement results.
[0061] In some embodiments, FPGA can be used to configure an ADC digital quantity reading module, a median filtering module, a digital quantity conversion to real dimension module, and a mean filtering module.
[0062] The ADC digital quantity reading module is used to read the digital quantity signal output by the ADC and send it to the median filtering module.
[0063] The median filter module is used to receive the digital quantity signal output by the ADC digital quantity reading module and perform median calculation. The median filter module can be configured with m N-bit registers to store the m historical data closest to the current time, where m≥2. When performing median calculation, the median filter module can generate the calculation result by taking the median from the currently received digital quantity signal and the m historical data stored in the register, and output it as the current data. Then, the historical data in its m registers is updated for the median calculation of the next sampling period.
[0064] The digital quantity to real dimension module is used to determine the binary conversion coefficient K according to the corresponding relationship between the real analog electrical signal and the digital signal; then, K is shifted left by M bits and rounded, and multiplied by the current data output by the median filter module to generate the real value after 2N bit shift expansion. The value of M is the maximum digital value output by the ADC × K × [2 M ] The number of digits after ] does not exceed the maximum value under 2N; [ ] is the rounding symbol.
[0065] The mean filter module is used to receive the real value after the shift expansion, and after summing four consecutive real values after the shift expansion, right shift two bits to generate the conversion result output.
[0066] By right shifting the conversion result output by the mean filter module by M bits, the true value of the analog electrical signal can be obtained.
[0067] Based on the above measurement method, this embodiment designs a fast measurement device for analog electrical signals, such as Figure 1 As shown, it mainly includes conditioning circuit, analog-to-digital converter ADC, field programmable gate array FPGA and processor.
[0068] Among them, the conditioning circuit is used for range conversion between analog signals, that is, according to the range of the analog electrical signal to be collected (0~V) and the analog signal input range (0~A) specified by the ADC, the first conversion coefficient K1 is determined to adjust the actually collected analog electrical signal to the range of 0~A, thereby meeting the ADC's reception requirements for the analog input signal.
[0069] The analog-to-digital converter (ADC) is used to convert the received analog signal into a digital signal. The converted value is different depending on the number of digits of the ADC. Specifically, if the number of digits of the ADC is N, then the digital value range corresponding to the analog signal input range 0~A is 0~2. N .
[0070] For example, the analog electrical signal to be collected is a voltage signal of 0~600V, the interface voltage range of ADC is between 0~2.5V, and an ADC chip with a digital quantity bit number of 16 bits (i.e., N=16) is selected, and its digital quantity interval is 0~65535. In this way, according to the corresponding relationship between the analog quantity 0~2.5V and the digital quantity 0~65535, the conversion coefficient K2=65535 / 2.5 between the analog quantity input of ADC and the digital quantity output can be determined. For the consideration of the bias of subsequent operations and the convenience of rounding calculation, this embodiment does not use up all 65535, but only uses the digital quantity interval of 0~60000, so the analog signal input interval of the corresponding ADC is 0~2.28885V. In this way, according to the voltage signal interval 0~600V to be collected and the analog signal input interval 0~2.28885V of ADC, the conversion coefficient K1=2.28885 / 600 can be determined.
[0071] In this way, in actual use, if the sampling voltage received by the conditioning circuit is Vreal, it can be converted into an analog input signal Vin=Vreal×K1≤2.28885V suitable for ADC reception after filtering and multiplying it by the conversion coefficient K1. The ADC multiplies the received analog input signal Vin by the conversion coefficient K2 to obtain a digital signal D=Vin×K2≤60000 corresponding to the analog input signal Vin.
[0072] Therefore, for analog voltage signals with a range of 0~600V, the conversion coefficient between digital quantity and real value is K=1 / (K1×K2)=0.01. When converting digital quantity to real dimension, just multiply the processed digital quantity by the conversion coefficient K to get the real value. For example, the real value corresponding to the digital quantity 50000 is 50000×0.01=500V.
[0073] For analog electrical signals of other ranges, the conversion coefficient K between the digital quantity and the real value can be determined by referring to the above method, so as to be used for the calculation of converting the digital quantity to the real dimension in the subsequent process.
[0074] In order to improve the data processing speed, this embodiment uses FPGA to construct a functional module to perform median filtering, average filtering and real value conversion on the digital signal converted and output by the ADC. Figure 1As shown in the figure, the specific designs include ADC digital quantity reading module, median filter module, digital quantity to real dimension module, mean filter module, etc. FPGA, as the carrier of these functional modules, can use Verilog hardware description language to describe the timing and logic of each module, and realize the driving and data interaction of peripheral devices.
[0075] Specifically, the ADC digital quantity reading module is used to communicate with the ADC, for example, to connect to the digital quantity output interface of the ADC through the SPI bus to read the digital quantity signal converted and output by the ADC.
[0076] In some embodiments, the ADC digital quantity reading module may be designed according to the timing logic of the ADC to control the ADC to perform analog-to-digital conversion and read the converted digital quantity.
[0077] Specifically, the clock signal SCLK of the ADC digital quantity reading module can be configured to be synchronized with the ADC, such as Figure 3 As shown in the figure, under the control of FPGA, the chip select signal CS is pulled low to take effect. After the chip select signal CS takes effect, the first N clock signals wait for the ADC to perform analog-to-digital conversion, and the last N clock signals read the N-bit digital quantity signal output by the ADC. In other words, the data reading cycle of the ADC digital quantity reading module is 2N clock signals.
[0078] Take a 16-bit ADC chip as an example. When the chip select signal CS is pulled low to take effect, the falling edge of the first 16 clock signals is the ADC performing analog-to-digital conversion. From the falling edge of the 17th clock to the falling edge of the 32nd clock is the digital output clock. A total of 16 clocks correspond to 16 bits of digital quantity. After receiving, the FPGA pulls the chip select signal CS high and sets it to an invalid state.
[0079] At the same time, after receiving the N-bit digital signal, the ADC digital quantity reading module controls the subsequent median filter module to be enabled, for example, by pulling up the enable signal EN1 of the median filter module.
[0080] In this embodiment, m N-bit registers are set in the median filter module to store the m historical data D closest to the current time t. t-1 , D t-2 ,……,D t-m . Where m ≥ 2, that is, the median is taken from at least three digital quantities.
[0081] like Figure 4 As shown, after the enable signal EN1 of the median filter module is pulled high and enabled, the rising edge of the first clock signal CLK receives the digital signal D output by the ADC digital reading module. tThe median filtering completion signal Done1 is latched and set to an invalid state at the same time, for example, the potential of the median filtering completion signal Done1 is pulled low.
[0082] Afterwards, when the rising edge of the second clock signal CLK arrives, the m+1 digital signals D t , D t-1 , D t-2 ,……,D t-m Compare and take the median as the current data, and output it through the output port OUT1 of the median filter module. Specifically, if m+1 is an odd number, a digital signal with a middle value is selected as the current data output; if m+1 is an even number, the average of the two digital signals with middle values is used as the current data output. At the same time, using D t , D t-1 ,……,D t-m+1 Update the historical data in the m registers for median calculation in the next sampling period.
[0083] Taking m=2 as an example, two registers are configured in the median filter module to store the digital signal D at time t-1 and time t-2 respectively. t-1 , D t-2 When the rising edge of the second clock signal CLK arrives, the three digital signals D t , D t-1 , D t-2 The median is taken as the current data and output through the output interface OUT1 of the median filter module. t , D t-1 Save to two registers to update the historical data in the registers.
[0084] When the rising edge of the third clock signal CLK arrives, the median filtering completion signal Done1 is set to a valid state. For example, the potential of the median filtering completion signal Done1 is pulled high to serve as the enable signal EN2 of the subsequent digital quantity to real dimension module to control the enablement of the digital quantity to real dimension module.
[0085] Afterwards, for example, before or when the fourth clock signal CLK arrives, the enable signal EN1 is set to an invalid state, for example, the potential of the enable signal EN1 is pulled low, and the ADC digital quantity reading module is waited for to read the next digital quantity signal, and then its enable is controlled again.
[0086] In the module of converting digital quantity to real dimension, the conversion between digital quantity and real value dimension is realized by KB calculation method. For example, for some electronic loads, the analog voltage signal outputted by them is divided into three ranges, from low to high, 150V, 600V, and 1200V, and the corresponding digital quantity is 60000 (here, 65535 is not used up in full, in order to reserve a part of the digits for bias and facilitate rounding calculation). Then, the three ranges need to use the digital quantity and 0.0025, 0.01 and 0.02 to realize the conversion of real value dimension. Here, 0.0025, 0.01 and 0.02 are the conversion coefficients K. For example, at high voltage, if the measured digital quantity is 31500, the corresponding real value is 31500*0.02=630V.
[0087] Since the conversion coefficient K is a decimal, floating-point operations can be performed directly in MCU or DSP. However, in FPGA, due to its special hardware structure, it is not suitable for direct floating-point operations. Therefore, this embodiment proposes a shift expansion method to enlarge the floating-point parameters to retain as many digits after the decimal point as possible and reduce the accuracy loss of the calculation results.
[0088] Specifically, according to the number of digital bits N of the ADC, the number of bits after expansion is determined to be 2N, and the conversion coefficient K is shifted left by M bits to obtain K×2 M . A binary left shift represents multiplication by 2 to the power of x, and a left shift of 1 bit represents multiplication by 2 1 , shifting left two places means multiplying by 2 2 , left shift M bits represents multiplication by 2 M Here, the value of M can be set to the maximum digital value output by ADC × K × [2 M ] after the digital quantity does not exceed the maximum value of 2N, where [ ] is the integer symbol. In this way, when converting digital quantity to real value, the digital quantity output by the median filter module × K × [2 M ], it can be expanded [2 M ] times the real value. Shift the calculation result right by M bits to get the real value. This shift expansion method can avoid FPGA from performing decimal multiplication operations, which not only simplifies the calculation difficulty and improves the calculation efficiency, but also controls the precision loss to 0.2%, ensuring the accuracy of the calculation results.
[0089] For example, the three voltage ranges mentioned above can be converted by shifting the corresponding three conversion coefficients 0.0025, 0.01 and 0.02 left by 24, 22 and 21 bits in binary mode, respectively, to obtain:
[0090] Low gear: 0.0025×2 24 =41943.04;
[0091] Mid-range: 0.01×2 22 =41943.04;
[0092] High: 0.02×2 21 =41943.04.
[0093] After the shifted binary number is rounded, multiplying it by the maximum value of the digital value output by the ADC, 60000, the result does not exceed 32 bits. Multiplying the digital value output by the median filter module by 41943, the amplified value [2 24 ] times or [2 22 ] times or [2 21 ] times the true value.
[0094] The above shift expansion method is used to convert digital quantity to real value. The timing can be seen in Figure 5 As shown. In this embodiment, the clock signal of the digital quantity to real dimension module is synchronized with the median filter module. When the potential of the enable signal EN2 is pulled high, when the rising edge of the first clock signal CLK arrives, the digital quantity signal output by the median filter module is received and latched, and the dimension conversion completion signal Done2 is set to an invalid state, for example, the potential of the dimension conversion completion signal Done2 is pulled low.
[0095] Afterwards, when the rising edge of the second clock signal CLK arrives, the above-mentioned shift expansion method is used to convert the digital quantity to the real value, and the amplified real value is output through the output port OUT2 of the digital quantity to real dimension module.
[0096] When the third clock signal CLK arrives, the dimension conversion completion signal Done2 is set to a valid state, for example, the potential of the dimension conversion completion signal Done2 is pulled high, which serves as an enable signal EN3 of the subsequent mean filter module to control the enablement of the mean filter module.
[0097] Afterwards, for example, before or when the fourth clock signal CLK arrives, the enable signal EN2 is set to an invalid state, for example, the potential of the enable signal EN2 is pulled low, and the median filter module is enabled again after completing the median calculation of the next group of digital signals.
[0098] The mean filter module is used to receive the shifted and expanded real value output by the digital quantity to real dimension module, and sum four consecutive shifted and expanded real values, and then right shift them by two bits to generate a conversion result output.
[0099] A binary right shift represents division by 2 to the power of x, and a right shift of 1 bit represents division by 2 1 , shifting right two places represents division by 2 2The mean filter module of this embodiment sums the four shifted and expanded real values and then right shifts two bits, that is, sums the four shifted and expanded real values and divides them by 4, thereby completing the division operation in a shifting manner to obtain the average value.
[0100] Figure 6 This is a working timing diagram of the mean filter module. In this embodiment, the clock signal of the mean filter module is synchronized with the digital quantity to real dimension module. When the potential of its enable signal EN3 is pulled high, when the rising edge of the first clock signal CLK arrives, the digital quantity signal output by the digital quantity to real dimension module is received and latched, and at the same time, the median filter completion signal Done3 is set to an invalid state, for example, the potential of the median filter completion signal Done3 is pulled low.
[0101] Afterwards, when the rising edge of the second clock signal CLK arrives, the currently received digital quantity and the three digital quantities before the current moment are averaged, and after the mean is obtained, the conversion result is output through the output port OUT3 of the mean filter module.
[0102] When the third clock signal CLK arrives, the mean filter completion signal Done3 is set to a valid state, for example, the potential of the mean filter completion signal Done3 is pulled high and output to the processor connected to the FPGA to control the processor to receive the conversion result output by the mean filter module.
[0103] Afterwards, for example, before or when the fourth clock signal CLK arrives, the enable signal EN3 is set to an invalid state, for example, the potential of the enable signal EN3 is pulled low, and after the digital quantity to real dimension module generates the next shifted and expanded real value, it is re-enabled.
[0104] In this embodiment, the processor can select an MCU or a DSP to connect to the FPGA, and receive the digital quantity conversion result output by the FPGA for the output of the sampled value or the realization of other functions. If the sampled value needs to be output, for example, when the line voltage value or the line current value is output, the MCU or the DSP can right-shift the digital quantity conversion result output by the FPGA by M bits to obtain the real value, and then drive the display unit to display it. If it is used to realize other functions, the digital quantity conversion result output by the FPGA can be directly used without conversion, so as to reduce the resource consumption of the MCU or the DSP.
[0105] In this embodiment, on the FPGA platform, three algorithms including median filtering, real value calculation and mean filtering are described by hardware description language, and the completion signal of the previous module is configured as the enable signal of the next module, so that the three functional modules can run automatically and orderly to complete the calculation from digital quantity to the final real value dimension. The entire calculation process can be completed within a few clock cycles, which not only reduces the time consumed by the calculation, but also reduces the resource consumption of MCU and DSP.
[0106] The analog electrical signal rapid measurement technology of this embodiment is applied to the field of electronic loads. When converting analog voltage signals and current signals collected and output by the electronic loads into real values, two sets of parallel conversion circuits can be set in the FPGA, such as Figure 2 As shown, a voltage signal conditioning circuit, a current signal conditioning circuit and a dual-interface ADC chip (or two single-interface ADC chips) are configured to achieve synchronous measurement of analog voltage signals and current signals.
[0107] Specifically, the analog voltage signal collected and output by the electronic load is transmitted to the voltage signal conditioning circuit. After the analog range conversion is performed, a voltage signal that meets the ADC interface voltage requirement is generated and transmitted to one of the ADC input interfaces. After the ADC performs analog-to-digital conversion, a voltage digital quantity is generated and output to the FPGA.
[0108] Similarly, the analog current signal collected and output by the electronic load is transmitted to the current signal conditioning circuit. After the analog range conversion is performed, a voltage signal or current signal that meets the ADC interface voltage requirement or interface current requirement is generated and transmitted to another input interface of the ADC. After the ADC performs analog-to-digital conversion, the current digital quantity is generated and output to the FPGA.
[0109] FPGA controls the ADC digital quantity reading module to enable through the chip select signal CS. In the first N clock signals SCLK, it waits for the ADC to perform analog-to-digital conversion. In the last N clock signals SCLK, it reads the N-bit digital quantity voltage signal SDO_A and the N-bit digital quantity current signal SDO_B output by the ADC. Figure 3 After receiving, the FPGA sets the chip selection signal CS to an invalid state, and controls the first median filter module and the second median filter module to be enabled.
[0110] After the first median filter module is enabled, the received digital voltage signal is median-calculated and the calculation result is output. At the same time, the level state of the median filter completion signal Done1 is configured accordingly according to the data processing process, and the median filter completion signal Done1 is used as the enable signal of the first digital quantity to real dimension module of its subsequent stage, and the first digital quantity to real dimension module is controlled to automatically enter the enable state after the first median filter module completes the median calculation and outputs the calculation result.
[0111] After the first digital quantity to real dimension module is enabled, the calculation result output by the first median filter module is converted into a dimension to generate a real value output after the shift and expansion. At the same time, the level state of the dimension conversion completion signal Done2 is configured accordingly according to the data processing process, and the dimension conversion completion signal Done2 is used as the enable signal of the first mean filter module at its subsequent stage, and the first mean filter module is controlled to automatically enter the enable state after the first digital quantity to real dimension module outputs the real value after the shift and expansion.
[0112] After the first mean filter module is enabled, the mean value is calculated for the real value after the shift and expansion output by the first digital quantity to real dimension conversion module, and the calculation result is generated and output to the MCU or DSP.
[0113] Similarly, after the second median filter module is enabled, the median calculation is performed on the received digital current signal, and the calculation result is output to the second digital quantity to real dimension module for real value conversion, and then output to the second mean filter module to obtain the average value, and the calculation result is generated and output to the MCU or DSP.
[0114] The MCU or DSP can directly apply the received shifted and expanded voltage value or current value to the calculation process or control logic designed to realize other functions, or it can right shift M bits to generate the final voltage true value and current true value, and then output them through the display unit for personnel to view.
[0115] Since the main conversion process of analog electrical signals is completed in FPGA, the problem of MCU or DSP resource shortage caused by using MCU or DSP to measure voltage and current and calculate true values at a frequency of 500K in the field of electronic load technology is solved.
[0116] Of course, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the above embodiments, it is still possible for a person skilled in the art to modify the technical solutions described in the above embodiments, or to replace some of the technical features therein by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions claimed to be protected by the present invention.
Claims
1. A method for rapid measurement of analog electrical signals, characterized in that: include: Adjust the range of the collected analog electrical signal to the analog signal input range specified by the ADC; Use ADC to convert the input signal into digital form and generate 0~2 N The digital signal, N is the number of digital bits of ADC; Use FPGA to configure ADC digital quantity reading module, median filter module, digital quantity conversion to real dimension module and mean filter module; among them, The clock signal of the ADC digital quantity reading module is synchronized with the ADC, and the data reading cycle of the ADC digital quantity reading module is configured to be 2N clock signals, the first N clock signals wait for the ADC to perform analog-to-digital conversion, and the last N clock signals read the N-bit digital quantity signal output by the ADC, and after receiving the N-bit digital quantity signal, control the median filter module to be enabled; The median filter module has m N-bit registers for storing m historical data closest to the current time; when the first clock signal of the median filter module in the enabled state arrives, the digital quantity signal output by the ADC digital quantity reading module is latched, and the median filter completion signal is set to an invalid state; when the second clock signal arrives, the median is taken from the currently received digital quantity signal and the m historical data stored in the register as the current data output; the historical data in the m registers are updated for the median calculation of the next sampling cycle; wherein m≥2; when the third clock signal arrives, the median filter completion signal is set to a valid state to control the digital quantity conversion to real dimension module to be enabled; before or when the fourth clock signal arrives, the median filter module exits the enable state; When the first clock signal of the digital quantity to real dimension module in the enabled state arrives, the calculation result output by the median filter module is latched, and the dimension conversion completion signal is set to an invalid state; when the second clock signal arrives, the binary conversion coefficient K is determined according to the corresponding relationship between the real analog electrical signal and the digital signal; K is shifted left by M bits and rounded, and then multiplied by the current data output by the median filter module to generate a real value after 2N bit shift expansion; wherein the value of M is the maximum value of the digital quantity output by the ADC × K × [2 M ] after the digital quantity does not exceed the maximum value under the condition of 2N; [] is the integer symbol; when the third clock signal arrives, the dimension conversion completion signal is set to a valid state, and the mean filter module is controlled to be enabled; before or when the fourth clock signal arrives, the digital quantity to real dimension module exits the enablement; When the first clock signal arrives when the mean filter module is in the enabled state, the real value after the shift and expansion output by the digital quantity to real dimension module is latched, and the mean filter completion signal is set to an invalid state; when the second clock signal arrives, the real value after the shift and expansion is received, and after summing four consecutive real values after the shift and expansion, it is shifted right by two bits to generate a conversion result output; the conversion result is shifted right by M bits to obtain the real value of the analog electrical signal; when the third clock signal arrives, the mean filter completion signal is set to a valid state and output; before or when the fourth clock signal arrives, the mean filter module exits enabling.
2. A rapid measurement device for analog electrical signals, characterized in that: include: ADC is used to convert analog input signals into digital signals and generate 0~2 N The digital signal, N is the number of digital bits of ADC; A conditioning circuit receives the collected analog electrical signal and performs range adjustment to adjust it to the analog signal input interval specified by the ADC, and outputs it to the ADC; FPGA, which includes an ADC digital quantity reading module, a median filter module, a digital quantity conversion real dimension module and a mean filter module; wherein, The clock signal of the ADC digital quantity reading module is synchronized with the ADC, and the data reading cycle of the ADC digital quantity reading module is configured to be 2N clock signals, the first N clock signals wait for the ADC to perform analog-to-digital conversion, and the last N clock signals read the N-bit digital quantity signal output by the ADC, and after receiving the N-bit digital quantity signal, control the median filter module to be enabled; The median filter module has m N-bit registers for storing m historical data closest to the current time; when the first clock signal of the median filter module in the enabled state arrives, the digital quantity signal output by the ADC digital quantity reading module is latched, and the median filter completion signal is set to an invalid state; when the second clock signal arrives, the median is taken from the currently received digital quantity signal and the m historical data stored in the register as the current data output; the historical data in the m registers are updated for the median calculation of the next sampling cycle; wherein m≥2; when the third clock signal arrives, the median filter completion signal is set to a valid state to control the digital quantity conversion to real dimension module to be enabled; before or when the fourth clock signal arrives, the median filter module exits the enable state; When the first clock signal of the digital quantity to real dimension module in the enabled state arrives, the calculation result output by the median filter module is latched, and the dimension conversion completion signal is set to an invalid state; when the second clock signal arrives, the binary conversion coefficient K is determined according to the corresponding relationship between the real analog electrical signal and the digital signal; K is shifted left by M bits and rounded, and then multiplied by the current data output by the median filter module to generate a real value after 2N bit shift expansion; wherein the value of M is the maximum value of the digital quantity output by the ADC × K × [2 M ] after the digital quantity does not exceed the maximum value under the condition of 2N; [] is the integer symbol; when the third clock signal arrives, the dimension conversion completion signal is set to a valid state, and the mean filter module is controlled to be enabled; before or when the fourth clock signal arrives, the digital quantity to real dimension module exits the enablement; When the first clock signal of the mean filter module in the enabled state arrives, the real value after the shift and expansion output by the digital quantity to real dimension module is latched, and the mean filter completion signal is set to an invalid state; when the second clock signal arrives, the real value after the shift and expansion is received, and four consecutive real values after the shift and expansion are summed, and then shifted right by two bits to generate a conversion result output; the conversion result is shifted right by M bits to obtain the real value of the analog electrical signal; when the third clock signal arrives, the mean filter completion signal is set to a valid state and output; before or when the fourth clock signal arrives, the mean filter module exits the enable state; A processor receives the conversion result output by the mean filter module and right-shifts it by M bits to obtain the real value of the analog electrical signal.
Citation Information
Patent Citations
Low power consumption optimization method of decimal multiplier in integrated circuit system
CN102314215A
Softmax implementation method based on hardware platforms
CN108021537A
