Disclosure of Invention
The invention provides a frequency response curve correction method, which solves the defects of low frequency response curve correction efficiency and large error in the prior art, and realizes the quick and accurate correction of the frequency response curve of an initial waveform.
In order to achieve the above purpose, the present invention provides the following technical solutions:
in a first aspect, an embodiment of the present invention provides a method for correcting a frequency response curve, including:
acquiring an original frequency response curve of a circuit or a device to be measured;
calculating a correction frequency response curve according to the difference value between the amplitude mean value of the original frequency response curve and the amplitude of the original frequency response curve;
and obtaining correction parameters of the filter according to the correction frequency response curve and inputting the correction parameters into the filter, so that the filter corrects the original frequency response curve.
According to the method for correcting the frequency response curve provided by the invention, the method for acquiring the original frequency response curve of the circuit or the device to be measured comprises the following steps:
setting the number of frequency bands to be divided, dividing the acquisition bandwidth of the analog-to-digital conversion device at equal intervals according to the number of the frequency bands to be divided to obtain a series of frequency bands, and recording the frequency of each interval point as a series of frequencies to be measured;
and inputting signals with the same amplitude and the frequency of the series of to-be-measured frequencies into a circuit or a device to be measured, and respectively recording the amplitude of the output signals and corresponding frequency points as the original frequency response curve.
According to the frequency response curve correction method provided by the invention, a corrected frequency response curve is calculated according to the difference value between the amplitude mean value of the original frequency response curve and the amplitude of the original frequency response curve, and the method specifically comprises the following steps:
acquiring each frequency point and a corresponding amplitude value of an original frequency response curve, calculating an amplitude mean value, and obtaining a target frequency response curve by taking each frequency point as an abscissa and the amplitude mean value as an ordinate corresponding to each frequency point;
and calculating the amplitude difference value of the target frequency response curve and the original frequency response curve at each frequency point to be used as the amplitude value of the correction frequency response curve.
Obtaining correction parameters of the filter according to the correction frequency response curve and inputting the correction parameters into the filter, wherein the method specifically comprises the following steps:
transforming the correction frequency response curve to a time domain to obtain time domain data;
performing sequence transformation on the time domain data to obtain correction data;
and inputting the correction data into a filter as a correction parameter of the filter.
According to the method for correcting the frequency response curve provided by the invention, preferably, before each frequency point and the corresponding amplitude value of the original frequency response curve are obtained, the method further comprises:
and reserving amplitude values corresponding to the original frequency response curve on frequency points within the bandwidth range of the filter, and setting data amplitude values corresponding to the rest frequency points to zero.
According to the method for correcting the frequency response curve provided by the invention, preferably, the method for transforming the corrected frequency response curve into a time domain comprises the following steps:
and performing inverse fast Fourier transform on the corrected frequency response curve, and taking a modulus value of a transformation result as time domain data.
According to the frequency response curve correction method provided by the invention, preferably, the sequence transformation is performed on the time domain data, and the method specifically comprises the following steps:
dividing the time domain data into 2 groups averagely, and transforming according to the following rules:
if i is equal to or less than N/2, coff (i) =c (N/2-i);
if i > N/2, coff (i) =c (N+1-i+N/2);
wherein N is the number of the time domain data and N is an even number, i is all integers between 1 and N, coff is the data after the sequence transformation, and c is the time domain data.
In a second aspect, an embodiment of the present invention further provides a frequency response curve correction apparatus, including:
the acquisition module is used for acquiring an original frequency response curve of a circuit or a device to be measured;
the processing module is used for calculating a correction frequency response curve according to the difference value between the amplitude mean value of the original frequency response curve and the amplitude of the original frequency response curve;
and the correction module is used for obtaining correction parameters of the filter according to the correction frequency response curve and inputting the correction parameters into the filter so that the filter corrects the original frequency response curve.
In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the steps of the frequency response curve correction method according to the first aspect when the processor executes the program.
In a fourth aspect, embodiments of the present invention also provide a computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, implements the steps of the frequency response curve correction method according to the first aspect.
According to the technical scheme, according to the frequency response curve correction method provided by the invention, the corrected frequency response curve is calculated according to the difference value between the amplitude mean value of the original frequency response curve and the amplitude of the original frequency response curve, namely, the original frequency response curve is corrected based on the corrected frequency response curve representing the difference value between the amplitude mean value of the original frequency response curve and the amplitude of the original frequency response curve, and the obtained final frequency response curve is an approximately ideal frequency response curve. Compared with the prior art, the frequency response curve correction method provided by the invention has the beneficial effects that: the method has the advantages of easiness in implementation, rapidness and high efficiency, and the method is based on the nonlinear characteristic of the analog device to carry out self-correction of the output frequency response characteristic, can be well suitable for various analog electronic devices, and has good universality and high accuracy. In addition, the frequency response curve correction method can also correct different frequency points at the same time, and is more flexible compared with other correction methods which can only correct in a segmented way.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Fig. 1 is a flowchart of a frequency response curve correction method provided in this embodiment, as shown in fig. 1, including:
step S1, acquiring an original frequency response curve of a circuit or device to be measured.
And S2, calculating a correction frequency response curve according to the difference value between the amplitude mean value of the original frequency response curve and the amplitude of the original frequency response curve.
And S3, obtaining correction parameters of the filter according to the correction frequency response curve, inputting the correction parameters into the filter, and correcting the original frequency response curve by the filter.
According to the frequency response curve correction method provided by the embodiment, the correction frequency response curve is calculated according to the difference value between the amplitude mean value of the original frequency response curve and the amplitude of the original frequency response curve, namely, the correction frequency response curve based on the difference value between the amplitude mean value of the original frequency response curve and the amplitude of the original frequency response curve is used for correcting the original frequency response curve, and the obtained final frequency response curve is an approximately ideal frequency response curve. Compared with the prior art, the frequency response curve correction method provided by the invention has the advantages of easiness in implementation, rapidness and high efficiency, and can be well suitable for various different analog electronic devices because the method carries out self-correction on the output frequency response characteristic based on the nonlinear characteristic of the analog device, and has good universality and higher accuracy. In addition, the frequency response curve correction method can also correct different frequency points at the same time, and is more flexible compared with other correction methods which can only correct in a segmented way.
In step S1, an original frequency response curve of a circuit or a device to be measured is obtained, specifically, by setting the number of frequency bands to be divided, dividing the acquisition bandwidth of an analog-digital conversion device at equal intervals according to the number of frequency bands to be divided, so as to obtain a series of frequency bands, recording the frequency of each interval point as a series of frequencies to be measured, inputting signals with the same amplitude and frequency as the series of signals to be measured into the circuit or the device to be measured, and recording the amplitude of the output signals and corresponding frequency points as the original frequency response curve.
In one embodiment, the sampling rate of the ADC is set to Fs, the maximum bandwidth acquired by the ADC is 0 to Fs/2, and the bandwidth is equally divided into 256 parts.
Setting the sampling rate fs=250 MHz and the bandwidth to be 125M, the sampling interval is (125/256) M, that is, the signal amplitude collected by the ADC is measured and recorded once every interval (125/256) M, and finally, a frequency response curve of 256 points is drawn, as shown in fig. 2, the abscissa represents the frequency point number, the ordinate represents the amplitude, and the unit is dBm.
It should be noted that, in the process of measuring the frequency response curve of the original device, the input signal must be a series of signals with the same amplitude and different frequencies, so that the drawn original frequency response curve can accurately reflect different effects generated after the signals with different frequencies pass through the system due to the nonlinear characteristics of the analog device, so as to facilitate subsequent correction.
In step S2, a correction frequency response curve is calculated according to the original frequency response curve, specifically, an amplitude average value is calculated by firstly obtaining each frequency point and a corresponding amplitude value of the original frequency response curve, a target frequency response curve is obtained by each frequency point and the amplitude average value, and then an amplitude difference value between the target frequency response curve and the original frequency response curve at each frequency point is calculated, so as to obtain the amplitude value of the correction frequency response curve.
Optionally, a calibration band is selected before the calibration of the frequency response curve, so that the calibration band and the filter band are matched to avoid unnecessary computation. The method is realized by reserving amplitude values corresponding to an original frequency response curve on frequency points in the bandwidth range of the filter, and setting data amplitude values corresponding to other frequency points to zero.
In one embodiment, as shown in fig. 3, a bandwidth range calculated from the coefficient of a finite impulse response digital filter (Finite Impulse Response filter, abbreviated as FIR filter) is tried, and the amplitude value in the bandwidth range on the original frequency response curve is reserved, and the amplitude value of the rest frequency points is set to 0. The frequency range reserves the amplitude corresponding to the frequency points from the 20 th point to the 125 th point in the original frequency response curve, the amplitude values of the rest frequency points are set to be 0, and the obtained 256 sets of amplitude-frequency data are used as the frequency response curve after the calibration frequency range is selected.
And acquiring each frequency point and a corresponding amplitude value of the original frequency response curve, calculating an amplitude average value, taking each frequency point as an abscissa, taking the amplitude average value as an ordinate corresponding to each frequency point, and obtaining a target frequency response curve. The target frequency response curve has the same influence on the input signals with the same amplitude and different frequencies at each frequency point, namely the frequency response curve is an approximately ideal frequency response curve.
And calculating the amplitude difference value of the target frequency response curve and the original frequency response curve at each frequency point, in a specific implementation manner, subtracting the amplitude value of each frequency point in the target frequency response curve drawn in the steps and the frequency response curve after the calibration frequency band is selected, recording the difference value, and drawing each difference value data and the corresponding frequency point on a coordinate axis to obtain the corrected frequency response curve shown in fig. 5.
In step S3, the original frequency response curve is adjusted by using the correction frequency response curve to obtain a final frequency response curve, specifically, the correction frequency response curve is firstly transformed into a time domain to obtain time domain data, then the time domain data is subjected to sequence transformation to obtain correction data, and finally the correction data is input into a filter to be used as correction parameters of the filter.
The filter can correct the amplitude value on the frequency point according to the amplitude value of the input signal of the frequency point and the corresponding correction parameter, so that the amplitude value is close to a true value, and larger errors caused by the nonlinear influence of an analog device or an analog circuit are avoided.
Since in the actual signal processing process the filter needs to perform amplitude correction of the signal in the time domain, i.e. to process the input signal at a certain point in time, the corrected frequency response curve needs to be transformed into the time domain. The transformation may be implemented by various signal processing or mathematical calculation methods.
Alternatively, in one embodiment of the present invention, the 256 amplitude value data corresponding to each interval frequency point of the correction curve is subjected to IFFT using inverse fast fourier transform (Inverse Fast Fourier Transform, abbreviated as IFFT), to obtain 256 time domain data, as shown in fig. 6.
Since the data result obtained by the IFFT calculation is often complex, it includes both real and imaginary parts. Since the modulus of the complex signal reflects the amplitude information of the signal, in one embodiment of the present invention, the modulus of the IFFT-post-data is taken as time domain data for subsequent processing.
Since the frequency components will shift after the IFFT operation, the fourier transform for performing zero-crossing frequency translation needs to be rearranged back to the original transform output, and thus the time domain data needs to be subjected to sequence transformation, which specifically includes:
dividing the time domain data into 2 groups averagely, and transforming according to the following rules:
if i is equal to or less than N/2, coff (i) =c (N/2-i);
if i > N/2, coff (i) =c (N+1-i+N/2);
wherein N is the number of the time domain data and N is an even number, i is all integers between 1 and N, coff is the data after the sequence transformation, and c is the time domain data.
According to the above steps, in one embodiment of the present invention having 256 data points, the specific rules are:
dividing 256 sets of data into two sets, wherein the data from the 1 st point to the 128 th point is the first set, the data from the 129 th point to the 256 th point is the second set,
the first set of transformation formulas is:
coff(i)=c(129-i);
the second set of transformation formulas is:
coff(i)=c(257-i+128);
wherein i of the first group takes all integers from 1 to 128, i of the second group takes all integers from 129 to 256; coff is the data after the sequence transformation and c is the real part data. The result of the data after the sequence transformation is shown in fig. 7.
It should be noted that, the transformation result shown in fig. 7 is time domain data, and the frequency domain data after fourier transformation is a smooth flat curve close to the ideal frequency response curve.
After the correction data is obtained, the correction data is input into a filter to be used as the FIR coefficient of the filter. The filter can be designed directly according to the FIR coefficient, and the FIR coefficient can be used as a correction parameter of the filter, so that the filter can correspondingly adjust the amplitude value of the input signal by itself to obtain a final frequency response curve. The final frequency response curve is a flat curve which is close to the ideal frequency response curve.
In one embodiment of the present invention, after 256 correction data generated after the sequence transformation in the previous step are input as FIR coefficients to the filter, the filter adjusts the magnitudes of the 256 points on the basis of the original values according to the correction data, and finally the graph drawn by the adjusted 256 point values approximates to a flat curve. For example, the correction data of the 10 th point is 3, the amplitude value of the 10 th point is 20dBm, and the filter corrects the amplitude value of the 10 th point according to the correction data and the amplitude value input by the 10 th point. The amplitude value of the 10 th point after correction is very close to the average value, the amplitude values of other points are corrected in sequence according to the same rule, and the obtained amplitude values of all points are close to the average value, namely the whole frequency response curve is close to a flat curve.
It should be noted that, the correction result of the frequency response curve correction method provided by the invention, namely the generated final frequency response curve, is a flat and close to the ideal frequency response curve. In the whole implementation process, the original frequency response curve is flat and smooth due to the nonlinear characteristic of the analog device, the amplitude-frequency characteristic waveform of the signal is uneven and smooth, and occupies a large bandwidth, and the corrected frequency response curve obtained through a series of processing steps is close to the ideal frequency response curve, is flat and smooth, and cannot generate too much distortion on signals with different frequencies passing through the analog device, so that the problem that the amplitude of the acquired signal is inconsistent after the acquired signal is acquired through an analog circuit in the prior art can be well solved. In addition, the frequency response curve correction method can also correct different frequency points at the same time, and is more flexible compared with other correction methods which can only correct in a segmented way.
As shown in fig. 8, the present invention further provides a frequency response curve correction device, including:
an acquisition module 810 is configured to acquire an original frequency response curve of a circuit or device to be measured.
The processing module 820 is configured to calculate a corrected frequency response curve according to a difference between the average value of the amplitude of the original frequency response curve and the amplitude of the original frequency response curve.
And the correction module 830 is configured to obtain correction parameters of the filter according to the correction frequency response curve, and input the correction parameters into the filter, so that the filter corrects the original frequency response curve.
According to the frequency response curve correction device provided by the embodiment, the correction frequency response curve is calculated according to the difference value between the amplitude mean value of the original frequency response curve and the amplitude of the original frequency response curve, namely, the original frequency response curve is corrected based on the correction frequency response curve representing the difference value between the amplitude mean value of the original frequency response curve and the amplitude of the original frequency response curve, and the obtained final frequency response curve is an approximately ideal frequency response curve. Compared with the prior art, the frequency response curve correction method provided by the invention has the advantages of easiness in implementation, rapidness and high efficiency, and can be well suitable for various different analog electronic devices because the method carries out self-correction on the output frequency response characteristic based on the nonlinear characteristic of the analog device, and has good universality and higher accuracy. In addition, the frequency response curve correction method can also correct different frequency points at the same time, and is more flexible compared with other correction methods which can only correct in a segmented way.
Optionally, the acquiring module 810 includes:
the frequency band dividing module is used for setting the number of frequency bands to be divided, dividing the acquisition bandwidth of the analog-digital conversion device at equal intervals according to the number of the frequency bands to be divided to obtain a series of frequency bands, and recording the frequency of each interval point as a series of frequencies to be measured.
The original data recording module is used for inputting signals with the same amplitude and the frequency of the series of to-be-measured frequencies to the to-be-measured circuit or device, and respectively recording the amplitude of the output signals and corresponding frequency points to serve as the original frequency response curve.
Optionally, the processing module 820 includes:
the target amplitude calculation module is used for obtaining each frequency point of the original frequency response curve and the corresponding amplitude value, calculating an amplitude average value, and obtaining the target frequency response curve by taking each frequency point as an abscissa and taking the amplitude average value as an ordinate corresponding to each frequency point.
And the correction amplitude calculation module is used for calculating the amplitude difference value of the target frequency response curve and the original frequency response curve at each frequency point to be used as the amplitude value of the correction frequency response curve.
Optionally, the target amplitude calculation module includes:
the frequency band calibration module is used for reserving amplitude values corresponding to the original frequency response curve on frequency points in the bandwidth range of the filter before acquiring the frequency points and the corresponding amplitude values of the original frequency response curve, and the amplitude values corresponding to the other frequency points are set to be zero.
Optionally, the correction module 830 includes:
and the time domain data acquisition module is used for transforming the correction frequency response curve into a time domain to obtain time domain data.
And the correction data acquisition module is used for performing sequence transformation on the time domain data to obtain correction data.
And the input module is used for inputting the correction data into the filter as a correction parameter of the filter.
Optionally, the correction module 830 further includes:
and the inverse Fourier transform module is used for carrying out inverse fast Fourier transform on the corrected frequency response curve and taking the modulus value of the transformation result as time domain data.
The sequence transformation module is used for equally dividing the time domain data into 2 groups and transforming according to the following rules:
if i.ltoreq.N/2, coff (i) =c (N/2-i).
If i > N/2, coff (i) =c (N+1-i+N/2).
Wherein N is the number of the time domain data and N is an even number, i is all integers between 1 and N, coff is the data after the sequence transformation, and c is the time domain data.
Fig. 9 is a schematic diagram of an entity structure of an electronic device according to the present invention, as shown in fig. 9, the electronic device may include: a processor (processor) 910, a communication interface (communication interface) 920, a memory (memory) 930, and a communication bus (bus) 940, wherein the processor 910, the communication interface 920, and the memory 930 perform communication with each other through the communication bus 940. Processor 910 may invoke logic instructions in memory 930 to perform the frequency response curve correction method described above, including: acquiring an original frequency response curve of a circuit or a device to be measured; calculating a correction frequency response curve according to the difference value between the amplitude mean value of the original frequency response curve and the amplitude of the original frequency response curve; and obtaining correction parameters of the filter according to the correction frequency response curve and inputting the correction parameters into the filter, so that the filter corrects the original frequency response curve.
Further, the logic instructions in the memory 930 described above may be implemented in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as a stand-alone product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, embodiments of the present invention further provide a computer program product, including a computer program stored on a non-transitory computer readable storage medium, the computer program including program instructions which, when executed by a computer, enable the computer to perform the frequency response curve correction method provided in the above method embodiments, including: acquiring an original frequency response curve of a circuit or a device to be measured; calculating a correction frequency response curve according to the difference value between the amplitude mean value of the original frequency response curve and the amplitude of the original frequency response curve; and obtaining correction parameters of the filter according to the correction frequency response curve and inputting the correction parameters into the filter, so that the filter corrects the original frequency response curve.
In still another aspect, an embodiment of the present invention further provides a non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor is implemented to perform the above-provided frequency response curve correction methods, including: acquiring an original frequency response curve of a circuit or a device to be measured; calculating a correction frequency response curve according to the difference value between the amplitude mean value of the original frequency response curve and the amplitude of the original frequency response curve; and obtaining correction parameters of the filter according to the correction frequency response curve and inputting the correction parameters into the filter, so that the filter corrects the original frequency response curve.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.