With the development of Zencheer's business and the deepening of R&D work, we have come into contact with more and more demands for SDR products, especially for boards with chips such as FPGA + AD9361. Before carrying out corresponding research and development work, we have done a lot of preparatory work. The first thing is to re-understand the digital baseband signal. We know that AD9361 is a landmark product. It integrates ADC DAC and multiple radio frequency components, which greatly reduces the complexity of software radio product design. If you want the AD9361 to output the expected waveform, you need to send the data to the DAC of the AD9361 in a certain format and modulate it to the radio frequency band through IQ. What seems to be a simple process is actually a super complex process that involves too much knowledge, such as calculus, linear algebra, probability theory, signals and systems, digital signal processing, digital communications, etc. The more in-depth the research is, the more profound and profound the wireless communication technology is.

We all know several basic modulation methods: amplitude modulation, frequency modulation, and phase modulation. Among them, phase modulation has strong anti-interference ability. Considering that Zencheerâ€™s first SDR product to be launched must have high reliability, We take phase modulation, also known as PSK, as the first research object. The goal of this article is to use AD9361 to generate BPSK modulated waveforms, whose channel bandwidth can be set arbitrarily as needed.

The goal has been set. We know that BPSK changes the carrier phase with the sequence of 0 and 1. So how is this process implemented? There is a very simple mathematical operation. We assume that the phase corresponding to 1 is 0, the phase corresponding to 0 is 180 degrees, and the carrier signal is cos(wt) (you do not need to care about the amplitude and initial phase of the carrier here), then there is the following corresponding relationship :

Baseband Signal | Carrier Phase | Carrier Signal |

1 | 0 | cos(wt) |

0 | pi | cos(wt+pi)=-cos(wt) |

Assuming that 0 1 appears in the digital sequence with equal probability, the average value of these 0 1 sequences added up is 0.5, which means that this digital sequence has a DC offset. Imagine that its spectrum must have strongÂ energy at DC (Fourier transform), which is obviously not what we want, because this method wastes energy and cannot convey any information. Therefore, in the actual communication system, -1 1 (that is, NRZ, non-return to zero) is used to represent 0 1. It is still assumed that -1 1 appears with equal probability, then the average value of the sum of these -1 1 sequences is 0, In this way, the DC component can be eliminated and the anti-interference ability can be improved. The spectra of the two digital sequences are shown in the figure below.

The corresponding Matlab code is as follows:

```
clear;clc;
N=200;
Tb=4;
rb=randi([0 1],N,1);
gt = ones(1, Tb);
Sinput=[] ;
for n=1:length(rb)
if rb(n)==0
Sinput=[Sinput gt];
else
Sinput=[Sinput -1*gt]; %-1 1 sequance
%Sinput=[Sinput zeros(1, Tb)]; %0 1 sequance
end
end
plot(20*log10(abs(fft(Sinput))));
ylim([0 inf]);
```

Therefore, everyone generally adopts the following correspondence:

Baseband Signal | Carrier Phase | Carrier Signal |

1 | 0 | cos(wt) |

-1 | pi | cos(wt+pi)=-cos(wt) |

Obviously, by multiplying the digital sequence -1 1 with the carrier cos(wt), the modulated signal can be obtained directly. In this way, treat the AD9361 as a simple DAC, let it output -1 1, and then multiply it with the carrier, wouldn't you get the modulated signal? indeed so.

Furthermore, textbooks will write that there is phase inversion during BPSK demodulation, resulting in misjudgment. In actual communication systems, differential PSK or DPSK is used, that is, the current bit is XORed with the previous bit (the same is 0, The difference is 1). Therefore, the baseband signal needs to undergo a differential transformation before being multiplied by the carrier. The corresponding matlab code is as follows.

```
ds=ones(1,N);
for i=2:N
if s(i)==1
ds(i)=-ds(i-1);
else
ds(i)=ds(i-1);
end
end
```

There is no difference between the differentially encoded spectrum and the original signal spectrum. As for why the spectrum looks like this, "Principles of Communication" (Fan Changxin, Cao Lina, National Defense Industry Press) gives a good explanation.