Disclosure of Invention
In order to solve the defects of the prior art, the invention provides a small signal processing method for controlling a power amplifier, which can solve the problem of PWM output jump caused by abnormal fluctuation of signals generated by environmental noise and ADC quantization error when an analog sine small signal with smaller external amplitude and lower signal-to-noise ratio is input, thereby ensuring stable output of PWM signals, enabling the control signal of the power amplifier to be more stable, improving the driving performance of equipment and prolonging the service life of the equipment. The specific technical scheme of the invention is as follows:
a small signal processing method for power amplifier control, comprising the steps of:
s1: sampling the externally input continuous sine wave small signal by adopting a high-precision ADC, quantizing the continuous sine wave small signal into a digital sine wave signal, and inputting the digital sine wave signal into a processor;
s2: intercepting the digital sine wave signal obtained in the step S1, solving a signal variance, adaptively adjusting the window length of a Hample filter according to the signal variance, and carrying out Hample filtering treatment on the intercepted digital sine wave signal;
s3: performing discrete autocorrelation operation on the signal filtered in the step S2 to obtain a discrete autocorrelation sequence;
s4: performing FFT operation on the discrete autocorrelation sequence obtained in the step S3, and calculating the frequency of the autocorrelation sequence; the frequency of the autocorrelation sequence is the frequency of the input sine wave signal in the step S1, the discrete sine wave signal sequence with fixed sampling rate, frequency and amplitude is generated by the processor by utilizing the frequency of the obtained input sine wave signal, and the discrete sine wave signal sequence is retransmitted to the processor;
s5: generating triangular waves by using a ROM table, and then performing linear interpolation to ensure that the sampling rate of the triangular wave signals after interpolation is the same as that of the discrete sine signal sequences generated in the step S4, namely the quantization errors are the same;
s6: and (3) comparing the triangular wave signal processed in the step (S5) with the discrete sine sequence generated in the step (S4) by a comparator to generate a PWM signal P, and directly driving a power amplifier.
Further, the step S2 specifically includes:
s2-1: intercepting digital sine wave signal sequence X with length NN Is [ x ]0 ,x1 ,…,xi ,…,xN-1 ]Find signal XN Is a variance of (2);
s2-2: adaptive adjustment of Hample Filtering finger x based on variancei The number of surrounding samples k, where i=1, …, N, as shown in equation (1), determines a window length of l=2k+1, where,
wherein ,rounding down as a rounding function;
s2-3: select xi Surrounding sequence Y2k+1 Is [ x ]i-k ,xi-k+1 ,...,xi ,...,xi+k-1 ,xi+k ]Length l=2k+1, and sequence Y is determined2k+1 Median m of (2)i And absolute deviation sigmai As shown in the formula (2) (3):
mi =median(xi-k ,xi-k+1 ,…,xi ,…,xi+k-1 ,xi+k ) (2)
σi =1.4826·median(|xi-k -mi |,...,|xi+k -mi |) (3)
wherein media () represents a median sequence value;
s2-4: when sampling point xi The sampling point on the left or right is less than k, namely when the sampling point is at the head end or the tail end of the signal, the median m is calculated according to (4) and (5)i And absolute deviation sigmai :
S2-5: processing the selected x according to equation (6)i :
wherein ,nσ Is a specified multiple of the deviation.
Further, the step S4 specifically includes:
the autocorrelation sequence phi obtained in step S3 is checked by the IP of the FFT in the processorx (m) performing FFT operation, and then taking the frequency corresponding to the point with the highest amplitude in the frequency domain as the frequency of the input sine wave signal, as shown in the formulas (7) (8):
fsin =f(Yj =max(Y(k))) (8)
wherein ,Wn =e(-2πi)/n Y (k) is the amplitude corresponding to different frequency points after Fourier transformation, k is the frequency point sequence, fsin To be the required inputInto the frequency of the sinusoidal signal, Yj The frequency domain maximum amplitude value is j, the frequency point corresponding to the maximum amplitude value is j, and M is the length of the autocorrelation sequence;
using the obtained frequency f of the input sinusoidal signalsin Generating, by a processor, a sequence X of discrete sinusoidal signals of fixed sampling rate, frequency and amplitudesin And the discrete sine signal sequence is retransmitted to the processor through the serial port.
Further, the step S5 specifically includes:
s5-1: generating a sampling frequency f using ROM tables Peak-to-peak value of Vp-p Is a triangular wave signal of (2);
s5-2: let the frequency of the triangular wave to be generated be ftri Original adjacent two points xi and xi+1 Is required to be inserted betweenA p-th point, wherein the amplitude of the p-th point is xip ,
Guarantee triangular wave signal Xtri And sinusoidal signal Xsin The sampling rate of (a) is the same, i.e. the quantization error is the same.
The invention has the beneficial effects that:
1. compared with the Hample filter algorithm with the fixed-length window length, the Hample filter algorithm with the self-adaptive window length can still effectively delete peak outliers generated by environmental impact noise from signals under the condition of input sine wave frequency change without generating excessive smoothing.
2. According to the invention, the frequency is obtained by carrying out FFT (fast Fourier transform) on the autocorrelation sequence of the discrete signal after Hample filtering, and compared with the method for directly carrying out FFT on the discrete signal, the frequency measurement is more accurate. Meanwhile, the autocorrelation operation is adopted to replace the design of FIR, IIR and other digital filters, and the noise suppression is directly carried out in the time domain, so that the operation amount is reduced, the operation speed is improved, and the implementation is easier in the operation of the processing unit.
3. The invention uses a linear interpolation method to ensure that the sampling frequency of the triangular wave is the same as that of the sine wave, namely the quantization steps are the same, thereby avoiding abnormal jump of the PWM wave caused by quantization errors and ensuring the output stability of the PWM wave.
Detailed Description
In order that the above-recited objects, features and advantages of the present invention will be more clearly understood, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description. It should be noted that, without conflict, the embodiments of the present invention and features in the embodiments may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, however, the present invention may be practiced in other ways than those described herein, and therefore the scope of the present invention is not limited to the specific embodiments disclosed below.
As shown in fig. 5, a small signal processing method for power amplifier control includes the steps of:
s1: sampling the externally input continuous sine wave small signal by adopting a high-precision ADC, quantizing the continuous sine wave small signal into a digital sine wave signal, and inputting the digital sine wave signal into a processor;
s2: intercepting the digital sine wave signal obtained in the step S1, solving a signal variance, adaptively adjusting the window length of a Hample filter according to the signal variance, and carrying out Hample filtering treatment on the intercepted digital sine wave signal; the peak abnormality generated by random noise is filtered, the waveform is smoothed, and the signal to noise ratio is improved.
S3: performing discrete autocorrelation operation on the signal filtered in the step S2 to obtain a discrete autocorrelation sequence;
s4: performing FFT operation on the discrete autocorrelation sequence obtained in the step S3, and calculating the frequency of the autocorrelation sequence; the frequency of the autocorrelation sequence is the frequency of the input sine wave signal in the step S1, the discrete sine wave signal sequence with fixed sampling rate, frequency and amplitude is generated by the processor by utilizing the frequency of the obtained input sine wave signal, and the discrete sine wave signal sequence is retransmitted to the processor;
s5: generating triangular waves by using a ROM table, and then performing linear interpolation to ensure that the sampling rate of the triangular wave signals after interpolation is the same as that of the discrete sine signal sequences generated in the step S4, namely the quantization errors are the same;
s6: and (3) comparing the triangular wave signal processed in the step (S5) with the discrete sine sequence generated in the step (S4) by a comparator to generate a PWM signal P, and directly driving a power amplifier.
In some embodiments, step S2 is specifically:
s2-1: intercepting digital sine wave signal sequence X with length NN Is [ x ]0 ,x1 ,…,xi ,…,xN-1 ]Find signal XN Is a variance of (2);
s2-2: adaptive adjustment of Hample Filtering finger x based on variancei The number of surrounding samples k, where i=1, …, N, as shown in equation (1), determines a window length of l=2k+1, where,
wherein ,rounding down as a rounding function;
s2-3: select xi Surrounding sequence Y2k+1 Is [ x ]i-k ,xi-k+1 ,...,xi ,...,xi+k-1 ,xi+k ]Length l=2k+1, and sequence Y is determined2k+1 Median m of (2)i And absolute deviation sigmai As shown in the formula (2) (3):
mi =median(xi-k ,xi-k+1 ,…,xi ,…,xi+k-1 ,xi+k ) (2)
σi =1.4826·median(|xi-k -mi |,...,|xi+k -mi |) (3)
wherein media () represents a median sequence value;
s2-4: when sampling point xi The sampling point on the left or right is less than k, namely when the sampling point is at the head end or the tail end of the signal, the median m is calculated according to (4) and (5)i And absolute deviation sigmai :
S2-5: processing the selected x according to equation (6)i When the deviation is large, the median value is used instead of:
wherein ,nσ Is a specified multiple of the deviation.
Preferably, nσ Taken as 3.
The Hampel filter works in a similar manner to a median filter, but it replaces only the values corresponding to a few standard deviations away from the local median. The discrete sine wave signal is subjected to the Hample filtering processing by using the Hample filtering algorithm with the self-adaptive window length, so that peak abnormal values can be still effectively deleted from the signal under the condition of changing the frequency of the input sine wave, excessive smoothing phenomenon can not be generated, noise can be effectively reduced, the signal to noise ratio is improved, and preparation is made for the next step of signal autocorrelation operation.
In some embodiments, step S3 is specifically:
performing autocorrelation operation on the Hample filtered signal with the adaptive window length to obtain a discrete autocorrelation sequence phix (m) as shown in formula (7):
where m=0, 1,..n-1, since the discrete signal is a periodic signal, the autocorrelation signal is thus also a periodic signal of the same frequency. Because the correlation between the signal and the noise is different, the signal is strengthened after the autocorrelation is obtained, the noise is weakened, namely, the noise is inhibited to a certain extent, so that the signal-to-noise ratio can be increased, and the frequency measurement precision is improved. Meanwhile, the digital filters such as FIR and IIR are replaced, noise suppression is directly carried out in a time domain, the operation amount is reduced, and the operation speed is improved.
In some embodiments, step S4 is specifically:
the autocorrelation sequence phi obtained in step S3 is checked by the IP of the FFT in the processorx (m) performing FFT operation, and then taking the frequency corresponding to the point with the highest amplitude in the frequency domain as the frequency of the input sine wave signal, as shown in equations (8) (9):
fsin =f(Yj =max(Y(k))) (9)
wherein ,Wn =e(-2πi)/n Y (k) is the amplitude corresponding to different frequency points after Fourier transformation, k is the frequency point sequence, fsin For the frequency of the input sinusoidal signal, Yj The frequency domain maximum amplitude value is j, the frequency point corresponding to the maximum amplitude value is j, and M is the length of the autocorrelation sequence;
using the obtained frequency f of the input sinusoidal signalsin Generating, by a processor, a sequence X of discrete sinusoidal signals of fixed sampling rate, frequency and amplitudesin And the discrete sine signal sequence is retransmitted to the processor through the serial port.
In some embodiments, step S5 is specifically:
s5-1: generating a sampling frequency f using ROM tables Peak-to-peak value of Vp-p Is a triangular wave signal of (2);
s5-2: let the frequency of the triangular wave to be generated be ftri Original adjacent two points xi and xi+1 Is required to be inserted betweenA p-th point, wherein the amplitude of the p-th point is xip ,
Guarantee triangular wave signal Xtri And sinusoidal signal Xsin The sampling rate of (a) is the same, i.e. the quantization error is the same.
In some embodiments, step S6 is specifically:
the interpolated triangular wave signal Xtri And the sinusoidal signal X generated in step S4sin The signal is fed to a comparator, as shown in equation (11), which generates a PWM signal P to directly drive the power amplifier.
In summary, the invention provides a small signal processing method based on power amplifier control, which is characterized in that by carrying out Hample filtering and autocorrelation operation on an analog sine wave small signal with smaller amplitude and lower signal-to-noise ratio and carrying out Fast Fourier Transform (FFT) frequency measurement on the result of the autocorrelation operation, an ideal digital sine wave is generated and compared with a triangular wave generated by a built-in ROM, so that the signal-to-noise ratio of the sine wave is effectively improved, signal burrs are eliminated, the problem of PWM wave output jump caused by abnormal fluctuation of signal amplitude due to environmental noise and ADC quantization error when the analog sine wave small signal is input is solved, and the stable output of PWM signals is ensured, so that the control signal of the power amplifier is more stable and has better performance.
In order to facilitate understanding of the above technical solutions of the present invention, the following detailed description of the above technical solutions of the present invention is provided by specific embodiments.
Example 1
Simulation was performed using Matlab by adding gaussian white noise and spike noise to a single frequency sinusoidal signal to simulate an external input sine wave when the power amplifier is actually operating, as shown in fig. 1.
Fig. 2-4 show effective results obtained after the processing of the small signal processing method based on the control of the power amplifier according to the present invention.
From the processing results, the method of the invention can fundamentally improve the signal-to-noise ratio of the sine wave, eliminate burrs, solve the problem of PWM wave output jump caused by abnormal fluctuation of signals generated by environmental noise and ADC quantization error when the sine wave small signal with smaller amplitude and lower signal-to-noise ratio is input, and eliminate the influence of the environmental noise on the sine wave, thereby eliminating the abnormal jump of PWM in the comparison process and ensuring the stable output of PWM signals.
The analog sine wave small signal with smaller external input amplitude and lower signal-to-noise ratio is subjected to Hample filtering, autocorrelation operation and Fast Fourier Transform (FFT) frequency measurement processing, so that an ideal digital sine wave signal is generated, the problem that PWM wave output jumps due to abnormal fluctuation of signal amplitude generated by environmental noise and ADC quantization error when the analog sine wave small signal is input is solved, and stable output of the PWM signal is ensured, and the control signal of the power amplifier is more stable.
The above description is only of the preferred embodiments of the present invention and is not intended to limit the present invention, but various modifications and variations can be made to the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.