Home Forums GENERAL The official reference “DSP code” is incorrect

The official reference “DSP code” is incorrect

Profile Photo
(joined December 2020)
Participant

Dear All
When I wanted to simulate an DP-8PSK communication system. But I got the wrong answer when I used the official example.
What I want to do is to add a matlab component between the two DSPs to add my own algorithm.
The code given by the official website is as follows:
OutputPort1 = InputPort1;
OutputPort2 = InputPort2;
OutputPort3 = InputPort3;
OutputPort4 = InputPort4;
IX = InputPort1.Sampled.Signal;
QX = InputPort2.Sampled.Signal;
IY = InputPort3.Sampled.Signal;
QY = InputPort4.Sampled.Signal;
SampleperSymbol = 1;
BitLength = 32768;
symbolNum = BitLength/6; % For DP QPSK, symbolNum = BitLength/4.
sampleNum = length(IX);
NumDownSamp = round(sampleNum/(symbolNum * SampleperSymbol));
SamplePoint = floor(NumDownSamp/2);
IX = downsample(IX, NumDownSamp, SamplePoint);
QX = downsample(QX, NumDownSamp, SamplePoint);
IY = downsample(IY, NumDownSamp, SamplePoint);
QY = downsample(QY, NumDownSamp, SamplePoint);

% Insert your algorithm here
% my code
%

% Upsampling
NumOutputSamp = length(InputPort1.Sampled.Signal);
NumSamp = length (IX);
NumUpSamp = round(NumOutputSamp/NumSamp);

IX_out = zeros(1, NumOutputSamp);
QX_out = zeros(1, NumOutputSamp);
IY_out = zeros(1, NumOutputSamp);
QY_out = zeros(1, NumOutputSamp);

for j = 1 : NumSamp

IX_out(1+(j-1)*NumUpSamp : j*NumUpSamp) = ones(1, NumUpSamp).*IX(j);
QX_out(1+(j-1)*NumUpSamp : j*NumUpSamp) = ones(1, NumUpSamp).*QX(j);
IY_out(1+(j-1)*NumUpSamp : j*NumUpSamp) = ones(1, NumUpSamp).*IY(j);
QY_out(1+(j-1)*NumUpSamp : j*NumUpSamp) = ones(1, NumUpSamp).*QY(j);

end

OutputPort1.Sampled.Signal = IX_out;
OutputPort2.Sampled.Signal = QX_out;
OutputPort3.Sampled.Signal = IY_out;
OutputPort4.Sampled.Signal = QY_out;

However, I was told by matlab that this is wrong, because the ones(1, NumUpSamp) requires NumUpSamp to be an integer, but NumUpSamp=24.0015

Attachments:

Responses (4):

    • #68566
      Profile Photo
      Hanyu Zhang
      Participant

      Dear All
      When I wanted to simulate an DP-8PSK communication system. But I got the wrong answer when I used the official example.
      What I want to do is to add a matlab component between the two DSPs to add my own algorithm.
      The code given by the official website is as follows:
      OutputPort1 = InputPort1;
      OutputPort2 = InputPort2;
      OutputPort3 = InputPort3;
      OutputPort4 = InputPort4;
      IX = InputPort1.Sampled.Signal;
      QX = InputPort2.Sampled.Signal;
      IY = InputPort3.Sampled.Signal;
      QY = InputPort4.Sampled.Signal;
      SampleperSymbol = 1;
      BitLength = 32768;
      symbolNum = BitLength/6; % For DP QPSK, symbolNum = BitLength/4.
      sampleNum = length(IX);
      NumDownSamp = round(sampleNum/(symbolNum * SampleperSymbol));
      SamplePoint = floor(NumDownSamp/2);
      IX = downsample(IX, NumDownSamp, SamplePoint);
      QX = downsample(QX, NumDownSamp, SamplePoint);
      IY = downsample(IY, NumDownSamp, SamplePoint);
      QY = downsample(QY, NumDownSamp, SamplePoint);

      % Insert your algorithm here
      % my code
      %

      % Upsampling
      NumOutputSamp = length(InputPort1.Sampled.Signal);
      NumSamp = length (IX);
      NumUpSamp = round(NumOutputSamp/NumSamp);

      IX_out = zeros(1, NumOutputSamp);
      QX_out = zeros(1, NumOutputSamp);
      IY_out = zeros(1, NumOutputSamp);
      QY_out = zeros(1, NumOutputSamp);

      for j = 1 : NumSamp

      IX_out(1+(j-1)*NumUpSamp : j*NumUpSamp) = ones(1, NumUpSamp).*IX(j);
      QX_out(1+(j-1)*NumUpSamp : j*NumUpSamp) = ones(1, NumUpSamp).*QX(j);
      IY_out(1+(j-1)*NumUpSamp : j*NumUpSamp) = ones(1, NumUpSamp).*IY(j);
      QY_out(1+(j-1)*NumUpSamp : j*NumUpSamp) = ones(1, NumUpSamp).*QY(j);

      end

      OutputPort1.Sampled.Signal = IX_out;
      OutputPort2.Sampled.Signal = QX_out;
      OutputPort3.Sampled.Signal = IY_out;
      OutputPort4.Sampled.Signal = QY_out;

      However, I was told by matlab that this is wrong, because the ones(1, NumUpSamp) requires NumUpSamp to be an integer, but NumUpSamp=24.0015

      Attachments:
    • #68576
      Profile Photo
      Ahmad Atieh
      Moderator

      Dear Hanyu,
      The code in OptiSystem components take into account when a none-integer value appears. An example if you use number of bits 32768 bits in Dual-polarization 8PSK modulation. In this case, the number of symbols is 5461.333333. Thus, we use internally an integer value in this case.
      You may check the example (DP-8PSK back to back.osd) located at the following link.
      C:\Users\USER NAME\Documents\OptiSystem 17.1 Samples\Advanced modulation systems\PSK systems\8PSK

      Regards,
      Ahmad

      • This reply was modified 1 month, 2 weeks ago by Ahmad Atieh.
    • #68710
      Profile Photo
      Hanyu Zhang
      Participant

      Dear Ahmad

      What I want to express is whether the official code is wrong .

    • #68712
      Profile Photo
      Ahmad Atieh
      Moderator

      Dear Hanyu,
      what do you mean by official code is wrong? could you please provide more details? and provide information how do you validate the code and came to the conclusion?
      Regards,
      Ahmad

    • #68719
      Profile Photo
      Hanyu Zhang
      Participant

      Dear Ahmad
      ok,I will tell the details of the problem I encountered:
      This code is officially given. The name is “DSP_Algorithm_Module.m”, and I want to implement the Stokes mapping of DP-8PSK. Stokes mapping is completed before equalization, phase estimation, and frequency offset estimation. But when I try to insert my code, I can’t get the correct result. Only when the SampleperSymbol = 0.5; can the Poincaré ball appear, but the final output is wrong because the second DSP cannot get the data. So I want to ask if there is a problem with the official code.

Login You must be logged in to reply to this topic.