# FSP-30 Spectrum Analyzer Simulator

In the last 3 years, there has been a rise in prices for measuring equipment. In particular, spectrum analyzers from Rohde & Schwarz have become practically unavailable. On the other hand, they are being replaced by Chinese analogues, which is also very good.

At the same time, spectrum analyzers of this company were widely distributed due to their adequate operation.

In fact, this equipment is still actively used, but it is not entirely advisable to waste its resources on teaching students how to use it. To solve this problem, a Rohde & Schwarz FSP-30 spectrum analyzer simulator was developed.

The most obvious approach is based on MATLAB or LabVIEW, but instead of manipulating the FSP-30 interface, there will be a MATLAB or LabVIEW interface. In addition, licenses for this software are very expensive, which makes it difficult to officially use. Therefore, I chose my own path – developing a simulator on my favorite Delphi.

The problem to be solved can be formulated as follows:

to develop a spectrum analyzer simulator with a frequency range of up to 30 GHz, repeating the Rohde & Schwarz FSP-30 interface, with adequate visual display depending on changes in parameters, allowing for the formation of tasks in the form of a set of signals and assessing the correctness of their measurement.

Why so complicated? Because a spectrum analyzer simulator without a set of measured signals is not needed, and the ability to evaluate the correctness of the settings during measurements allows for the simultaneous training of a large number of students.

Okay, away from the lyrics, closer to the code…

What we will measure…

A set of narrow-band modulated signals is proposed as the measured ones. For which it is possible to adjust the carrier oscillation frequency, amplitude, modulating signal frequency and a whole bunch of other things depending on the final application of this simulator…

For ease of signal identification, it is possible to turn them on and off using separate buttons (TEST 1 – TEST 5).

Now everything has become extremely clear and we can move on to forming an oscillogram and obtaining an amplitude spectrum using the fast Fourier transform.

At first, it was planned to solve the problem head-on – to honestly build all the signals, calculate the spectra and output the required part of the spectrum, but it turned out to be impossible. A modern PC with 8 GB of RAM refused to calculate the signal spectrum up to 30 GHz with the required resolution. Therefore, everything had to be simplified… Only one AMN signal was built, its spectrum was obtained, and then it was displayed with the specified parameters in the required place of the spectrum.

```
T1:=4;
T2:=round(span*2/Sign[i,3,triger[i]]);
if T2<1 then T2:=2048;
// Формирование сигнала
for ij:=0 to DFT.nmax do
if ((ij mod T1)<(T1/2)) and ((ij mod T2)<(T2/2))
then
DFT.fdata[ij]:=0
else
DFT.fdata[ij]:=500;
```

where T1 and T2 are two periods of the AMN signal (carrier and modulating), and T2 is taken from the array of initial data of the Sign signals, taking into account the span value (the width of the scanning band). In lines 6-11, the classical construction of a discrete AMN signal occurs.

```
f_z:=Sign[i,1,triger[i]]; // Частота в МГц
N_garm:=round(f_stop/f_z);//расчитали число гармоник
for grm:=1 to min(N_garm,Sign[i,4,1]) do
begin
f_i:=f_z*grm;
k_z:=round((f_i-f_start)*1024/(f_stop-f_start)); // номер гармоники
j0:=512-k_z;
j:=0;
//Формирование общего спектра сигнала
for k:=0 to DFT.kmax-1 do
begin
k1:=round(j0+j);
if (k1>300) and (k1<724) and (f_i>f_start) then
Spectr_sign[k]:=Spectr_sign[k]+round(Angle(i)*(Sign[i,2,triger[i]]*Spectr[k1]*abs(sin(grm*pi/2)/(grm*pi/2))/10));
j:=j+1;
end;
end;
end;
```

f_z – frequency of narrowband signal (we take the value from the task array); N_garm – number of harmonics (must be taken into account if several signal harmonics fall within the viewing band).

Lines 10-16 add the display of the signal in the overall spectrum depending on its frequency and the set bandwidth.

In this case, the signal is formed only when the simulator settings are changed once. But the noise must be generated constantly.

```
Randomize;
//Получение спектра шума
for k:=0 to DFT.kmax-1 do begin
Spectr_sum[k]:=Max(Spectr_sign[k],0.1*random(rbw*Amp));
end;
```

At the moment, noise is a random number whose value depends on rbw (the bandwidth value).

The analyzer functions include: selecting a detector, changing the frequency range, selecting a bandwidth, setting the display mode (average, maxhold, clearwrite), selecting a linear or logarithmic amplitude display scale, and working with a marker.

The implementation of this approach allowed to revive the “spectrum picture” with minimal CPU load (I get no more than 3%). There are many options for using this simulator. At the same time, you can come up with various scenarios… At the moment of adding the measured signal to the report, the amplitude of the marker, the frequency of the marker, the detector and any other parameters and settings of the simulator are recorded depending on the purpose of use.