Amplifier Model with Varying Input Amplitude

15 次查看(过去 30 天)
Hello all
I was wondering if someone could help me with a problem I am trying to work out. I am trying to explore certain parameters of an RF amplifier by using Matlab to model certain behaviours so that I can then plan for certain parameters when it comes to designing the amplifier for real.
My current code (see below) has an input signal comprised of two tones that I am then passing through the Rapp model with two different values for the Osat parameter that I can then compare. I am then looking at the fft output by generating two fft plots of the different Osat values for comparison.
I now need to look at varying the amplitude of the input signal then build up a table for the fft magnitude of the output intermod products and fundamental level and so that I can look for when 1dB compression starts. I can then calculate the value of OIP3 which will be helpful for my eventual design.
The problem I have is that I am not sure what commands I need in order to have a varying input amplitude or how to build up a table and I can't seem to find a suitable way of doing this using the Matlab help files.
The following is the code I have so far based on the two tone input signal:
f1 = 200000; %input frequency 200kHz
f2 = 150000; %second tone frequency 150kHz
fs = 50*f1; %sampling frequency
Ta = 1/f1; %input frequency period
Ts = 1/fs; %sampling frequency period
t = (0:Ts:50000*Ta); %timing and step size
input = 1*cos(2*pi*f1*t + 0.5) + 1*cos(2*pi*f2*t + 1); %input signal
u = input; %magnitude value in RAPP model equation
s = 1; %smoothness factor
Osat1 = 0.5; %output saturation factor 1
Osat2 = 1.5; %output saturation factor 2
Fam1 = u./((1+(u./Osat1).^(2*s)).^(1/(2*s))); %RAPP model equation for Osat1
FAM1 = fft (Fam1); %fft of Fam1
X_mag1 = abs (FAM1); %returns absolute values without the complex part of FAM1 fft
binwidth = fs/length(FAM1); %converts x-axis to Hz
xaxis = 0:1:length(FAM1)-1; %converts x-axis to Hz
xaxis = xaxis * binwidth; %converts x-axis to Hz
%figure (10);
%plot(xaxis,X_mag1);
%hold on
Fam2 = u./((1+(u./Osat2).^(2*s)).^(1/(2*s))); %RAPP model equation for Osat2
FAM2 = fft (Fam2); %fft of Fam2
X_mag2 = abs (FAM2); %returns absolute values without the complex part of FAM2 fft
binwidth = fs/length(FAM2);
xaxis = 0:1:length(FAM2)-1;
xaxis = xaxis * binwidth;
%plot(xaxis,X_mag2);
subplot (2,1,1), plot(xaxis, X_mag1);
title('FFT Plot of Osat=0.5')
xlabel('Frequency (Hz)')
ylabel('Amplitude (dB)')
subplot (2,1,2), plot(xaxis, X_mag2);
title('FFT Plot of Osat=1.5')
xlabel('Frequency (Hz)')
ylabel('Amplitude (dB)')
I'm not sure I have managed to convert the axis to MHz correctly either as the plots show 1 to 10 with a 10^6 multiplier but I was trying to have it displayed in something more readable, say 100's of MHz instead.
I also seem to have a problem with converting the y-axis to dB's. Is it just a case of using 20log to change the units for this?
Any help with this would be greatly appreciated.
Regards
Dan

采纳的回答

Star Strider
Star Strider 2020-8-23
A relatively straightforward way to vary the amplitudes:
Amplitudes = logspace(-2, 2, 25); % Amplitude Vector: 1E-2 To 1E+2, 25 Values
u = inputsig(:)*Amplitudes; %magnitude value in RAPP model equation
This uses matrix-vector multiplication to create a (2.5E+6 x 25) double array oif amplitudes that go from 0.01 to 100. This version of the matrix makes it tractable for the fft function (so separately adding a dimension argument to it is not necessary), and the plot function automatically will get it correct. Depending on what you want, you can also use linspace instead of logspace if you want a different range.
I am not exactly certain what you are doing, other than you appear to be operating the amplifier as Class A (my knowledge of power amplifier design being limited).
  2 个评论
Daniel Clayton
Daniel Clayton 2020-8-25
Hi Star Strider
Thank you for your feedback on this. I see what you are saying here in terms of creating an array of amplitudes.
Where you have the u = inputsig (:)*Amplitudes, what is the (:) doing in this instance? Or are you using this for shorthand for my input equation?
Dan
Star Strider
Star Strider 2020-8-25
As always, my pleasure!
The (:) creates a column vector (regardless of the original orientation or size of the vector or matrix it refers to). Here, this creates the multiplication of ‘inputsig’ as a column vector and the ‘Amplitude’ row vector to create a matrix of the values of ‘inputsig’ as columns, each column multiplied by the appropriate element of ‘Amplitude’ to create the matrix. This is not element-wise multiplication, it is ‘classic’ vector-matrix multiplication.

请先登录,再进行评论。

更多回答(1 个)

Alan Stevens
Alan Stevens 2020-8-23
编辑:Alan Stevens 2020-8-23
To plot the x-axis in MHz:
plot(xaxis*10^-6, X_mag1);
For dB you need
20*log10(...
as log is base e, log10 is base 10.
I assume you want a "for" loop with Osat varying for your other point, e.g.
for Osat = 1:0.1:2
....
etc.
end
but I'm not clear as to what result you will store from each loop. Perhaps something like:
k = 0;
for Osat = 1:0.1:2
....
etc.
k = k+1;
store(k) = result;
end
has the required structure.
  1 个评论
Daniel Clayton
Daniel Clayton 2020-8-25
Hi Alan
Thank you for your feedback on this. The Osat values are part of the Rapp model of an amplifier behaviour which are used to compute the distortion of the amplitude of the input signal so in this case I would prefer to leave the two values the same to see the direct comparison between them.
I need to have a varying amplitude of the input signal so that I can then look for any intermodulation products in the displayed fft's and this way I can see if the intermods are worse for an Osat of 0.5 or for an Osat of 1.5. I can then also use this data to look for when the 1dB compression point occurs.
I think 'Star Strider' may have answered this for me but I just need to play around with the code. Thank you for responding to my question very quickly though.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by